Spaces:
Sleeping
Sleeping
File size: 474 Bytes
0309068 |
1 2 3 4 5 6 7 8 9 10 |
from sentence_transformers import SentenceTransformer, util
_model = SentenceTransformer("all-MiniLM-L6-v2") # 22 M params, semantic embeddings :contentReference[oaicite:8]{index=8}
def score_fit(text: str, goal: str) -> int:
emb1 = _model.encode(text, convert_to_tensor=True)
emb2 = _model.encode(goal, convert_to_tensor=True)
cos = util.cos_sim(emb1, emb2).item() # –1…1
return max(0, min(100, int((cos + 1) * 50))) # map to 0–100
|