Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -66,7 +66,7 @@ def load_models():
|
|
66 |
# Use pipeline if available
|
67 |
models['evaluator'] = pipeline(
|
68 |
"sentiment-analysis",
|
69 |
-
model="
|
70 |
)
|
71 |
else:
|
72 |
# Fall back to basic model loading
|
@@ -210,11 +210,7 @@ def evaluate_job_fit(resume_summary, job_requirements, models):
|
|
210 |
analysis_prompt = analysis_prompt[:max_prompt_length]
|
211 |
|
212 |
# Use sentiment analysis model for evaluation
|
213 |
-
# This is a smart use of a simple model - we're phrasing our prompt
|
214 |
-
# so that a positive sentiment = good match, negative sentiment = poor match
|
215 |
-
|
216 |
fit_score = 0 # Default score
|
217 |
-
fit_assessment = ""
|
218 |
|
219 |
# Run multiple sub-analyses to build confidence in our result
|
220 |
sub_analyses = []
|
@@ -224,10 +220,10 @@ def evaluate_job_fit(resume_summary, job_requirements, models):
|
|
224 |
if has_pipeline and 'evaluator' in models:
|
225 |
result = models['evaluator'](prompt_text)
|
226 |
# Convert sentiment to score
|
227 |
-
if result[0]['label'] == 'POSITIVE' and result[0]['score'] > 0.
|
228 |
return 2 # Strong positive = good fit
|
229 |
-
elif result[0]['label'] == '
|
230 |
-
return 1 #
|
231 |
else:
|
232 |
return 0 # Negative = not fit
|
233 |
else:
|
@@ -247,7 +243,7 @@ def evaluate_job_fit(resume_summary, job_requirements, models):
|
|
247 |
positive_prob = probabilities[0][1].item() # Positive class probability
|
248 |
|
249 |
# Convert probability to score
|
250 |
-
if positive_prob > 0.
|
251 |
return 2
|
252 |
elif positive_prob > 0.6:
|
253 |
return 1
|
@@ -297,19 +293,30 @@ def evaluate_job_fit(resume_summary, job_requirements, models):
|
|
297 |
else:
|
298 |
fit_score = 0
|
299 |
|
300 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
resume_lower = resume_summary.lower()
|
302 |
matching_skills = [skill for skill in required_skills if skill.lower() in resume_lower]
|
303 |
missing_skills = [skill for skill in required_skills if skill.lower() not in resume_lower]
|
304 |
-
skills_match_percentage = int(len(matching_skills) / max(1, len(required_skills)) * 100)
|
305 |
|
306 |
-
# Generate assessment text based on score
|
307 |
if fit_score == 2:
|
308 |
-
fit_assessment = f"{fit_score}:
|
309 |
elif fit_score == 1:
|
310 |
-
fit_assessment = f"{fit_score}:
|
311 |
else:
|
312 |
-
|
|
|
313 |
|
314 |
execution_time = time.time() - start_time
|
315 |
|
|
|
66 |
# Use pipeline if available
|
67 |
models['evaluator'] = pipeline(
|
68 |
"sentiment-analysis",
|
69 |
+
model="lxyuan/distilbert-base-multilingual-cased-sentiments-student"
|
70 |
)
|
71 |
else:
|
72 |
# Fall back to basic model loading
|
|
|
210 |
analysis_prompt = analysis_prompt[:max_prompt_length]
|
211 |
|
212 |
# Use sentiment analysis model for evaluation
|
|
|
|
|
|
|
213 |
fit_score = 0 # Default score
|
|
|
214 |
|
215 |
# Run multiple sub-analyses to build confidence in our result
|
216 |
sub_analyses = []
|
|
|
220 |
if has_pipeline and 'evaluator' in models:
|
221 |
result = models['evaluator'](prompt_text)
|
222 |
# Convert sentiment to score
|
223 |
+
if result[0]['label'] == 'POSITIVE' and result[0]['score'] > 0.8:
|
224 |
return 2 # Strong positive = good fit
|
225 |
+
elif result[0]['label'] == 'NEUTRAL':
|
226 |
+
return 1 # neutral fit = potential fit
|
227 |
else:
|
228 |
return 0 # Negative = not fit
|
229 |
else:
|
|
|
243 |
positive_prob = probabilities[0][1].item() # Positive class probability
|
244 |
|
245 |
# Convert probability to score
|
246 |
+
if positive_prob > 0.8:
|
247 |
return 2
|
248 |
elif positive_prob > 0.6:
|
249 |
return 1
|
|
|
293 |
else:
|
294 |
fit_score = 0
|
295 |
|
296 |
+
# Extract key information from resume for assessment
|
297 |
+
# Parse name, age, industry from resume summary
|
298 |
+
name_match = re.search(r'Name:\s*(.*?)(?=\n|\Z)', resume_summary)
|
299 |
+
name = name_match.group(1).strip() if name_match else "The candidate"
|
300 |
+
|
301 |
+
age_match = re.search(r'Age:\s*(.*?)(?=\n|\Z)', resume_summary)
|
302 |
+
age = age_match.group(1).strip() if age_match else "unspecified age"
|
303 |
+
|
304 |
+
industry_match = re.search(r'Expected Industry:\s*(.*?)(?=\n|\Z)', resume_summary)
|
305 |
+
industry = industry_match.group(1).strip() if industry_match else "unspecified industry"
|
306 |
+
|
307 |
+
# Count matching skills but don't show the percentage in output
|
308 |
resume_lower = resume_summary.lower()
|
309 |
matching_skills = [skill for skill in required_skills if skill.lower() in resume_lower]
|
310 |
missing_skills = [skill for skill in required_skills if skill.lower() not in resume_lower]
|
|
|
311 |
|
312 |
+
# Generate assessment text based on score with more holistic evaluation
|
313 |
if fit_score == 2:
|
314 |
+
fit_assessment = f"{fit_score}: {name} demonstrates strong alignment with the {job_title} position. Their background in {industry} and professional experience appear well-suited for this role's requirements. The technical expertise matches what the position demands."
|
315 |
elif fit_score == 1:
|
316 |
+
fit_assessment = f"{fit_score}: {name} shows potential for the {job_title} role with some relevant experience, though there are gaps in certain technical areas. Their {industry} background provides partial alignment with the position requirements. Additional training might be needed in {', '.join(missing_skills[:2])} if pursuing this opportunity."
|
317 |
else:
|
318 |
+
# For score 0, be constructive but honest
|
319 |
+
fit_assessment = f"{fit_score}: {name}'s current background shows limited alignment with this {job_title} position. Their experience level and technical background differ significantly from the role requirements. A position better matching their {industry} expertise might be more suitable."
|
320 |
|
321 |
execution_time = time.time() - start_time
|
322 |
|