# Cosine Similarity

> Cosine similarity measures how alike two embeddings are by the angle between them — the standard relevance score behind semantic search and RAG retrieval.

Cosine similarity scores how alike two embeddings are by the angle between them, ignoring magnitude, matching how embedding spaces encode meaning directionally. Two field notes save real debugging time: scores are not portable between models, so thresholds must be recalibrated, and similarity is not relevance, which is why pipelines add a reranker.

**Cosine similarity scores how similar two [embeddings](/glossary/embedding) are by measuring the angle between them: 1.0 means pointing the same way (very similar), 0 means unrelated — the default relevance metric of [semantic search](/glossary/semantic-search).**

It won the default slot because embedding spaces encode meaning *directionally*: two texts about the same thing point the same way regardless of length or emphasis, so comparing angles (and ignoring magnitude) matches semantic intuition. A practical simplification follows: most modern embedding models output **normalized** vectors, where cosine similarity equals the dot product and ranks identically to Euclidean distance — the metric choice in your [vector database](/glossary/vector-database) matters less than tutorials imply, as long as it matches what the embedding model was trained for (check the model card).

Two field notes save real debugging time. **Scores aren't portable**: each model has its own score distribution, so thresholds like "similarity > 0.8" must be calibrated per model, never copied. And **similarity isn't relevance**: cosine retrieves what's *alike*, which is why pipelines add [reranking](/glossary/reranking) to sort the genuinely-relevant out of the merely-similar.

---

_Source: https://agentscamp.com/glossary/cosine-similarity — Term on AgentsCamp._
