# Revision: Cheat Sheet and Self-Check — Embeddings & Vector Search

Source: https://www.geekswithgeeks.com/en/embeddings/z-revision

> Review the key ideas of the whole course.

## Cheat sheet

**Idea**: an embedding is a learned vector; similar meaning means nearby vectors; each model has its own space (never mix models). **Similarity**: dot grows with length and angle, cosine is direction only, L2 is distance; for unit vectors cosine = dot and L2 gives the same ranking, so normalise. **Dimensions**: more is not automatically better; storage = vectors × dims × bytes; random data concentrates distances. **Creating**: learned from context (LSA, word2vec) and contrastive training of transformers; choose by languages, domain, max length, dims, cost, licence and your own recall; chunk well, respect max length, use query/document prefixes when required. **Search**: exact kNN first (ground truth); IVF (nprobe) and HNSW (efSearch) trade recall for speed; scalar and product quantisation trade accuracy for memory. **Beyond**: metadata filters inside the query, hybrid BM25 + vector with RRF, cross-encoder reranking, clustering, near-duplicate thresholds, multilingual and multimodal models. **Quality**: golden set with recall@k, MRR, nDCG; error analysis by cause; re-index with a parallel index on model change. **Production**: library vs database extension vs dedicated engine; incremental updates and deletes; memory arithmetic and p95/p99; vectors as sensitive as source; permissions in the query.

**Quiz:** A user searches for "time off work" but the policy says "annual leave". Which approach most directly fixes this?

- [ ] Exact string matching only
- [x] Embedding (semantic) search, ideally combined with keyword search
- [ ] Increasing nprobe
- [ ] Using int8 vectors

*Answer:* Embedding (semantic) search, ideally combined with keyword search. Semantic embeddings bridge vocabulary mismatch; keyword search still covers exact terms.

**Quiz:** You upgrade the embedding model and only re-embed new documents, leaving the old vectors. What goes wrong?

- [ ] Nothing, vectors are interchangeable
- [x] Old and new vectors live in different spaces, so comparisons become meaningless
- [ ] The index becomes smaller
- [ ] Only latency changes

*Answer:* Old and new vectors live in different spaces, so comparisons become meaningless. Re-embed everything into a new index when the model changes.

**Quiz:** Your HNSW index has recall@10 of 0.93 against exact search. What is a sensible next step?

- [ ] Switch to a smaller model without testing
- [ ] Declare it perfect
- [ ] Delete the index
- [x] Raise efSearch (or index parameters) and re-measure against the target recall and latency

*Answer:* Raise efSearch (or index parameters) and re-measure against the target recall and latency. Recall and latency trade off; tune until the target is met at acceptable cost.
