Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -61,15 +61,18 @@ def compare():
|
|
61 |
employee_embeddings = model.encode(employee_skills)
|
62 |
|
63 |
# Computing cosine similarity between employee skills and each job
|
64 |
-
|
65 |
-
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
71 |
|
72 |
-
return jsonify(similarity_scores)
|
73 |
|
74 |
|
75 |
if __name__ == '__main__':
|
|
|
61 |
employee_embeddings = model.encode(employee_skills)
|
62 |
|
63 |
# Computing cosine similarity between employee skills and each job
|
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 |
+
|
71 |
+
# Append all similarity scores for each job
|
72 |
+
similarity_scores.append({"job": jobs_skills[i], "similarity_scores": similarity_score.tolist()})
|
73 |
+
|
74 |
+
return jsonify(similarity_scores)
|
75 |
|
|
|
76 |
|
77 |
|
78 |
if __name__ == '__main__':
|