File size: 898 Bytes
efdbca3
 
 
 
 
 
 
 
 
 
 
 
e526ebd
efdbca3
 
 
 
 
4c824d1
efdbca3
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Requires transformers>=4.51.0
import torch
from sentence_transformers import SentenceTransformer

model = SentenceTransformer("Qwen/Qwen3-Embedding-0.6B")

# queries = "hey"
# documents = [
#     "The capital of China is Beijing.",
#     "Gravity is a force that attracts two bodies towards each other. It gives weight to physical objects and is responsible for the movement of planets around the sun.",
# ]

def rank_jobs(job_description, resumes):
    task = "Given a resume, retrieve relevant job description that is suitable for the resume"

    queries = resumes
    documents = job_description

    print("[QUERIES]", queries)
    print("[DOCUMENTS]", documents)

    query_embeddings = model.encode(queries, prompt=task)
    document_embeddings = model.encode(documents)
    similarity = model.similarity(query_embeddings, document_embeddings)

    return documents, similarity[0].tolist()