Spaces:
Paused
Paused
Commit ·
1ead253
1
Parent(s): 0e43f07
updated
Browse files
backend/services/resume_parser.py
CHANGED
|
@@ -90,16 +90,42 @@ def extract_name(text: str, filename: str) -> str:
|
|
| 90 |
# ===============================
|
| 91 |
def parse_with_deepseek(text: str) -> dict:
|
| 92 |
"""Use Deepseek-Coder-V2-Lite-Instruct to extract resume details in JSON format."""
|
| 93 |
-
|
| 94 |
prompt = f"""
|
| 95 |
Extract the following information from the resume text provided below. Your response should be a valid JSON object.
|
| 96 |
|
| 97 |
-
|
| 98 |
-
-
|
| 99 |
-
-
|
| 100 |
-
-
|
| 101 |
-
-
|
| 102 |
-
-
|
| 103 |
-
-
|
| 104 |
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
# ===============================
|
| 91 |
def parse_with_deepseek(text: str) -> dict:
|
| 92 |
"""Use Deepseek-Coder-V2-Lite-Instruct to extract resume details in JSON format."""
|
| 93 |
+
|
| 94 |
prompt = f"""
|
| 95 |
Extract the following information from the resume text provided below. Your response should be a valid JSON object.
|
| 96 |
|
| 97 |
+
Information to extract:
|
| 98 |
+
- Full Name: The candidate's full name.
|
| 99 |
+
- Email: The candidate's email address.
|
| 100 |
+
- Phone: The candidate's phone number.
|
| 101 |
+
- Skills: A list of technical and soft skills.
|
| 102 |
+
- Education: A list of academic degrees and institutions.
|
| 103 |
+
- Experience: A list of previous jobs, including company, title, and dates.
|
| 104 |
|
| 105 |
+
Resume Text:
|
| 106 |
+
{text}
|
| 107 |
+
|
| 108 |
+
Return only valid JSON in the following format:
|
| 109 |
+
{{
|
| 110 |
+
"name": "Full Name",
|
| 111 |
+
"email": "email@example.com",
|
| 112 |
+
"phone": "+961-xxx-xxx",
|
| 113 |
+
"skills": ["Skill1", "Skill2", "Skill3"],
|
| 114 |
+
"education": ["Degree1 - Institution1", "Degree2 - Institution2"],
|
| 115 |
+
"experience": ["Job1 - Company1 (Dates)", "Job2 - Company2 (Dates)"]
|
| 116 |
+
}}
|
| 117 |
+
"""
|
| 118 |
+
|
| 119 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 120 |
+
outputs = model.generate(**inputs, max_new_tokens=512)
|
| 121 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 122 |
+
|
| 123 |
+
import re, json
|
| 124 |
+
match = re.search(r"\{.*\}", response, re.S)
|
| 125 |
+
if match:
|
| 126 |
+
try:
|
| 127 |
+
return json.loads(match.group())
|
| 128 |
+
except:
|
| 129 |
+
pass
|
| 130 |
+
|
| 131 |
+
return {"name": "", "email": "", "phone": "", "skills": [], "education": [], "experience": []}
|