简历智能搜索引擎

一个基于AI的简历智能搜索与分析服务,提供语义搜索和LLM驱动的问答功能,支持PDF简历处理和隐私优先设计。

  • by Priyanshukumaranand
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 Priyanshukumaranand/mcp-resume-engine

使用说明

📄 恢复RAG发动机

人工智能驱动的智能简历搜索 -上传PDF文件,提出问题,通过源引用获得智能答案。

🎯 概述

一个可用于生产的简历发现API,它使用语义搜索和LLM支持的问答来查找和分析简历。采用隐私优先设计,包括PII编辑和匿名ID。

flowchart LR
    subgraph Input
        PDF[📄 PDF Resume]
        Q[❓ Question]
    end
    
    subgraph Processing
        Extract[🤖 Gemini<br/>Extract Fields]
        Chunk[✂️ Semantic<br/>Chunker]
        Embed[🔢 HuggingFace<br/>Embeddings]
        Search[🔍 Vector<br/>Search]
        Rerank[📊 Reranker]
        Answer[💬 Gemini<br/>Answer]
    end
    
    subgraph Storage
        DB[(ChromaDB)]
        Redis[(Redis Queue)]
    end
    
    PDF --> Extract --> Chunk --> Embed --> DB
    Q --> Search --> DB
    DB --> Rerank --> Answer
    PDF -.-> Redis -.-> Extract

✨ 特性

  • 🔍 语义搜索 -按含义查找简历,而不仅仅是关键字
  • 🤖 人工智能问答 -询问关于候选人的自然语言问题
  • 📄 PDF处理 -从简历中提取文本和元数据
  • 🔒 隐私第一 -PII编辑和匿名候选人ID
  • ⚡ 异步处理 -用于批量上传的可选Redis队列
  • 🎯 多跳检索 -复杂的查询分解以获得更好的答案
  • 📊 置信度分数 -了解每个答案的可靠性

🚀 快速开始

选项1:Docker(推荐)

# 1. Clone the repository
git clone https://github.com/your-repo/mcp-resume-engine.git
cd mcp-resume-engine

# 2. Create .env file
echo "GEMINI_API_KEY=your_gemini_key" > .env
echo "HUGGINGFACE_API_TOKEN=your_hf_token" >> .env

# 3. Start with Docker Compose
docker-compose up --build

# 4. Open API docs
# http://localhost:8000/docs

方案2:地方发展

# 1. Create virtual environment
python -m venv .venv
.venv\Scripts\activate  # Windows
source .venv/bin/activate  # Linux/Mac

# 2. Install dependencies
pip install -r requirements.txt

# 3. Set environment variables
export GEMINI_API_KEY=your_key
export HUGGINGFACE_API_TOKEN=your_token

# 4. Run the server
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000

📁 项目结构

mcp-resume-engine/
├── backend/
│   ├── core/              # Text processing & semantic chunking
│   │   ├── chunker.py     # Section-aware resume chunking
│   │   └── preprocessor.py # Text cleaning & normalization
│   ├── embeddings/        # Vector embeddings & storage
│   │   ├── embedder.py    # HuggingFace API embeddings
│   │   └── vectorstore.py # ChromaDB vector store
│   ├── retrieval/         # Search & reranking
│   │   ├── reranker.py    # Result reranking with skill matching
│   │   ├── multihop.py    # Multi-hop retrieval for complex queries
│   │   └── verifier.py    # Confidence scoring
│   ├── queue/             # Redis queue infrastructure
│   │   ├── worker.py      # Background job processor
│   │   └── jobs.py        # Job definitions
│   ├── main.py            # FastAPI endpoints
│   ├── llm.py             # Gemini LLM integration
│   ├── models.py          # Pydantic data models
│   └── anonymizer.py      # PII redaction
├── docker-compose.yml     # Docker orchestration
├── Dockerfile             # Container build
├── requirements.txt       # Python dependencies
└── README.md

🔌 API终点

方法 端点 描述
POST /ingest_pdf 上传并处理简历PDF
POST /qa 询问有关简历的问题
GET /health 使用队列状态进行健康检查
GET /resumes 列出所有已处理的简历
DELETE /resumes/{id} 删除简历

上传简历

curl -X POST "http://localhost:8000/ingest_pdf" \
  -F "file=@resume.pdf"

答复:

{
  "status": "processed",
  "id": "abc123",
  "name": "John Doe",
  "skills": ["Python", "React", "AWS"],
  "chunk_count": 8
}

提问

curl -X POST "http://localhost:8000/qa" \
  -H "Content-Type: application/json" \
  -d '{"question": "Who has Python and machine learning experience?", "top_k": 5}'

答复:

{
  "answer": "John Doe has extensive Python and ML experience...",
  "confidence_score": 0.92,
  "sources": [...],
  "is_fallback": false
}

异步上传(批量处理)

curl -X POST "http://localhost:8000/ingest_pdf?async_mode=true" \
  -F "file=@resume.pdf"

退货 job_id 用于状态检查。

⚙️ 建筑

数据摄取管道

sequenceDiagram
    participant User
    participant API
    participant LLM as Gemini LLM
    participant HF as HuggingFace API
    participant Vec as ChromaDB
    
    User->>API: Upload PDF
    API->>API: Extract text & strip PII
    API->>LLM: Extract fields (name, skills, projects)
    API->>API: Semantic chunking by sections
    API->>HF: Generate embeddings
    HF->>API: 384-dim vectors
    API->>Vec: Store chunks + metadata
    API->>User: ✓ Resume processed

问答管道

sequenceDiagram
    participant User
    participant API
    participant HF as HuggingFace API
    participant Vec as ChromaDB
    participant LLM as Gemini LLM
    
    User->>API: Ask question
    API->>API: Expand query
    API->>HF: Embed question
    HF->>API: Query vector
    API->>Vec: Semantic search (top 15)
    Vec->>API: Candidate chunks
    API->>API: Rerank by skills & sections
    API->>LLM: Generate answer with context
    LLM->>API: Natural language answer
    API->>User: Answer + confidence + sources

🐳 Docker编写服务

services:
  api:        # FastAPI server (port 8000)
  redis:      # Job queue (port 6379)
  worker:     # Background processors (5 replicas)

缩放工人:

docker-compose up --scale worker=10

🔧 环境变量

变量 必填 描述
GEMINI_API_KEY ✅ 用于LLM的Google Gemini API密钥
HUGGINGFACE_API_TOKEN ✅ 用于嵌入的HuggingFace API令牌
ALLOWED_ORIGINS ❌ CORS源(默认值: *)
REDIS_URL ❌ Redis连接URL(在Docker中自动配置)

📊 技术栈

组件 技术
API框架 FastAPI+Pydantic
LLM 谷歌双子座2.5 Flash
嵌入 HuggingFace推理API(MiniLM-L6-v2)
矢量存储 ChromaDB
队列 Redis+RQ
容器 Docker+Docker组合

🔒 隐私功能

  • PII补救措施:电话号码、电子邮件、地址自动屏蔽
  • 匿名ID:基于哈希的候选标识符
  • 无原始存储:不存储原始PDF,只存储处理过的文本

📝 许可证

麻省理工学院