cosine similarity
A similarity score between two vectors from the angle between them, from 1 for the same direction to -1 for opposite, ignoring their lengths.
In more detail
It is the usual measure for text embeddings. Cosine distance is one minus the similarity, which is what pgvector's <=> operator and Chroma's cosine space return; for unit vectors all common measures give the same ranking.
Related terms
- dot product — The sum of the products of two vectors' matching values, a similarity score that grows with both alignment and length.
- Euclidean distance — The straight-line distance between two vectors, the square root of the summed squared differences.
- embedding vector — A list of numbers that represents a piece of text, or an image, so that items with similar meaning lie close together.
Taught in
- What An Embedding Is — AI Engineering: LLM Apps, RAG & Agents
- Embedding Models — AI Engineering: LLM Apps, RAG & Agents
- Vector Indexes And Databases — AI Engineering: LLM Apps, RAG & Agents
- Keyword And Hybrid Search — AI Engineering: LLM Apps, RAG & Agents
- Measuring Retrieval — AI Engineering: LLM Apps, RAG & Agents
- How RAG Works And When To Use It — AI Engineering: LLM Apps, RAG & Agents
- Retrieval That Finds The Right Thing — AI Engineering: LLM Apps, RAG & Agents