| The mental model | ||
|---|---|---|
| vector | One point in a high-dimensional space; typically 256–3072 dims. | [0.021, -0.113, …] |
| similarity | Nearness in that space ≈ relatedness in meaning. | cos(cat, dog) > cos(cat, carburetor) |
| context dependence | The same word embeds differently in different sentences. | 'bank' ≠ 'bank' |
| anisotropy | Raw vectors cluster in a cone — normalize before comparing. | cosine instead of dot |
| Distance metrics | ||
| cosine | Angle between vectors — the default for text; length-independent. | cos = A·B / (|A||B|) |
| dot product | Cosine × lengths — equals cosine when vectors are normalized. | A·B (fastest) |
| euclidean (L2) | Straight-line distance; fine within one model, misleading across scales. | √Σ(aᵢ−bᵢ)² |
| manhattan (L1) | Sum of absolute differences; robust to outlier dims. | Σ|aᵢ−bᵢ| |
| Practical geometry | ||
| dimensions | More dims = more nuance, more storage, slower search. | 384 (small) → 3072 (large) |
| Matryoshka (MRL) | Truncate trained embeddings to a shorter prefix, keep most quality. | 1536 → 256 dims |
| hybrid search | Embedding similarity + keyword (BM25) beats either alone. | 0.6·dense + 0.4·sparse |
| cross-encoder rerank | Embeddings shortlist; a reranker scores pairs for the final order. | top-50 → rerank → top-5 |