RAG & Agents Engineering

M13 lab, embeddings

Cosine ignores length. Dot product rewards it.

Ten Larkspur Cloud handbook chunks drawn as 2D vectors, so you can see the angles. The vectors are hand-placed; every score is computed. Stretch the long pricing page the way an un-normalized model would, and compare the three rankings.

Golden question
Top by cosine
Top by dot product
Top by Euclidean
All three rankings agree

Three scores for every chunk

Sorted by cosine; rank under each metric beneath the score

ChunkCosineDotEuclideanGolden set

Higher is closer for cosine and dot; lower is closer for Euclidean distance. A rank in magenta differs from the cosine rank.

The vectors

Dashed circle: length 1. Arrows longer than 2.1 stop at the edge.

the questionits evidence chunksplans-overviewother chunks