Spaces:
Sleeping
Sleeping
DreamStream-1
commited on
Commit
•
83dc51e
1
Parent(s):
66f7872
Update app.py
Browse files
app.py
CHANGED
@@ -51,8 +51,6 @@ def extract_skills_llama(text):
|
|
51 |
# --- Job Description Processing Function --- #
|
52 |
def process_job_description(text):
|
53 |
"""Extracts skills or relevant keywords from the job description."""
|
54 |
-
# You can customize this function as needed, for now, we'll use a basic extraction
|
55 |
-
# Using the Llama model or a simple regex-based approach for demonstration
|
56 |
return extract_skills_llama(text)
|
57 |
|
58 |
# --- Qualification and Experience Extraction --- #
|
@@ -91,33 +89,32 @@ def categorize_similarity(score):
|
|
91 |
return "Low Match"
|
92 |
|
93 |
# --- Communication Generation with Enhanced Response --- #
|
94 |
-
def communication_generator(resume_skills, job_description_skills, skills_similarity, qualifications_similarity, experience_similarity,
|
95 |
-
"""Generates a
|
96 |
-
model_name = "google/flan-t5-base"
|
97 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
98 |
-
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
99 |
-
|
100 |
# Assess candidate fit based on similarity scores
|
101 |
fit_status = "strong fit" if skills_similarity >= 80 and qualifications_similarity >= 80 and experience_similarity >= 80 else \
|
102 |
"moderate fit" if skills_similarity >= 50 else "weak fit"
|
103 |
|
104 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
message = (
|
106 |
f"After a detailed analysis of the candidate's resume, we found the following insights:\n\n"
|
107 |
-
f"- **Skills Match**: {skills_similarity:.2f}% ({
|
108 |
-
f"- **
|
109 |
-
f"- **
|
110 |
f"The overall assessment indicates that the candidate is a {fit_status} for the role. "
|
111 |
-
f"
|
112 |
-
f"
|
113 |
-
f"
|
114 |
-
f"but additional evaluation or interviews are recommended for further clarification."
|
115 |
)
|
116 |
|
117 |
-
|
118 |
-
response = model.generate(**inputs, max_length=max_length, num_beams=4, early_stopping=True)
|
119 |
-
|
120 |
-
return tokenizer.decode(response[0], skip_special_tokens=True)
|
121 |
|
122 |
# --- Sentiment Analysis --- #
|
123 |
def sentiment_analysis(text):
|
@@ -155,10 +152,14 @@ def analyze_resume(resume_file, job_description_file):
|
|
155 |
qualifications_similarity = calculate_semantic_similarity(' '.join(resume_qualifications), ' '.join(job_description_qualifications))
|
156 |
experience_similarity = calculate_semantic_similarity(' '.join([str(e) for e in resume_experience]), ' '.join([str(e) for e in job_description_experience]))
|
157 |
|
|
|
|
|
|
|
158 |
# Generate a communication response based on the similarity percentages
|
159 |
communication_response = communication_generator(
|
160 |
resume_skills, job_description_skills,
|
161 |
-
skills_similarity, qualifications_similarity, experience_similarity
|
|
|
162 |
)
|
163 |
|
164 |
# Perform Sentiment Analysis
|
@@ -175,34 +176,19 @@ def analyze_resume(resume_file, job_description_file):
|
|
175 |
f"Job Description Skills: {', '.join(job_description_skills)}",
|
176 |
f"Resume Qualifications: {', '.join(resume_qualifications)}",
|
177 |
f"Job Description Qualifications: {', '.join(job_description_qualifications)}",
|
178 |
-
f"
|
179 |
-
f"Job Description Experience: {', '.join([str(e) for e in job_description_experience])}"
|
180 |
)
|
181 |
|
182 |
# --- Gradio Interface --- #
|
183 |
-
|
184 |
-
"
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
gr.Textbox(label="Job Description Skills"),
|
196 |
-
gr.Textbox(label="Resume Qualifications"),
|
197 |
-
gr.Textbox(label="Job Description Qualifications"),
|
198 |
-
gr.Textbox(label="Resume Experience"),
|
199 |
-
gr.Textbox(label="Job Description Experience")
|
200 |
-
],
|
201 |
-
title="Resume and Job Description Analysis",
|
202 |
-
description="Analyze a resume against a job description to evaluate skills, qualifications, experience, and generate communication insights."
|
203 |
-
)
|
204 |
-
|
205 |
-
interface.launch()
|
206 |
-
|
207 |
-
if __name__ == "__main__":
|
208 |
-
main()
|
|
|
51 |
# --- Job Description Processing Function --- #
|
52 |
def process_job_description(text):
|
53 |
"""Extracts skills or relevant keywords from the job description."""
|
|
|
|
|
54 |
return extract_skills_llama(text)
|
55 |
|
56 |
# --- Qualification and Experience Extraction --- #
|
|
|
89 |
return "Low Match"
|
90 |
|
91 |
# --- Communication Generation with Enhanced Response --- #
|
92 |
+
def communication_generator(resume_skills, job_description_skills, skills_similarity, qualifications_similarity, experience_similarity, candidate_experience):
|
93 |
+
"""Generates a detailed communication response based on similarity scores and additional criteria."""
|
|
|
|
|
|
|
|
|
94 |
# Assess candidate fit based on similarity scores
|
95 |
fit_status = "strong fit" if skills_similarity >= 80 and qualifications_similarity >= 80 and experience_similarity >= 80 else \
|
96 |
"moderate fit" if skills_similarity >= 50 else "weak fit"
|
97 |
|
98 |
+
# Build a message that includes a recommendation based on various assessments
|
99 |
+
if fit_status == "strong fit":
|
100 |
+
recommendation = "We recommend moving forward with this candidate, as they demonstrate a high level of alignment with the role requirements."
|
101 |
+
elif fit_status == "moderate fit":
|
102 |
+
recommendation = "This candidate shows potential; however, further assessment or interviews are recommended to clarify their fit for the role."
|
103 |
+
else:
|
104 |
+
recommendation = "We advise against moving forward with this candidate, as they do not meet the key technical requirements for the position."
|
105 |
+
|
106 |
message = (
|
107 |
f"After a detailed analysis of the candidate's resume, we found the following insights:\n\n"
|
108 |
+
f"- **Skills Match**: {skills_similarity:.2f}% (based on required technologies: {', '.join(job_description_skills)})\n"
|
109 |
+
f"- **Experience Match**: {experience_similarity:.2f}% (relevant experience: {candidate_experience} years)\n"
|
110 |
+
f"- **Qualifications Match**: {qualifications_similarity:.2f}%\n\n"
|
111 |
f"The overall assessment indicates that the candidate is a {fit_status} for the role. "
|
112 |
+
f"Their skills in {', '.join(resume_skills)} align with the job's requirements of {', '.join(job_description_skills)}. "
|
113 |
+
f"Based on their experience in web application development, particularly with technologies like {', '.join(resume_skills)}, they could contribute effectively to our team.\n\n"
|
114 |
+
f"**Recommendation**: {recommendation}\n"
|
|
|
115 |
)
|
116 |
|
117 |
+
return message
|
|
|
|
|
|
|
118 |
|
119 |
# --- Sentiment Analysis --- #
|
120 |
def sentiment_analysis(text):
|
|
|
152 |
qualifications_similarity = calculate_semantic_similarity(' '.join(resume_qualifications), ' '.join(job_description_qualifications))
|
153 |
experience_similarity = calculate_semantic_similarity(' '.join([str(e) for e in resume_experience]), ' '.join([str(e) for e in job_description_experience]))
|
154 |
|
155 |
+
# Assuming candidate experience is extracted from the resume
|
156 |
+
candidate_experience = sum(resume_experience) # Calculate total experience based on extracted years
|
157 |
+
|
158 |
# Generate a communication response based on the similarity percentages
|
159 |
communication_response = communication_generator(
|
160 |
resume_skills, job_description_skills,
|
161 |
+
skills_similarity, qualifications_similarity, experience_similarity,
|
162 |
+
candidate_experience
|
163 |
)
|
164 |
|
165 |
# Perform Sentiment Analysis
|
|
|
176 |
f"Job Description Skills: {', '.join(job_description_skills)}",
|
177 |
f"Resume Qualifications: {', '.join(resume_qualifications)}",
|
178 |
f"Job Description Qualifications: {', '.join(job_description_qualifications)}",
|
179 |
+
f"Candidate Experience: {candidate_experience} years"
|
|
|
180 |
)
|
181 |
|
182 |
# --- Gradio Interface --- #
|
183 |
+
with gr.Blocks() as demo:
|
184 |
+
gr.Markdown("## Resume and Job Description Analyzer")
|
185 |
+
with gr.Row():
|
186 |
+
resume_file_input = gr.File(label="Upload Resume (PDF/TXT)", type="file")
|
187 |
+
job_description_file_input = gr.File(label="Upload Job Description (PDF/TXT)", type="file")
|
188 |
+
analyze_button = gr.Button("Analyze")
|
189 |
+
results_output = gr.Output()
|
190 |
+
|
191 |
+
analyze_button.click(analyze_resume, inputs=[resume_file_input, job_description_file_input], outputs=results_output)
|
192 |
+
|
193 |
+
# Launch Gradio Interface
|
194 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|