Resume Evaluation Tool Using RAG

Sambhav Mehta
6 min readOct 14, 2024

In this blog we will going to learn how one can implement a GenAI project just by reading the documentation provided in this blog.

Workflow

Basic Understand of the project:

Smart ATS is a web application that helps improve resumes for Applicant Tracking Systems (ATS). It evaluates resumes based on job descriptions, providing feedback on how well the resume matches the job and suggesting missing keywords for optimization.

Installation

Clone the repository:

git clone "Your Github repo link"

Create a virtual environment and activate it:

python3 -m venv venv
source venv/bin/activate

Install the required dependencies

pip install -r requirements.txt
streamlit
python-dotenv
langchain-openai
langchain
openai
PyPDF2

Set up environment variables by creating a .env file with the necessary keys (e.g., OpenAI API key).

Importing all the dependencies

import streamlit as st
import os
import PyPDF2 as pdf
import openai
from dotenv import load_dotenv

os : It provides a way of interacting with the operating system. It is used to access environment variables, specifically to get and set the OpenAI API key (os.getenv and os.environ).

load_dotenv : It reads key-value pairs from a .env file and adds them to the environment variables. load_dotenv() is used to load the OpenAI API key from the .env file so it can be used securely without hardcoding it into the script.

streamlit : It is used to create the user interface, handle file uploads, and capture user input, for example in our case the given job description. It serves as the front-end for the RAG-based resume evaluation tool.

PDF Extraction: This class will be used for Reading and extracting text from the uploaded resume PDF.

OpenAI : Using OpenAI’s API to process the extracted resume and match it against the provided job description.

By implementing Retrieval-Augmented Generation (RAG) we will going to evaluate the model performance based on the job description.

Setting Up Environment Variables for API Configuration

  • load_dotenv() loads the environment variables from a .env file.
  • os.getenv("OPENAI_API_KEY") retrieves the API key from the environment.
  • os.environ['OPENAI_API_KEY'] sets the API key in the current session's environment variables, making it available to any code or library that needs it.
load_dotenv()  # Load all environment variables

openai.api_key = os.getenv("OPENAI_API_KEY")

Reading and Processing PDF Files

The first major function within our application is designed to read PDF files:

  • Using the PdfReader class from PyPDF2, when a user uploads a resume, the application reads the text from each page of the document and merges it into a single continuous string.
# extract all the text from the uploaded CV
def input_pdf_text(uploaded_file):
reader = pdf.PdfReader(uploaded_file)
text = ""
for page in range(len(reader.pages)):
page = reader.pages[page]
text += str(page.extract_text())
return text

Pasting the Job Description as input and getting response from ChatGPT

Input Prompt: This prompt is a string which contains the job description and resume.

We need to send the request to the OpenAI model with a system role ("You are a skilled ATS specialized in tech jobs.") and the user input prompt (the detailed prompt with resume and job description).

def get_openai_response(input_prompt):

"""This function sends an API request
to OpenAI's gpt-3.5-turbo model to get
a response based on an input_prompt."""
"

response = openai.ChatCompletion.create(
model="
gpt-3.5-turbo", # You can change this to "gpt-4" if you have access
messages=[
{"
role": "system", "content": "You are a skilled ATS (Applicant Tracking System) specialized in tech jobs."},
{"
role": "user", "content": input_prompt}
]
)
return response['choices'][0]['message']['content'].strip()

The function returns the response from GPT, specifically the content of the message from the model, and strips any surrounding whitespace.

input_prompt_template = """
Hey, act like a skilled or very experienced ATS (Applicant Tracking System)
with a deep understanding of the tech field, software engineering, data science, data analysis,
and big data engineering. Your task is to evaluate the resume based on the given job description.
You must consider that the job market is very competitive, and you should provide
the best assistance for improving the resume. Assign the percentage match based
on the job description and
list the missing keywords with high accuracy.
resume: {text}
description: {jd}

I want the response in a single string structured as follows:
{{"JD Match": "X%", "MissingKeywords": ["keyword1", "keyword2"], "Profile Summary": "summary text"}}
"""
  • Purpose: This is a template for the input prompt that is passed to the GPT model.
  • Variables:
    {text} will hold the extracted resume text.
    {jd} will hold the job description text.
  • Description:
  • The template guides GPT to act like an ATS specialized in tech jobs and evaluate how well the resume matches the job description.
  • GPT is also asked to provide a percentage match, missing keywords, and a summary of the profile.
  • The response is expected in a structured JSON format.
## Streamlit app
st.title("Smart ATS")
st.text("Improve Your Resume for ATS")
jd = st.text_area("Paste the Job Description")
uploaded_file = st.file_uploader("Upload Your Resume", type="pdf", help="Please upload the PDF")

submit = st.button("Submit")

if submit:
if uploaded_file is not None:
text = input_pdf_text(uploaded_file)
input_prompt = input_prompt_template.format(text=text, jd=jd)
response = get_openai_response(input_prompt)
st.subheader("ATS Evaluation")
st.text_area("Response", value=response, height=200)
  • st.title(“Smart ATS”): This sets the title of the page/app as “Smart ATS”.
  • st.text(“Improve Your Resume for ATS”): A short description is added below the title, indicating that the purpose of the app is to help improve the ATS score for the resumes.
  • jd = st.text_area(“Paste the Job Description”): This creates a text area where the user can paste the Job Description. The input from the user is stored in the jd variable.
  • uploaded_file = st.file_uploader(“Upload Your Resume”, type=”pdf”, help=”Please upload the PDF”): This component allows the user to upload their resume in PDF format. The uploaded file is stored in the uploaded_file variable. The help parameter provides a tooltip to assist the user with instructions for uploading the PDF file only.
  • submit = st.button(“Submit”): A submit button is created, and when clicked, the value of submit will be set to True.
  • if uploaded_file is not None: This condition checks whether the user has uploaded a PDF file or not.
  • text = input_pdf_text(uploaded_file): If the file is uploaded, the input_pdf_text function is called to extract the text from the uploaded resume. The extracted text is stored in the text variable.
  • input_prompt = input_prompt_template.format(text=text, jd = jd): The input_prompt_template is formatted with the extracted resume text and the job description pasted by the user. This creates a prompt that will be sent to an OpenAI API for evaluation.
  • response = get_openai_response(input_prompt): The prompt is sent to OpenAI’s API using the get_openai_response function, which likely returns a response evaluating the resume based on the job description.
  • st.subheader(“ATS Evaluation”): If the resume is successfully uploaded and evaluated, a subheader called “ATS Evaluation” is displayed.
  • st.text_area(“Response”, value=response, height=200): A text area is created to display the response from OpenAI. The response is shown in a read-only format in this text area, with a height of 200 pixels.

How This Application Works

This app provides a solution for evaluating your resume by following these steps:

  1. User Inputs:
  • Paste the Job Description.
  • Upload a Resume (in PDF) format.

2. Process:

  • The app extracts text from the uploaded resume and combines it with the job description.
  • Using OpenAI’s GPT model, the app evaluates the resume and compares it to the job description, looking for key differences like missing keywords.

3. Output:

The app provides feedback in the form of a score or suggestions, such as:

  • Resume Score: How well your resume matches the job description.
  • Missing Keywords: Keywords or skills mentioned in the job description but missing in your resume.

Summary

This tool allows you to upload your resume, paste a job description, and get an ATS evaluation. The app provides feedback on how well your resume aligns with the job description and highlights missing keywords, improving your chances of passing an ATS and landing the job interview.

For more info visit my GitHub repo at :

https://github.com/sambhavm22/GenAI_ATS_Resume

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Sambhav Mehta
Sambhav Mehta

Written by Sambhav Mehta

I make content on data science and related field

No responses yet

Write a response