Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

Cosine similarity

Definition

A measure of how similar two vectors are based on the angle between them, ranging from -1 (opposite) to 1 (same direction).

In more detail

It is the usual way to compare text embeddings. For vectors normalised to unit length, cosine similarity and dot product give the same ranking.

Scores range from -1 to 1, but text embeddings usually fall in a narrow positive band, and what counts as similar enough differs between models. Do not copy a threshold from one model to another: look at the score distribution for matching and non-matching pairs in your own data. Vector databases let you pick the distance metric when you create a collection; use the one the embedding model was trained for.

  • Embedding

    A vector representation of text or other data that places items with similar meaning close together, so they can be searched by similarity.

  • Vector database

    A database designed to store embeddings and quickly find the nearest neighbours to a query vector, often with metadata filtering.

  • HNSW

    Hierarchical Navigable Small World: a graph-based index for fast approximate nearest-neighbour search, widely used by vector databases.

  • Semantic caching

    Reusing a stored model response when a new request means the same as an earlier one, judged by embedding similarity rather than exact text.

  • Embeddings and vector search, hands on

    Embed documents, store them in Postgres with pgvector, index them and run similarity and hybrid search.

    TutorialIntermediate45 min

  • Embeddings and vector search

    Turning text into vectors to find similar items, alone or with keywords.

    SkillIntermediate

  • Semantic caching

    Reusing a stored model response when a new request means the same as an earlier one, judged by embedding similarity rather than exact text.

    Glossary