Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -19,21 +19,38 @@ llm = LlamaCpp(
|
|
19 |
verbose=True,
|
20 |
n_ctx=4096
|
21 |
)
|
|
|
|
|
22 |
model = SentenceTransformer('sentence-transformers/paraphrase-TinyBERT-L6-v2')
|
23 |
|
24 |
file_size = os.stat('Phi-3-mini-4k-instruct-q4.gguf')
|
25 |
print("model size ====> :", file_size.st_size, "bytes")
|
26 |
|
27 |
|
|
|
|
|
|
|
28 |
|
29 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
@app.route('/compare', methods=['POST'])
|
32 |
@app.route('/compare', methods=['POST'])
|
33 |
def compare():
|
34 |
-
employee_skills = request.json.get('jobs_skills')
|
35 |
-
jobs_skills = request.json.get('employee_skills')
|
36 |
|
|
|
37 |
|
38 |
# Validation
|
39 |
if not isinstance(jobs_skills, list) or not all(isinstance(skill, str) for skill in jobs_skills):
|
@@ -49,9 +66,11 @@ def compare():
|
|
49 |
|
50 |
for i, job_e in enumerate(job_embeddings):
|
51 |
job_e_tensor = torch.from_numpy(job_e).unsqueeze(0)
|
52 |
-
similarity_score = cosine_similarity(employee_embeddings_tensor, job_e_tensor, dim=1)
|
53 |
similarity_scores.append({"job": jobs_skills[i], "similarity_score": similarity_score.item()})
|
54 |
|
55 |
return jsonify(similarity_scores)
|
|
|
|
|
56 |
if __name__ == '__main__':
|
57 |
-
app.run()
|
|
|
19 |
verbose=True,
|
20 |
n_ctx=4096
|
21 |
)
|
22 |
+
model0 = AutoModel.from_pretrained('sentence-transformers/paraphrase-TinyBERT-L6-v2')
|
23 |
+
|
24 |
model = SentenceTransformer('sentence-transformers/paraphrase-TinyBERT-L6-v2')
|
25 |
|
26 |
file_size = os.stat('Phi-3-mini-4k-instruct-q4.gguf')
|
27 |
print("model size ====> :", file_size.st_size, "bytes")
|
28 |
|
29 |
|
30 |
+
@app.route('/cv', methods=['POST'])
|
31 |
+
def get_skills():
|
32 |
+
cv_body = request.json.get('cv_body')
|
33 |
|
34 |
+
# Simple inference example
|
35 |
+
output = llm(
|
36 |
+
f"<|user|>\n{cv_body}<|end|>\n<|assistant|>Can you list the skills mentioned in the CV?<|end|>",
|
37 |
+
max_tokens=256, # Generate up to 256 tokens
|
38 |
+
stop=["<|end|>"],
|
39 |
+
echo=True, # Whether to echo the prompt
|
40 |
+
)
|
41 |
+
|
42 |
+
return jsonify({'skills': output})
|
43 |
+
|
44 |
+
@app.get('/')
|
45 |
+
def health():
|
46 |
+
return jsonify({'status': 'Worked'})
|
47 |
|
|
|
48 |
@app.route('/compare', methods=['POST'])
|
49 |
def compare():
|
50 |
+
employee_skills = request.json.get('jobs_skills')
|
51 |
+
jobs_skills = request.json.get('employee_skills')
|
52 |
|
53 |
+
|
54 |
|
55 |
# Validation
|
56 |
if not isinstance(jobs_skills, list) or not all(isinstance(skill, str) for skill in jobs_skills):
|
|
|
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()
|