Spaces:
Running
title: SmartHire AI
emoji: π―
colorFrom: indigo
colorTo: purple
sdk: docker
pinned: false
license: mit
short_description: Transformer-based resume and job description matching API
π€ SmartHire AI: Transformer-Based Resume & Job Matching System
ATS-inspired AI recruitment system that matches candidate resumes with job descriptions using fine-tuned Sentence Transformer embeddings and cosine semantic similarity β going far beyond simple keyword matching.
π Project Overview
SmartHire AI is a production-style HRTech application that demonstrates:
- Transformer-based NLP using
all-MiniLM-L6-v2(fine-tuned on 127 resumeβJD pairs across 41 job roles) - Semantic understanding via mean-pooled sentence embeddings
- Cosine similarity scoring β context-aware, not keyword-matching
- Candidate ranking from multiple simultaneous resume uploads
- Skill gap analysis with critical missing skill detection (300+ skill vocabulary)
- Persistent vector index (ChromaDB/NumPy) for instant sub-100ms resume search
- REST API (FastAPI) for frontend integration
- Interactive recruiter dashboard built with Streamlit + Plotly
π Fine-Tuning Results
| Metric | Value |
|---|---|
| Pearson r | 0.9733 |
| Spearman Ο | 0.9604 |
| Strong Match Accuracy | 98% |
| Partial Match Accuracy | 47% |
| Mismatch Accuracy | 100% |
| Overall 3-tier Accuracy | 81.25% |
| Fine-tuning Gain | +9.4% |
Fine-tuned on 127 pairs across 41 job roles: 43 Strong (34%), 40 Partial (31%), 44 Mismatch (35%)
ποΈ Project Structure
SmartHireAI/
β
βββ app/
β βββ streamlit_app.py # Full Streamlit dashboard (dark mode, port 8501)
β
βββ api/
β βββ __init__.py
β βββ main.py # FastAPI REST API server (port 8000)
β βββ README.md # Full API endpoint documentation
β
βββ src/
β βββ __init__.py
β βββ parser.py # PDF, DOCX, TXT resume parser
β βββ preprocess.py # Text cleaning & normalization pipeline
β βββ model.py # Sentence Transformer embedding model
β βββ similarity.py # Cosine similarity & calibrated scoring
β βββ skills.py # Skill extraction & gap analysis (300+ skills)
β βββ ranking.py # Candidate ranking & export
β βββ vector_store.py # ChromaDB/NumPy persistent vector index
β
βββ train/
β βββ training_data.json # 127 labeled resumeβJD pairs (41 job roles)
β
βββ datasets/
β βββ sample_jd.txt
β βββ candidate_alice.txt
β βββ candidate_bob.txt
β βββ candidate_carol.txt
β βββ candidate_david.txt
β
βββ finetune.py # Fine-tuning script (CosineSimilarityLoss, 6 epochs)
βββ evaluate.py # Evaluation (Pearson r, Spearman Ο, 3-tier accuracy)
βββ diagnose.py # Calibration diagnostics
βββ requirements.txt
βββ RUN_APP.bat # Windows: launch Streamlit UI
βββ RUN_API.bat # Windows: launch FastAPI server
βββ SETUP_AND_RUN.bat # Windows: first-time setup
βββ main.py # CLI entry point
β‘ Quick Start
1. Clone the Repository
git clone https://github.com/Vishu200672/SmartHire-AI.git
cd SmartHire-AI
2. Create a Virtual Environment
python -m venv venv
source venv/bin/activate # Linux / macOS
# .\venv\Scripts\activate # Windows
3. Install Dependencies
pip install -r requirements.txt
β οΈ First run downloads the embedding model (~90 MB). Subsequent runs use the HuggingFace cache.
4. Run the Streamlit Dashboard
streamlit run app/streamlit_app.py
# β http://localhost:8501
5. Run the REST API
uvicorn api.main:app --host 0.0.0.0 --port 8000 --reload
# β http://localhost:8000
# β http://localhost:8000/docs (interactive Swagger UI)
Both servers can run simultaneously β they share the same
src/model.
6. Run the CLI Demo
python main.py --demo
# Or with your own files:
python main.py --resume resume.pdf --jd job_description.txt
π REST API
SmartHire AI includes a full FastAPI REST API for integrating the matching engine into any frontend (React, Next.js, Vue, Node.js, etc.).
Base URL
http://localhost:8000
Interactive Docs
http://localhost:8000/docs β Swagger UI (try all endpoints in browser)
http://localhost:8000/redoc β Redoc
Key Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Health check |
| GET | /model/info |
Loaded model metadata |
| POST | /match |
Match resumes vs JD β main endpoint |
| POST | /skills |
Skills-only analysis |
| POST | /index/build |
Build persistent vector index |
| POST | /index/search |
Instant search against index (<100ms) |
| GET | /index/info |
Index stats |
| GET | /index/candidates |
List indexed resumes |
| POST | /index/add |
Add single resume to index |
| DELETE | /index/clear |
Clear index |
| POST | /parse |
Parse file β raw text |
| POST | /embed |
Get embedding vector for any text |
Example β Match Resumes (JavaScript)
const form = new FormData();
form.append("resumes", resumeFile1);
form.append("resumes", resumeFile2);
form.append("jd_text", "Looking for Python ML Engineer with PyTorch...");
form.append("similarity_weight", "0.7");
const res = await fetch("http://localhost:8000/match", {
method: "POST",
body: form,
});
const data = await res.json();
// data.candidates β ranked list with scores, skills, recommendations
Example Response
{
"status": "success",
"duration_sec": 1.23,
"total_candidates": 2,
"summary": {
"average_score": 72.5,
"highest_score": 85.0,
"highly_recommended": 1,
"recommended": 1
},
"candidates": [
{
"rank": 1,
"name": "John_Doe",
"score_pct": 85.0,
"semantic_similarity": 91.2,
"skill_coverage_pct": 75.0,
"recommendation": "Highly Recommended",
"matching_skills": ["python", "pytorch", "docker"],
"missing_skills": ["kubernetes"],
"critical_missing": [],
"ai_insight": "Strong contextual alignment with the JD..."
}
]
}
See api/README.md for full endpoint documentation.
π₯οΈ Streamlit Dashboard Features
| Tab | Features |
|---|---|
| Upload & Analyze | Upload PDF/DOCX/TXT resumes, paste or upload JD, run pipeline |
| Match Results | Score distribution bar chart, scatter plot, per-candidate cards |
| Skill Gap Analysis | Matching/missing/critical skill chips, skill matrix chart |
| Candidate Ranking | Leaderboard table, gauge chart for top candidate, CSV export |
| Vector Index | Build/search persistent resume index, instant JD search |
ποΈ Vector Index
SmartHire AI includes a persistent vector index that pre-encodes resumes so JD search is instant:
Normal flow: Upload resumes β encode each (~0.06s each) β compare β results
Vector index: Index resumes once β search any JD β results in <100ms
Backends supported:
- ChromaDB (recommended) β
pip install chromadb - NumPy flat-file (automatic fallback) β no extra install needed
Usage via API:
# Index resumes once
curl -X POST http://localhost:8000/index/build \
-F "resumes=@resume1.pdf" -F "resumes=@resume2.docx"
# Search instantly for any JD
curl -X POST http://localhost:8000/index/search \
-F "jd_text=Python ML Engineer with PyTorch experience" \
-F "top_k=5"
π§ How It Works
Architecture Pipeline
Resume (PDF/DOCX/TXT)
β
βΌ
[parser.py] Extract raw text
β
βΌ
[preprocess.py] Normalize β clean β chunk (400 tokens, 50 overlap)
β
βΌ
[model.py] Tokenize β forward pass β mean pooling β L2 normalize β embedding
β
ββββββββββββββββββββββββββββββββββββ
βΌ βΌ
[similarity.py] [skills.py]
Cosine similarity vs JD Skill extraction (300+ vocab)
Calibrated score 0β100% Gap analysis (matching/missing/critical)
β β
ββββββββββββββββ¬ββββββββββββββββββββ
βΌ
[ranking.py]
Composite score = 70% semantic + 30% skill
Sort β Recommendation tier β AI insight
Composite Ranking Score
Final Score = (Semantic Similarity Γ 0.70) + (Skill Coverage Γ 0.30)
Weights are configurable via API parameter or Streamlit sidebar slider.
π― Recommendation Tiers
| Score | Recommendation | Action |
|---|---|---|
| β₯ 60% | π’ Highly Recommended | Fast-track to interview |
| 38β60% | π΅ Recommended | Schedule screening call |
| 18β38% | π Consider | Review manually |
| < 18% | π΄ Not Recommended | Archive |
π οΈ Tech Stack
| Component | Technology |
|---|---|
| Core Model | Fine-tuned all-MiniLM-L6-v2 (Sentence Transformers) |
| DL Framework | PyTorch 2.0+ |
| NLP Library | Hugging Face Transformers + Sentence-Transformers |
| REST API | FastAPI + Uvicorn |
| Vector Store | ChromaDB / NumPy |
| Web App | Streamlit |
| Charts | Plotly |
| PDF Parsing | pdfplumber + PyPDF2 |
| DOCX Parsing | python-docx |
| Data | Pandas, NumPy |
π Performance Benchmarks
| Operation | Time (CPU) |
|---|---|
| Model load (first time) | ~5β10s |
| Encode 1 resume | ~0.06s |
| Encode 60 resumes | ~4β5s |
| Vector index search | <100ms |
| Skill gap analysis | <0.01s per candidate |
π Module Documentation
Each module is fully documented with:
- Google-style docstrings
- Python type hints throughout
loggingat every pipeline step- Meaningful error messages
π€ Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Commit changes (
git commit -m "Add: your feature") - Push to branch (
git push origin feature/your-feature) - Open a Pull Request
π License
This project is licensed under the MIT License β see LICENSE for details.
π Acknowledgements
- Hugging Face for Transformers and
all-MiniLM-L6-v2 - Sentence Transformers for the fine-tuning framework
- FastAPI for the API framework
- Streamlit for the dashboard framework
- Plotly for interactive charts
- ChromaDB for the vector store
π¬ Contact
Built as a portfolio project demonstrating Transformer-based NLP, semantic search, fine-tuning, REST API design, and production ML engineering practices.
GitHub: github.com/Vishu200672/SmartHire-AI HF Space: huggingface.co/spaces/Vishu2006/SmartHire-AI