Careeroza
Real World Example
Finding Duplicate Questions
Q&A platforms (Stack Overflow, Quora) and support desks like Freshdesk use embeddings to detect that a new question was already answered. ShopEase suggests existing FAQ answers as the customer types:
import numpy as np, voyageai
vo = voyageai.Client()
faqs = load_faqs() # [{"q": ..., "a": ...}, ...]
faq_vecs = np.array(vo.embed([f["q"] for f in faqs], model="voyage-3.5", input_type="document").embeddings)
def suggest(user_text, threshold=0.75):
q = np.array(vo.embed([user_text], model="voyage-3.5", input_type="query").embeddings[0])
scores = faq_vecs @ q # Voyage vectors are normalized
best = int(scores.argmax())
return faqs[best] if scores[best] >= threshold else None
print(suggest("paisa wapas kab aayega"))Run it
python suggest.pyExample output
{'q': 'When will I get my refund?', 'a': 'Refunds reach your account in 5-7 working days after pickup.'}Choosing the Threshold
Example
The threshold decides when a match is "good enough". Teams pick it from labelled examples: score known duplicate and non-duplicate pairs and look at where they separate (the scores below are sample values):
pairs = [ # (similarity score from the embedding model, is it really a duplicate?)
(0.91, True), (0.84, True), (0.79, True), (0.77, False), (0.72, True),
(0.69, False), (0.61, False), (0.55, False), (0.48, False),
]
for threshold in (0.6, 0.7, 0.75, 0.8):
tp = sum(1 for s, dup in pairs if s >= threshold and dup)
fp = sum(1 for s, dup in pairs if s >= threshold and not dup)
fn = sum(1 for s, dup in pairs if s < threshold and dup)
precision = tp / (tp + fp) if tp + fp else 0
recall = tp / (tp + fn) if tp + fn else 0
print(f"threshold {threshold:.2f}: precision {precision:.2f} recall {recall:.2f}")Output
threshold 0.60: precision 0.57 recall 1.00 threshold 0.70: precision 0.80 recall 1.00 threshold 0.75: precision 0.75 recall 0.75 threshold 0.80: precision 1.00 recall 0.50
Higher threshold = fewer wrong suggestions (precision up) but more missed duplicates (recall down). For FAQ suggestions a wrong suggestion is cheap, so a lower threshold is fine; for auto-closing tickets you would choose a high one.