File size: 3,059 Bytes
2792fd5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from typing import List
from pydantic import BaseModel
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
from langchain.chat_models import ChatOpenAI

# Define the structured output model
class MHEvaluationResult(BaseModel):
    category: str  # Category I, II, or III
    evidence: str  # Justification for the categorization

# Define the prompt template
resume_evaluation_prompt = PromptTemplate(
    input_variables=["job_description", "candidates_profile", "checkpoints", "answer_script"],
    template="""
You are an expert recruiter specializing in evaluating resumes against job descriptions.
Your task is to evaluate and assign a categorization for the candidate's resume based on the "checkpoints" and "answer_script" provided to understand how well it aligns with the JD. Also, provide a brief reasoning. You are required to take a pragmatic and holistic approach considering the context of the resume and implied aspects.

### Steps:
Step 1: Understand the Job Description along with the checkpoints and answer script.
Step 2: Analyze if the answers from the checkpoints and answer script satisfy the must-haves while considering the following aspects:
- Years of experience: Consider responsibilities and role context rather than strictly adhering to a numeric limit.
- Education: If a post-graduate degree is mentioned, assume the person has an undergraduate degree.
- Implicit and explicit matches: Identify if relevant skills and experience satisfy the role.

Step 3: Based on analysis, categorize the resume into:
- **Category I:** JD does not explicitly or implicitly specify any must-haves.
- **Category II:** Satisfies all must-haves explicitly or implicitly.
- **Category III:** Lacks one or more must-haves.

Step 4: Provide evidence supporting the categorization.

**Job Description:**
{job_description}

**Candidate's Resume:**
{candidates_profile}

**Checkpoints:**
{checkpoints}

**Answer Script:**
{answer_script}

### Output Format:
- **category**: (I/II/III)
- **evidence**: A concise 70-100 word justification.

Output:
- Category: [Assign category]
- Evidence: [Provide justification]
"""
)

# Initialize the LLM (e.g., GPT-4)
llm = ChatOpenAI(model_name="gpt-4o-mini", temperature=0)

# Create an LLMChain
resume_evaluation_chain = LLMChain(llm=llm, prompt=resume_evaluation_prompt)

# Example input
job_description = "Looking for a Data Scientist with 3+ years of experience in Python and ML. A Master's degree is preferred."
candidates_profile = "John Doe has a Master's in Data Science and 4 years of Python experience in ML projects."
checkpoints = "1. Must have Python experience. 2. Must have a Master's degree. 3. Must have 3+ years of ML experience."
answer_script = "John Doe explicitly mentions 4 years of Python and ML experience, along with a Master's degree."

# Run the evaluation
response = resume_evaluation_chain.run(
    job_description=job_description,
    candidates_profile=candidates_profile,
    checkpoints=checkpoints,
    answer_script=answer_script
)

print(response)