Chapter 7
Training & Fine-Tuning Embeddings
Move beyond zero-shot embeddings. This chapter covers when to train, how to build training data from user behavior, which fine-tuning strategies work at scale, how to measure quality, and how to deploy without breaking production.
In This Chapter
7.1 Why Train Your Own
When off-the-shelf models plateau and domain shift justifies the cost of custom training.
7.2 Training Data: Click Pairs
Mining high-quality training signals from user behavior, session awareness, and hard negatives.
7.3 Contrastive Learning
InfoNCE loss, cosine similarity, batch size leveraging, and why bi-encoders dominate retrieval.
7.4 Fine-Tuning Strategies
Full training vs LoRA vs Matryoshka vs distillation—choose based on budget and constraints.
7.5 Evaluation Metrics
nDCG, Recall, MRR, slice-based evaluation, and why offline metrics gate experiments.
7.6 Production Deployment
Blue-green rollouts, backfills, consistency, quantization, and the vector mismatch trap.