Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -50,23 +50,27 @@ def health():
|
|
50 |
# we will make here post request to compare between lists of skills one has employee just one text and the other has the of jobs has many texts
|
51 |
# the llm will say the most similar job to the cv
|
52 |
@app.route('/compare', methods=['POST'])
|
|
|
53 |
def compare():
|
54 |
-
employee_skills = request.json.get('employee_skills')
|
55 |
-
#example: employee_skills = "<|assistant|> Certainly! Based on the provided information, here are the relevant skills listed in my CV:\n\n1. Python programming language proficiency\n2. Java development expertise\n3. Web development experience (including front-end and back-end technologies)\n4. Proficient with machine learning algorithms and frameworks\n5. Strong problem-solving abilities\n6. Excellent communication skills, both written and verbal\n7. Agile methodology adherence\n8. Familiarity with version control systems (e.g., Git)\n9. Experience in designing scalable software architectures\n10. Proficient in testing methodologies such as unit tests, integration tests, and end-to-end tests\n11. Continuous learning mindset to stay updated on the latest technological advancements\n12. Strong collaboration skills for effective teamwork\n\nThese skills enable me to contribute significantly to an employer's objectives by developing innovative features that leverage cutting-edge technology, optimizing software performance through efficient coding practices and algorithmic improvements, enhancing code quality with rigorous testing methodologies, and fostering a collaborative work environment""
|
56 |
jobs_skills = request.json.get('jobs_skills')
|
57 |
-
|
58 |
if not isinstance(jobs_skills, list) or not all(isinstance(skill, str) for skill in jobs_skills):
|
59 |
raise ValueError("jobs_skills must be a list of strings")
|
|
|
60 |
job_embeddings = model.encode(jobs_skills)
|
61 |
employee_embeddings = model.encode(employee_skills)
|
62 |
-
|
|
|
63 |
employee_embeddings_tensor = torch.from_numpy(employee_embeddings).unsqueeze(0)
|
64 |
-
|
|
|
65 |
job_e_tensor = torch.from_numpy(job_e).unsqueeze(0)
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
return jsonify(
|
|
|
70 |
|
71 |
if __name__ == '__main__':
|
72 |
app.run()
|
|
|
50 |
# we will make here post request to compare between lists of skills one has employee just one text and the other has the of jobs has many texts
|
51 |
# the llm will say the most similar job to the cv
|
52 |
@app.route('/compare', methods=['POST'])
|
53 |
+
@app.route('/compare', methods=['POST'])
|
54 |
def compare():
|
55 |
+
employee_skills = request.json.get('employee_skills')
|
|
|
56 |
jobs_skills = request.json.get('jobs_skills')
|
57 |
+
|
58 |
if not isinstance(jobs_skills, list) or not all(isinstance(skill, str) for skill in jobs_skills):
|
59 |
raise ValueError("jobs_skills must be a list of strings")
|
60 |
+
|
61 |
job_embeddings = model.encode(jobs_skills)
|
62 |
employee_embeddings = model.encode(employee_skills)
|
63 |
+
|
64 |
+
similarity_scores = []
|
65 |
employee_embeddings_tensor = torch.from_numpy(employee_embeddings).unsqueeze(0)
|
66 |
+
|
67 |
+
for i, job_e in enumerate(job_embeddings):
|
68 |
job_e_tensor = torch.from_numpy(job_e).unsqueeze(0)
|
69 |
+
similarity_score = cosine_similarity(employee_embeddings_tensor, job_e_tensor, dim=1)
|
70 |
+
similarity_scores.append({"job": jobs_skills[i], "similarity_score": similarity_score.item()})
|
71 |
+
|
72 |
+
return jsonify(similarity_scores)
|
73 |
+
|
74 |
|
75 |
if __name__ == '__main__':
|
76 |
app.run()
|