Metadata-Version: 2.4
Name: job-talent-match
Version: 13.7.0
Summary: 基于KylinOS的AI智能匹配与能力图谱系统
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: fastapi>=0.110
Requires-Dist: uvicorn[standard]>=0.27
Requires-Dist: pydantic>=2.0
Requires-Dist: python-multipart>=0.0.9
Requires-Dist: python-dotenv>=1.0
Requires-Dist: bcrypt<4.0,>=3.2
Requires-Dist: pyjwt>=2.0
Requires-Dist: openai>=1.0
Requires-Dist: jieba>=0.42
Requires-Dist: rank-bm25>=0.2
Requires-Dist: pycryptodome>=3.20
Requires-Dist: python-docx>=1.0
Requires-Dist: pypdf>=4.0
Requires-Dist: olefile>=0.46
Requires-Dist: numpy>=1.24
Requires-Dist: requests>=2.31
Requires-Dist: pymysql>=1.1
Requires-Dist: reportlab<4.1,>=4.0; python_version < "3.9"
Requires-Dist: reportlab>=4.0; python_version >= "3.9"
Requires-Dist: eval_type_backport>=0.2; python_version < "3.10"

# 人岗智能匹配与能力图谱系统

基于 KylinOS 的 AI 匹配引擎，支持员工与企业的双向智能推荐。

---

## 目录结构

```
v11.1/
├── server.py                 # FastAPI 应用入口 & 启动逻辑
├── core/database.py           # SQLite 连接管理（线程级复用）
├── configs/
│   ├── env.py                 # 环境变量加载（DEEPSEEK/SiliconFlow API Key）
│   └── matching_config.py     # 匹配引擎常量（候选池、嵌入维度等）
├── routers/                   # API 路由
│   ├── auth_router.py         # 注册/登录
│   ├── user_router.py         # 用户信息、简历上传
│   ├── enterprise_router.py   # 企业信息
│   ├── position_router.py     # 岗位发布/搜索/批量
│   ├── application_router.py  # 投递/状态管理
│   ├── recommendation_router.py  # 推荐接口（jobs/talent）
│   ├── match_router.py        # 匹配画像/运行/详情
│   ├── skill_router.py        # 技能图谱/差距/学习路径
│   ├── feedback_router.py     # 反馈评分
│   ├── notification_router.py # 通知（含 SSE 实时推送）
│   └── admin_router.py        # 管理端：全量训练等
├── services/
│   ├── matching/              # 三模块匹配引擎
│   │   ├── __init__.py        # MatchingEngine 组合 0.2/0.3/0.5
│   │   ├── rule_matcher.py    # 规则模块（学历/工龄/薪资/学校/年龄）
│   │   ├── semantic_matcher.py# 语义模块（经历/专业/项目/获奖/地域/职业）
│   │   └── skill_graph_matcher.py  # 图谱模块（技能/知识图谱结构）
│   ├── factors/               # 各因子评分实现
│   │   ├── base.py            # Factor / FactorRegistry 基类
│   │   ├── skill.py           # 技能匹配度（bigram F1 + 共现）
│   │   ├── education.py       # 学历层次
│   │   ├── experience.py      # 相关经历（bigram F1 + 时间衰减）
│   │   ├── years.py           # 工龄匹配
│   │   ├── salary.py          # 薪资重合度
│   │   ├── school.py          # 学校层次
│   │   ├── major.py           # 专业匹配
│   │   ├── project.py         # 项目经历
│   │   ├── award.py           # 获奖加分
│   │   ├── location.py        # 地域匹配
│   │   ├── age.py             # 年龄匹配
│   │   ├── gender.py          # 性别匹配（已禁用，weight=0）
│   │   ├── job_type.py        # 工作性质
│   │   ├── occupation.py      # 职业分类（ISCO）
│   │   └── kge_graph.py       # 知识图谱结构（匈牙利+Jaccard替代KGE）
│   ├── recommendation_service.py  # 搜索流水线（向量→BM25→SQL回退+公司多样混排）
│   ├── profile_service.py     # 用户/岗位画像加载与同步
│   ├── indexing_service.py    # ZVec + BM25 索引管理
│   ├── document_processor.py  # 语义分块
│   ├── skill_normalizer.py    # 技能归一化（ontology + embedding）
│   ├── skill_graph.py         # 技能图谱 DAG / 差距分析 / 学习路径
│   ├── skill/
│   │   └── cooccurrence.py    # 共现图构建 + LLM 补充
│   └── vector/
│       ├── __init__.py        # 统一导出
│       ├── zvec_store.py      # numpy 暴力搜索向量存储
│       ├── embed_service.py   # 嵌入 API（SiliconFlow BGE-M3）
│       └── bm25_store.py      # BM25 关键词检索
├── static/                    # 前端静态文件
│   ├── user.html              # 个人端页面
│   ├── enterprise.html        # 企业端页面
│   ├── css/user.css           # 个人端样式
│   ├── css/enterprise.css     # 企业端样式
│   └── js/user.js             # 个人端 JS
│   └── js/enterprise.js       # 企业端 JS
├── utils/
│   ├── file_parser.py         # 文件解析（DOCX/PDF/TXT）
│   ├── StructuredExtractor.py # LLM 结构化提取
│   └── SkillExtractor.py      # 技能提取
├── repositories/              # 数据访问层
│   ├── user_repo.py           # 用户数据查询
│   └── job_repo.py            # 岗位数据查询
├── schemas.py                 # Pydantic 请求/响应模型
└── databases/
    ├── app.db                 # SQLite 数据库
    └── database_schema.sql    # 数据库建表语句
```

---

## 启动

```bash
# 单 worker
python -m uvicorn server:app --host 0.0.0.0 --port 8000

# 多 worker（推荐，需 4GB 内存）
python -m uvicorn server:app --host 0.0.0.0 --port 8000 --workers 4
```

首次启动会自动创建数据库表、填充示例数据。访问：

| 页面 | 地址 |
|------|------|
| 登录 | `http://localhost:8000/` |
| 个人端 | `http://localhost:8000/user?uuid=xxx&token=xxx` |
| 企业端 | `http://localhost:8000/enterprise?uuid=xxx&token=xxx` |
| API 文档 | `http://localhost:8000/docs` |

---

## 匹配权重体系

### 模块间权重

```
规则模块 (0.2)
  学历层次 ×0.22 → 有效 0.044
  工龄匹配 ×0.22 → 有效 0.044
  薪资重合 ×0.28 → 有效 0.056
  学校层次 ×0.17 → 有效 0.034
  年龄匹配 ×0.11 → 有效 0.022

语义模块 (0.3)
  相关经历 ×0.25 → 有效 0.075
  专业匹配 ×0.15 → 有效 0.045
  项目经历 ×0.20 → 有效 0.060
  获奖加分 ×0.10 → 有效 0.030
  地域匹配 ×0.15 → 有效 0.045
  工作性质 ×0.05 → 有效 0.015
  职业分类 ×0.10 → 有效 0.030

图谱模块 (0.5)
  技能匹配度 ×0.50 → 有效 0.250
  知识图谱结构 ×0.50 → 有效 0.250
```

### 硬条件（不通过直接过滤）

学历、性别、年龄、工作性质、工作年限、薪资期望 — 六项硬条件不满足直接跳过，不参与评分。

---

## 搜索流水线

```
请求进入
  ↓
向量搜索（ZVec numpy 暴力搜 + BM25 混合）
  ↓
候选不足？→ BM25 二次搜索
  ↓
候选仍不足？→ SQL 回退（扫描全部活跃数据）
  ↓
对每个候选项执行硬条件过滤 + engine.compute() 评分
  ↓
按总分降序排序
  ↓
公司多样性混排（避免单一公司霸榜）
  ↓
返回 top_k
```

---

## 关键技术选型

| 组件 | 方案 | 说明 |
|------|------|------|
| 向量搜索 | numpy 暴力（无 FAISS） | 当前数据量小，无需近似索引 |
| 嵌入模型 | SiliconFlow BGE-M3（API） | 1024 维，文本/代码混合 |
| LLM | DeepSeek v4 Flash（API） | 简历解析、技能关系补充 |
| 匹配算法 | 匈牙利 O(n³) + bigram F1 | 纯 Python 实现，无 scipy |
| 数据库 | SQLite（WAL 模式） | 单机部署，零运维 |
| 认证 | JWT（PyJWT + bcrypt） | 无状态 token |

---

## 因子评分算法

| 因子 | 算法 |
|------|------|
| 技能匹配度 | bigram F1 + 共现图 Jaccard + 前置覆盖率 |
| 学历层次 | EDUCATION_LEVEL 映射 + 差值衰减 |
| 相关经历 | bigram F1 × 时间衰减权重 |
| 工龄匹配 | 中位数距离衰减 |
| 薪资重合度 | 期望与岗位薪资的交叠比 |
| 学校层次 | JSON 学校分级（最高 4 级） |
| 专业匹配 | 嵌入余弦相似度（major→job text） |
| 地域匹配 | 居住地与岗位地点的子串匹配 |
| 年龄匹配 | 距离期望中位数衰减 |

---

## 环境变量

创建 `.env` 文件在项目根目录：

```
DEEPSEEK_API_KEY=sk-your-key-here
```

| 变量 | 说明 | 默认值 |
|------|------|--------|
| `DEEPSEEK_API_KEY` | DeepSeek / SiliconFlow API Key | 必填 |
| `SILICONFLOW_API_KEY` | SiliconFlow 专用 Key | 同 DEEPSEEK_API_KEY |
