898 words
4 minutes
AI Interview 中的实体关系分析
存储业务实体和关系数据:
┌───────────────────┬──────────────┐ │ 表/模块 │ 存储内容 │ ├───────────────────┼──────────────┤ │ User │ 用户信息 │ ├───────────────────┼──────────────┤ │ Resume │ 简历文本内容 │ ├───────────────────┼──────────────┤ │ Project │ 项目经历 │ ├───────────────────┼──────────────┤ │ KnowledgeBase │ 知识库元数据 │ ├───────────────────┼──────────────┤ │ InterviewSession │ 面试会话记录 │ ├───────────────────┼──────────────┤ │ QAHistory │ 问答历史 │ ├───────────────────┼──────────────┤ │ InterviewFeedback │ 面试反馈 │ └───────────────────┴──────────────┘pgvector (向量数据)
存储嵌入向量用于语义检索:
┌───────────────────────────┬────────────┬────────────────────┐ │ 向量类型 │ 来源 │ 用途 │ ├───────────────────────────┼────────────┼────────────────────┤ │ resume 向量 │ 简历文本 │ 根据技能点匹配简历 │ ├───────────────────────────┼────────────┼────────────────────┤ │ question 向量 │ 标准问题 │ 相似问题检索 │ ├───────────────────────────┼────────────┼────────────────────┤ │ standard_answer 向量 │ 标准答案 │ 答案评估参考 │ ├───────────────────────────┼────────────┼────────────────────┤ │ skill_point 向量 │ 技能点 │ 训练选题匹配 │ ├───────────────────────────┼────────────┼────────────────────┤ │ enterprise_knowledge 向量 │ 企业知识库 │ 最佳实践检索 │ └───────────────────────────┴────────────┴────────────────────┘实体关系图
PostgreSQL + pgvector 实体关系图
┌─────────────────────────────────────────────────────────────────────────────┐ │ PostgreSQL (结构化数据) │ └─────────────────────────────────────────────────────────────────────────────┘
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────────┐ │ User │ │ Resume │ │ Project │ ├──────────────────┤ ├──────────────────┤ ├──────────────────────┤ │ id (PK) │──┐ │ id (PK) │ │ id (PK) │ │ uuid │ │ │ user_id (FK) │──┐ │ resume_id (FK) │──┐ │ name │ └──▶│ file_path │ │ │ name │ │ │ email │ │ parsed_content │ │ │ repo_path │ │ │ created_at │ │ created_at │ │ │ description │ │ └──────────────────┘ └──────────────────┘ │ │ created_at │ │ │ └──────────────────────┘ │ │ │ │ │ │ 1:N │ │ ▼ │ ┌──────────────────────────────────────────────────────────────────────────────┴─┐ │ KnowledgeBase │ ├─────────────────────────────────────────────────────────────────────────────────┤ │ id (PK) │ ← 知识库条目ID │ │ project_id (FK) │──▶ Project │ │ type │ (skill / experience / responsibility) │ │ skill_point │ 技能点名称 │ │ content │ 文本内容 │ │ embedding_id │ ←── pgvector 引用 (可选) │ │ responsibility_id │ 职责索引 │ │ responsibility_text │ 完整职责文本 │ │ question_id │ 问题ID (去重用) │ │ session_id │ 会话ID (跨会话过滤) │ │ created_at │ │ └─────────────────────────────────────────────────────────────────────────────────┘ ▲ │ 1:N ┌────────────────────────────────────┴───────────────────────────────────────┐ │ InterviewSession │ ├─────────────────────────────────────────────────────────────────────────────┤ │ id (PK) │ │ │ user_id (FK) │──▶ User │ │ resume_id (FK) │──▶ Resume │ │ mode │ (free / training) │ │ feedback_mode │ (realtime / recorded) │ │ status │ (active / completed / cancelled) │ │ started_at │ │ │ ended_at │ │ └─────────────────────────────────────────────────────────────────────────────┘ │ │ │ 1:N │ 1:N ▼ ▼ ┌──────────────────────────────┐ ┌──────────────────────────────┐ │ QAHistory │ │ InterviewFeedback │ ├──────────────────────────────┤ ├──────────────────────────────┤ │ id (PK) │ │ id (PK) │ │ session_id (FK) ────────────┘ │ session_id (FK) ────────────┘ │ series │ │ overall_score │ │ question_number │ │ strengths (JSONB) │ │ question │ │ weaknesses (JSONB) │ │ user_answer │ │ suggestions (JSONB) │ │ standard_answer │ │ created_at │ │ feedback │ └──────────────────────────────┘ │ deviation_score │ │ created_at │ └──────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────┐ │ ContextSnapshot (Context Catch) │ ├─────────────────────────────────────────────────────────────────────────────┤ │ id (PK) │ │ session_id (String) │ │ version │ 每次压缩递增 │ │ timestamp │ │ │ compressed_summary (JSONB) │ 压缩后的摘要 │ │ created_at │ │ └─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────┐ │ pgvector (向量数据) │ └─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────┐ │ 向量类型 │ 存储内容 │ 关联实体 │ ├─────────────────────────────────────────────────────────────────────────────┤ │ resume向量 │ 简历文本嵌入 │ KnowledgeBase.embedding_id │ │ question向量 │ 标准问题嵌入 │ KnowledgeBase.content │ │ answer向量 │ 标准答案嵌入 │ QAHistory.standard_answer │ │ skill_point向量 │ 技能点嵌入 │ KnowledgeBase.skill_point │ │ enterprise向量 │ 企业知识嵌入 │ KnowledgeBase (企业知识库) │ └─────────────────────────────────────────────────────────────────────────────┘关联关系
┌─────────────────────────────────────────────────────────────────────────────┐ │ KnowledgeBase ──embedding_id──▶ pgvector.embeddings │ │ │ │ │ └──skill_point──▶ [Embedding Model] ──▶ 向量检索 │ │ │ │ │ ▼ │ │ 语义相似度搜索 (cosine similarity) │ └─────────────────────────────────────────────────────────────────────────────┘ ┌─────────────────────────────────────────────────────────────────────────────┐ │ 数据流向 │ └─────────────────────────────────────────────────────────────────────────────┘
简历上传 │ ▼ Resume (PostgreSQL) ──────▶ parsed_content ──▶ [Embedding Model] ──▶ pgvector │ │ │ ▼ └────▶ Project ──▶ KnowledgeBase ◀── skill_point ──▶ 检索匹配 │ ▼ 面试问题 → 检索最相似的技能点 │ ▼ 返回匹配的标准答案/问题关键关系:
- User 1
Resume - 一个用户多份简历 - Resume 1
Project - 一份简历多个项目 - Project 1
KnowledgeBase - 一个项目多条知识 - KnowledgeBase.embedding_id → pgvector - 知识库通过ID关联向量
- InterviewSession 1
QAHistory - 一个会话多条问答记录
AI Interview 中的实体关系分析
https://sgjki547.top/posts/pgvector-postgresql/