AI Resume Screener using Python & Llama 3

project

Setup and Installation

Before writing code, we need to set up our environment. We are keeping this private and free by running the AI locally on your machine.

First, we need an engine to run our AI model. Ollama is the easiest way to run open-source LLMs locally. Download it from ollama.com/download and follow the installation instructions for your operating system.

Once installed, open your terminal/command prompt and run:

ollama pull llama3.2:1b

First, create a new folder for your project. Next, we'll need Python to interact with Ollama and to read PDF files. To do this, run the following command in your terminal:

pip install ollama pymupdf

Now, let’s start building:

Building the Resume Screener

  1. Import the necessary libraries:
import fitz, json, ollama
  1. The Reader: LLMs can’t see PDF files directly; they need raw text. We will use PyMuPDF to strip the text layer from the document.
def extract_text_from_pdf(pdf_path): doc = fitz.open(pdf_path) text = "" for page in doc: text += page.get_text() return text
  1. The Brain: This is the key part of our AI Resume Screener. We aren’t just sending text; we are prompt engineering. We will give the AI a persona (of Senior Technical Recruiter) and specific constraints (JSON format).
def screen_resume(resume_text, job_description): prompt = f""" You are a Senior Technical Recruiter with 20 years of experience. Your goal is to objectively evaluate a candidate based on a Job Description (JD). JOB DESCRIPTION: {job_description} CANDIDATE RESUME: {resume_text} TASK: Analyze the resume against the JD. Look for key skills, experience levels, and project relevance. Be strict but fair. "React" matches "React.js". "AWS" matches "Amazon Web Services". OUTPUT FORMAT: Provide the response in valid JSON format only. Do not add any conversational text. structure: {{ "candidate_name": "extracted name", "match_score": "0-100", "key_strengths": ["list of 3 key strengths"], "missing_critical_skills": ["list of missing skills"], "recommendation": "Interview" or "Reject", "reasoning": "A 2-sentence summary of why." }} """ response = ollama.chat(model='llama3.2:1b', messages=[ {'role': 'user', 'content': prompt}, ]) return response['message']['content']
  1. The Execution: Now, we will define our standard (the Job Description), load our input (the Resume), and handle the output.
# 1. Define the Job Description (The Standard) job_description = """ We are looking for a Junior Web Developer. Must have: - React - Experience with REST APIs - Basic understanding of Next.js - Good communication skills Nice to have: - Experience with AWS or Cloud deployment - Knowledge of TypeScript """ # 2. Load the Resume (The Input) try: resume_text = extract_text_from_pdf(r"Sample_Resume.pdf") print(f"Resume loaded. Length: {len(resume_text)} characters.") except Exception as e: print(f"Error loading resume: {e}") exit() # 3. The Screening (The Processing) print("AI is analyzing the candidate... (this may take a few seconds on local hardware)") result_json_string = screen_resume(resume_text, job_description) # 4. Parse and Display Results try: # Sometimes LLMs wrap JSON in ```json blocks. We clean that up. clean_json = result_json_string.replace("```json", "").replace("```", "").strip() result_data = json.loads(clean_json) print("\n--- SCREENING REPORT ---") print(f"Candidate: {result_data.get('candidate_name', 'Unknown')}") print(f"Score: {result_data.get('match_score')}/100") print(f"Decision: {result_data.get('recommendation').upper()}") print(f"Reasoning: {result_data.get('reasoning')}") print(f"Missing Skills: {', '.join(result_data.get('missing_critical_skills', []))}") except json.JSONDecodeError: print("Failed to parse JSON. Raw output:") print(result_json_string)

Conclusion

This AI Resume Screener is a powerful tool that can help recruiters quickly identify top candidates by analyzing their resumes against a job description. By leveraging the capabilities of LLMs like Llama 3, we can automate the initial screening process and focus our attention on the most promising candidates.

Get the source code and instructions on how to run it on your local machine from the GitHub repository