This uses a combination of bi-encoders, cross-encoders, and LLM, to rank candidate resumes against a given job description with strong accuracy.
- Ranking Architecture: starting with a fast bi-encoder for initial filtering, followed by cross-encoder and LLM-as-a-judge for detailed re-ranking.
- Structured Data Extraction: uses LLMs to parse unstructured text from resumes and job descriptions into a structured JSON format, capturing key details like skills, experience, and qualifications.
- Resume Parsing: supports resumes in various formats, including
.pdf,.docx, and.txt. - Ensemble Scoring: combines the strengths of different models by generating a weighted final score from both a cross-encoder and an LLM-based evaluation.
The pipeline processes resumes in several sequential stages:
- Text Extraction: Raw text is extracted from all resume files in the
resumes/directory. - Structured Data Generation:
- The raw text of the job description is converted into a structured JSON object outlining key requirements.
- Each resume's text is converted into a structured JSON object, detailing the candidate's profile.
- Initial Filtering (Bi-Encoder): A computationally efficient bi-encoder model creates embeddings for the job description and all resumes. It then calculates the cosine similarity between them to perform an initial ranking, quickly identifying a list of promising candidates.
- Detailed Re-ranking (Cross-Encoder & LLM): The top candidates from the initial filtering are passed to two more powerful models for a finer-grained analysis:
- LLM-as-a-Judge: LLM to evaluates each top candidate against the structured job requirements, providing a detailed analysis and a final score.
- Cross-Encoder: A cross-encoder model performs a direct, pairwise comparison between the job description and each resume, yielding a highly accurate similarity score.
- Final Ranking: The scores from the LLM-as-a-judge and the cross-encoder are combined using configurable weights to produce the final, ranked list of candidates. The results are saved in the
data/directory.
- Python 3.11+
- An OpenAI API key
-
Clone the repository:
git clone https://github.com/DanielTobi0/ResumeRanker.git cd ResumeProject-main -
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Set up your environment variables: Create a file named
.envin the root directory and add your OpenAI API key:OPENAI_API_KEY="your-api-key-here"
- Place the job description in the
job_description.txtfile. - Add all candidate resumes to the
resumes/directory. - Run the main pipeline from the command line:
python main.py
You can customize the pipeline's execution with the following arguments:
--top-resumes: The number of top-ranking resumes to display. (Default:5)--llm-scoring-weight: The weight to apply to the LLM-as-a-judge score. (Default:0.7)--cross-encoder-weight: The weight to apply to the cross-encoder score. (Default:0.3)--job-description: The path to the job description file. (Default:job_description.txt)--resumes-dir: The path to the directory containing resumes. (Default:resumes/)--data-dir: The directory to store intermediate and final results. (Default:data/)
Example:
python main.py --top-resumes 3 --llm-scoring-weight 0.6 --cross-encoder-weight 0.4├── job_description.txt # Input: The job description
├── main.py # Main script to run the pipeline
├── requirements.txt # Project dependencies
├── resumes/ # Input: Directory for all resume files
├── data/ # Output: Stores structured data and final rankings
├── src/ # Source code
│ ├── extraction/ # Modules for extracting structured data
│ ├── models/ # Model loading and schema definitions
│ ├── ranking/ # Modules for ranking logic
│ └── utils/ # Helper functions and text extractors
└── cached_model/ # Stores downloaded sentence-transformer models