liveBook · Manning

Cosine similarity

As explained in Machine Learning Platform Engineering

Cosine similarity measures the angular alignment of two vectors independently of their magnitudes.

Cosine similarity compares vectors by their angular alignment, making it useful for finding semantically related document chunks without emphasizing embedding magnitude. section 12.2.4

In production retrieval, FAISS can use cosine similarity alongside L2 distance and inner product. Choose retrieval count and thresholds carefully: too few results reduce coverage, while too many add noise. section 12.2.4

How Machine Learning Platform Engineering covers it

How deep it goes
Defines the semantic-direction rationale and operational trade-offs but stops short of mathematical derivation or implementation details.
Examples
Demonstrates similarity search over indexed documentation using the query “How do I rotate encryption keys?” and three retrieved results.
What it assumes
Assumes vector embeddings and retrieval concepts while connecting metric choice to chunking, indexing, and query design.
What you can do after
Evaluate retrieval quality by selecting a distance metric and tuning result counts and similarity thresholds.
How it connects
Connects cosine similarity with embeddings, vector databases, FAISS, chunking strategy, retrieval thresholds, and semantic search.

Also explained in

Compare how 14 books explain cosine similarity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Platform Engineering. The section links point to the parts of the book it draws on.