Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
51 small wins to finish your pathNext question →

Q42HardConcept

When and how would you fine-tune an embedding model or reranker for your domain?

30-second answerSay your answer out loud first, then reveal.

Training data

  1. Positive pairs: (query, relevant chunk) from search logs or clicks, support tickets with linked KB articles, expert labels, or synthetic questions generated per chunk by an LLM (cheap and effective).
  2. Hard negatives: passages that look similar but aren't relevant (e.g. retrieved by BM25 or the base model but not correct). They teach fine distinctions, and they matter more than the dataset's size.

Training

  • Contrastive loss, such as MultipleNegativesRankingLoss with in-batch negatives (Sentence-Transformers).
  • Rerankers: train a cross-encoder on (query, passage, label) with hard negatives.
  • Start from a strong base model; a few thousand quality pairs can give meaningful gains.

Evaluation

  • Held-out queries (no overlap with training docs if possible).
  • Recall@k, nDCG before and after; also check that general queries didn't regress.

Reranker vs embedder fine-tuning

Fine-tune rerankerFine-tune embedder
Re-indexing neededNoYes (all vectors)
ImpactTop-of-list precisionRecall of the first stage
RiskLowIndex migration effort

Good order: fine-tune the reranker first (no re-index), and the embedder if first-stage recall is the bottleneck.

You understood something today that you didn't yesterday.