Spaces:
Sleeping
Sleeping
Update cv_prompt.py
Browse files- cv_prompt.py +38 -18
cv_prompt.py
CHANGED
@@ -4,6 +4,7 @@ from langchain_core.pydantic_v1 import BaseModel, Field
|
|
4 |
from langchain.output_parsers import PydanticOutputParser
|
5 |
from langchain_core.prompts import PromptTemplate
|
6 |
|
|
|
7 |
def load_json_file(filename):
|
8 |
try:
|
9 |
with open(filename, 'r', encoding='utf-8') as f:
|
@@ -51,6 +52,43 @@ class ResumeQualityEvaluation(BaseModel):
|
|
51 |
work_experience: WorkExperience = Field(description="Evaluation of the work experience section")
|
52 |
profile: Profile = Field(description="Evaluation of the profile section")
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
def get_personal_info_prompt(text):
|
55 |
return f"""<s>[INST]Extract the personal information from the following CV text. The text may be in any language. Respond with a JSON object in the format {{"name": "extracted name", "email": "extracted email", "phone": "extracted phone number", "location": "extracted location"}}. If you can't find any of the information, set the value to null.
|
56 |
|
@@ -82,25 +120,7 @@ CV text:
|
|
82 |
Respond with a JSON object with a key "present_sections" containing an array of the identified sections.
|
83 |
Only include sections that are actually present in the CV. [/INST]"""
|
84 |
|
85 |
-
def get_content_quality_prompt(text):
|
86 |
-
parser = PydanticOutputParser(pydantic_object=ResumeQualityEvaluation)
|
87 |
-
|
88 |
-
prompt = PromptTemplate(
|
89 |
-
template="""<s>[INST]Evaluate the quality of the following resume sections:
|
90 |
|
91 |
-
{resume}
|
92 |
-
|
93 |
-
Provide a detailed evaluation following this format:
|
94 |
-
{format_instructions}
|
95 |
-
|
96 |
-
For each section, evaluate the presence of required elements.
|
97 |
-
For the Work Experience section, also evaluate the quality of the Responsibilities and Achievements descriptions on a scale of 0-10.
|
98 |
-
Provide an overall score for each section on a scale of 0-10 based on the presence of elements and their quality where applicable.[/INST]""",
|
99 |
-
input_variables=["resume"],
|
100 |
-
partial_variables={"format_instructions": parser.get_format_instructions()}
|
101 |
-
)
|
102 |
-
|
103 |
-
return prompt.format(resume=text)
|
104 |
|
105 |
def calculate_section_detection_score(detected_sections):
|
106 |
total_score = 0
|
|
|
4 |
from langchain.output_parsers import PydanticOutputParser
|
5 |
from langchain_core.prompts import PromptTemplate
|
6 |
|
7 |
+
|
8 |
def load_json_file(filename):
|
9 |
try:
|
10 |
with open(filename, 'r', encoding='utf-8') as f:
|
|
|
52 |
work_experience: WorkExperience = Field(description="Evaluation of the work experience section")
|
53 |
profile: Profile = Field(description="Evaluation of the profile section")
|
54 |
|
55 |
+
def get_content_quality_prompt(text):
|
56 |
+
parser = PydanticOutputParser(pydantic_object=ResumeQualityEvaluation)
|
57 |
+
|
58 |
+
prompt = PromptTemplate(
|
59 |
+
template="""<s>[INST]Evaluate the quality of the following resume sections:
|
60 |
+
|
61 |
+
{resume}
|
62 |
+
|
63 |
+
Provide a detailed evaluation following this format:
|
64 |
+
{format_instructions}
|
65 |
+
|
66 |
+
For each section, evaluate the presence and quality of required elements:
|
67 |
+
|
68 |
+
1. Education:
|
69 |
+
- Check for the presence of Degree, Year, and Institution for each education entry
|
70 |
+
- Provide a score (0-10) for each education entry based on completeness and clarity
|
71 |
+
|
72 |
+
2. Work Experience:
|
73 |
+
- Check for the presence of Job title, Company, dates, used technologies, Responsibilities, and Achievements for each work experience entry
|
74 |
+
- Evaluate the quality of Responsibilities description (0-10)
|
75 |
+
- Evaluate the quality of Achievements description (0-10)
|
76 |
+
- Provide a score (0-10) for each work experience entry based on completeness, clarity, and the quality of descriptions
|
77 |
+
|
78 |
+
3. Profile:
|
79 |
+
- Check for the presence of a brief overview, career goals, and objective
|
80 |
+
- Provide an overall score (0-10) based on the completeness and clarity of the profile
|
81 |
+
|
82 |
+
Provide an overall score for each section on a scale of 0-10 based on the presence of elements and their quality where applicable.[/INST]""",
|
83 |
+
input_variables=["resume"],
|
84 |
+
partial_variables={"format_instructions": parser.get_format_instructions()}
|
85 |
+
)
|
86 |
+
|
87 |
+
return prompt.format(resume=text)
|
88 |
+
|
89 |
+
|
90 |
+
|
91 |
+
|
92 |
def get_personal_info_prompt(text):
|
93 |
return f"""<s>[INST]Extract the personal information from the following CV text. The text may be in any language. Respond with a JSON object in the format {{"name": "extracted name", "email": "extracted email", "phone": "extracted phone number", "location": "extracted location"}}. If you can't find any of the information, set the value to null.
|
94 |
|
|
|
120 |
Respond with a JSON object with a key "present_sections" containing an array of the identified sections.
|
121 |
Only include sections that are actually present in the CV. [/INST]"""
|
122 |
|
|
|
|
|
|
|
|
|
|
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
def calculate_section_detection_score(detected_sections):
|
126 |
total_score = 0
|