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