# Cosine similarity

> Cosine similarity measures how similar two text vectors are, for example a page's main content and a search query. The higher the value, the more likely the content counts as relevant.

Source: https://www.codaai.ai/en/knowledge/geo-glossary/cosine-similarity/
Published: 2026-09-03
May be quoted with attribution and a link to the source.

---

Cosine similarity is a mathematical measure of how similar two vectors are. In AI systems it is used to calculate how close the [embedding](https://www.codaai.ai/en/knowledge/geo-glossary/embedding/) vector of a text section lies to the vector of a search query. The value ranges from −1 to 1; the closer to 1, the more similar the meaning.

## How does cosine similarity work?

Two texts are translated into vectors. Cosine similarity is the cosine of the angle between these vectors: if they point in the same direction, the value is close to 1; if they are perpendicular to each other, it is 0. Because only the direction counts and not the length, the measure is independent of how long a text is; a short, precise section can be closer to a question than a long article.

In the [retrieval pipeline](https://www.codaai.ai/en/knowledge/geo-glossary/initial-retrieval/) of an AI system, cosine similarity is a central criterion for which passages clear the relevance threshold in [re-ranking](https://www.codaai.ai/en/knowledge/geo-glossary/re-ranking/).

## Why does cosine similarity matter for AI visibility?

It is the technical version of the question "Does this content match the query?". Classic SEO answers this question via keywords and links; AI systems answer it via closeness of meaning. A page can rank for a keyword and still have a low value for the specific user question if its main content only touches on the question. It is then found, but not cited.

## What does this mean for your website?

Compare the main content of your important pages with the questions from your [prompt set](https://www.codaai.ai/en/knowledge/geo-glossary/prompt-set/). Sections that answer a question directly and begin with the term being asked about lie closer to the query than sections with an introduction, promotion and changes of topic. Cover the related questions too ([query coverage](https://www.codaai.ai/en/knowledge/geo-glossary/query-coverage/)), because an AI system rarely asks just one.
