LLMscore
Embeddings
Fixed-length vectors that place similar meanings close together.
What it is and why it exists
An embedding model maps text (or images) to a vector of a few hundred to a few thousand numbers so that semantic similarity becomes geometric closeness, usually measured with cosine similarity. They power dense retrieval, clustering, deduplication, semantic caching and classification.
Quick prototype
Call an embeddings API, store vectors in a list, rank with cosine similarity.
In production, at scale
Choose a model by retrieval quality on your own data (not leaderboard rank), fix the model version because vectors from different models are incompatible, normalise vectors, and budget storage: 1M chunks × 1,536 float32 dims ≈ 6 GB before index overhead.
Vendors and tools
| OpenAI text-embedding-3 | small/large; supports shortening dimensions |
|---|---|
| Cohere Embed | Multilingual, with input types for queries vs documents |
| Voyage AI | Retrieval-focused embeddings, domain variants |
| Open models (BGE, E5, GTE, nomic) | Self-hostable via sentence-transformers or TEI |
On AWS: Amazon Titan Text Embeddings and Cohere Embed on Bedrock; vectors usually land in OpenSearch Serverless, Aurora pgvector or S3 Vectors.
How it fails
- Re-embedding only part of the corpus after changing models — mixed vector spaces return garbage
- Exact identifiers (error codes, SKUs) embed poorly, so dense search misses them
- Queries and documents embedded with different instructions or prefixes
What the interviewer asks next
Why cosine and not Euclidean distance?
Cosine ignores vector length and compares direction. With normalised vectors the two rank identically, and dot product becomes the cheapest equivalent.
How do you cut embedding storage?
Use fewer dimensions (Matryoshka-style truncation where supported), quantise to int8 or binary, and only embed chunks you actually retrieve from.