PromptForge
AI Glossary

Retrieval & data

Cosine similarity

Also known as: cosine distance, similarity score

Definition

Cosine similarity measures how closely two vectors point in the same direction, on a scale from -1 to 1. It is the standard way to compare embeddings, because it captures semantic similarity while ignoring text length.

The metric is the cosine of the angle between two vectors. A value of 1 means identical direction, 0 means unrelated, and -1 means opposite. Because it depends only on direction and not magnitude, a short paragraph and a long article on the same topic score as similar.

That length-insensitivity is exactly why it suits text retrieval: you want to match meaning, not word count.

In practice a vector database computes this for you. It matters when interpreting scores — typical "relevant" thresholds sit around 0.7-0.85 depending on the embedding model, and thresholds are not transferable between models.

Related terms

Put this into practice

Understanding the term is step one. Our free courses and tools let you actually use it.