Skip to content
masterclass Buddy

AI & ML · Concept

Cosine Similarity

Cosine similarity compares embedding vectors by their direction. For OpenAI embeddings, a dot product can calculate it efficiently because the vectors have unit length.

Last updated

Syntax

cosine_similarity(a, b) = (a · b) / (||a|| ||b||)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • Vector embeddings
  • text-embedding-3-small
  • text-embedding-3-large
  • Vector database
  • Semantic text search

Source: Vector embeddings | OpenAI API. Checked 2026-11-03.