Term
Cosine Similarity
Cosine similarity measures how similar two vectors are by the angle between them — the default metric in RAG retrieval for comparing query embeddings against the embeddings stored in a vector index.
Cosine Similarity — explained in more detail
Mathematically, cosine similarity is the dot product of two vectors divided by the product of their magnitudes — which is the cosine of the angle between them. Values range from -1 (opposite direction) to 1 (identical direction); 0 means orthogonal, i.e. no similarity. The key point: only the direction of the vectors matters, not their length. That makes the metric robust against scale effects — two texts of different lengths but similar meaning produce embeddings with a high cosine score even though their vector magnitudes differ.
Example / Practical context
In a RAG pipeline, the user query is converted into a vector (e.g. 1536-dimensional for OpenAI text-embedding-3-small) and compared against every chunk vector in the index via cosine similarity. The top-k with the highest scores land in the LLM context. When all vectors are normalised to length 1 (the norm in modern embedding models), cosine similarity is computationally identical to the dot product — vector databases like Pinecone or Qdrant exploit that equivalence for speed.
Distinction from related concepts
Euclidean distance measures geometric distance and depends on vector magnitudes — for normalised vectors it produces the same ranking as cosine similarity. Dot product is a different metric for non-normalised vectors and favours longer ones. Jaccard similarity operates on sets rather than vectors and is more typical of token-based search.
Entdecke mehr
AI Workflows by Keyword: How We Make Recurring Routines Enforceable
A typed keyword triggers a fixed AI routine — and every single step must be committed before the next one appears. Why that's the actual trick.
GlossarS-RAG
S-RAG (Search-optimized RAG) is boostN.ai's take on Retrieval-Augmented Generation. It extends classic RAG with search-engine principles: relevance ranking, recency decay and typed links between chunks for deterministic follow-up retrieval.
LexikonRAG Tuning and Balancing — Embeddings, Weights, Decay and MCP for Advanced Setups
How to steer retrieval on purpose: embedding choice, hybrid weights, reranker cascades, time decay, authority boost, MMR and MCP as a retrieval tool.