Spaces:
Sleeping
Sleeping
Update resume_prompt.py
Browse files- resume_prompt.py +76 -71
resume_prompt.py
CHANGED
|
@@ -1,72 +1,77 @@
|
|
| 1 |
-
def analyze_resume(resume_text,pipe):
|
| 2 |
-
# resume_text = truncate_text(resume_text) # Ensure Resume fits within token limit
|
| 3 |
-
# modularize resume into personal_information, summary,skills, experience, education, certifications, projects, total_experience, primary_job_function and additional information
|
| 4 |
-
|
| 5 |
-
prompt = f"""
|
| 6 |
-
|
| 7 |
-
Respond **ONLY** with a valid JSON object. **Do NOT include any extra text, explanations, or notes.** The JSON should follow this exact structure:
|
| 8 |
-
|
| 9 |
-
{{
|
| 10 |
-
"personal_info": {{
|
| 11 |
-
"name": "",
|
| 12 |
-
"email": "",
|
| 13 |
-
"phone": "",
|
| 14 |
-
"location": "",
|
| 15 |
-
"state": "",
|
| 16 |
-
"country": "",
|
| 17 |
-
"linkedin": ""
|
| 18 |
-
}},
|
| 19 |
-
"summary": "",
|
| 20 |
-
"skills": {{"technical_skills": [], "soft_skills": [], "languages": []}},
|
| 21 |
-
"experience": [
|
| 22 |
-
{{
|
| 23 |
-
"company": "",
|
| 24 |
-
"job_title": "",
|
| 25 |
-
"duration": "",
|
| 26 |
-
"responsibilities": []
|
| 27 |
-
}}
|
| 28 |
-
],
|
| 29 |
-
"education": [
|
| 30 |
-
{{
|
| 31 |
-
"degree": "",
|
| 32 |
-
"institution": "",
|
| 33 |
-
"graduation_date": ""
|
| 34 |
-
}}
|
| 35 |
-
],
|
| 36 |
-
"certifications": [],
|
| 37 |
-
"projects": [
|
| 38 |
-
{{
|
| 39 |
-
"name": "",
|
| 40 |
-
"description": "",
|
| 41 |
-
"technologies": []
|
| 42 |
-
}}
|
| 43 |
-
],
|
| 44 |
-
"keywords": [],
|
| 45 |
-
"additional_information": "",
|
| 46 |
-
"total_experience": 0,
|
| 47 |
-
"primary_job_function": "",
|
| 48 |
-
"parsing_issues": []
|
| 49 |
-
}}
|
| 50 |
-
Resume:
|
| 51 |
-
{resume_text}
|
| 52 |
-
|
| 53 |
-
Instructions:
|
| 54 |
-
• Return only JSON. No extra text or explanations.
|
| 55 |
-
• If data is missing, use "Not provided" instead of guessing.
|
| 56 |
-
• Ensure correct JSON format.
|
| 57 |
-
Guidelines:
|
| 58 |
-
1. Fill in relevant details from the resume. Use "Not provided" for missing fields.
|
| 59 |
-
2. Extract location, state, and country (infer from city if needed).
|
| 60 |
-
3. Categorize skills properly (e.g., technical vs. soft skills).
|
| 61 |
-
4. List experiences in reverse order (most recent first).
|
| 62 |
-
5. Include all job experiences, even without responsibilities.
|
| 63 |
-
6. Summarize job responsibilities (4-5 key points per job).
|
| 64 |
-
7. Extract all relevant keywords (skills, tools, methodologies).
|
| 65 |
-
8. Calculate total experience (round to the nearest half-year).
|
| 66 |
-
9. Identify the primary job function based on role and skills.
|
| 67 |
-
10. Log unclear sections in "parsing_issues".
|
| 68 |
-
"""
|
| 69 |
-
response = pipe(prompt,max_new_tokens=5000, do_sample=True, temperature=0.7)
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
# return prompt
|
|
|
|
| 1 |
+
def analyze_resume(resume_text,pipe):
|
| 2 |
+
# resume_text = truncate_text(resume_text) # Ensure Resume fits within token limit
|
| 3 |
+
# modularize resume into personal_information, summary,skills, experience, education, certifications, projects, total_experience, primary_job_function and additional information
|
| 4 |
+
|
| 5 |
+
prompt = f"""
|
| 6 |
+
|
| 7 |
+
Respond **ONLY** with a valid JSON object. **Do NOT include any extra text, explanations, or notes.** The JSON should follow this exact structure:
|
| 8 |
+
|
| 9 |
+
{{
|
| 10 |
+
"personal_info": {{
|
| 11 |
+
"name": "",
|
| 12 |
+
"email": "",
|
| 13 |
+
"phone": "",
|
| 14 |
+
"location": "",
|
| 15 |
+
"state": "",
|
| 16 |
+
"country": "",
|
| 17 |
+
"linkedin": ""
|
| 18 |
+
}},
|
| 19 |
+
"summary": "",
|
| 20 |
+
"skills": {{"technical_skills": [], "soft_skills": [], "languages": []}},
|
| 21 |
+
"experience": [
|
| 22 |
+
{{
|
| 23 |
+
"company": "",
|
| 24 |
+
"job_title": "",
|
| 25 |
+
"duration": "",
|
| 26 |
+
"responsibilities": []
|
| 27 |
+
}}
|
| 28 |
+
],
|
| 29 |
+
"education": [
|
| 30 |
+
{{
|
| 31 |
+
"degree": "",
|
| 32 |
+
"institution": "",
|
| 33 |
+
"graduation_date": ""
|
| 34 |
+
}}
|
| 35 |
+
],
|
| 36 |
+
"certifications": [],
|
| 37 |
+
"projects": [
|
| 38 |
+
{{
|
| 39 |
+
"name": "",
|
| 40 |
+
"description": "",
|
| 41 |
+
"technologies": []
|
| 42 |
+
}}
|
| 43 |
+
],
|
| 44 |
+
"keywords": [],
|
| 45 |
+
"additional_information": "",
|
| 46 |
+
"total_experience": 0,
|
| 47 |
+
"primary_job_function": "",
|
| 48 |
+
"parsing_issues": []
|
| 49 |
+
}}
|
| 50 |
+
Resume:
|
| 51 |
+
{resume_text}
|
| 52 |
+
|
| 53 |
+
Instructions:
|
| 54 |
+
• Return only JSON. No extra text or explanations.
|
| 55 |
+
• If data is missing, use "Not provided" instead of guessing.
|
| 56 |
+
• Ensure correct JSON format.
|
| 57 |
+
Guidelines:
|
| 58 |
+
1. Fill in relevant details from the resume. Use "Not provided" for missing fields.
|
| 59 |
+
2. Extract location, state, and country (infer from city if needed).
|
| 60 |
+
3. Categorize skills properly (e.g., technical vs. soft skills).
|
| 61 |
+
4. List experiences in reverse order (most recent first).
|
| 62 |
+
5. Include all job experiences, even without responsibilities.
|
| 63 |
+
6. Summarize job responsibilities (4-5 key points per job).
|
| 64 |
+
7. Extract all relevant keywords (skills, tools, methodologies).
|
| 65 |
+
8. Calculate total experience (round to the nearest half-year).
|
| 66 |
+
9. Identify the primary job function based on role and skills.
|
| 67 |
+
10. Log unclear sections in "parsing_issues".
|
| 68 |
+
"""
|
| 69 |
+
# response = pipe(prompt,max_new_tokens=5000, do_sample=True, temperature=0.7)
|
| 70 |
+
|
| 71 |
+
messages = [
|
| 72 |
+
{"role": "system", "content": "You are an expert resume analyzer capable of understanding various resume formats and extracting relevant information accurately."},
|
| 73 |
+
{"role": "user", "content": prompt},
|
| 74 |
+
]
|
| 75 |
+
response=pipe(messages,max_new_tokens=5000, do_sample=True, temperature=0.7)
|
| 76 |
+
return response, prompt
|
| 77 |
# return prompt
|