Embeddings
Vectors used to compare representations of data
What is Embeddings?
An embedding represents an item, such as a text passage, as a vector produced by a model. Similarity measures compare vectors within that model’s representation space. Similarity can help search, grouping, and recommendations but does not establish factual agreement.
How it works
Fixed vectorRotating vector
- Angle
- 90°
- Cosine similarity
These example vectors have equal length. At 90°, their similarity is 0.
Key takeaways
-
Use compatible model versions and vector dimensions.
-
Evaluate retrieval relevance independently from similarity scores.
Illustrative example
For an illustrative two-dimensional example, vectors [1, 0] and [0, 1] have cosine similarity zero, while [1, 0] compared with itself has similarity one. These invented vectors illustrate arithmetic, not measured sentence embeddings.
Compare compatible vectors
Cosine similarity is the dot product divided by the product of vector lengths, for nonzero vectors. Dimensions and model versions must match the index’s expectations. Changing the embedding model usually requires re-embedding stored material. For multilingual search, evaluate real EN/ES queries; semantic closeness can still retrieve the wrong policy, date, or customer record.
Sources and documentation
A visual explanation
Watch on YouTube ↗ Transformers, the tech behind LLMs
Follow tokens and their vectors through a transformer, with an illustrated written version alongside the video.
Read the illustrated lesson ↗