Retrieval Augmented Generation

Layer 4 · Foundations

Retrieval Augmented Generation

The geometry of similarity, why ANN search is approximate, HNSW's structure, and the recall-latency-memory triangle.

12 min read180 XP

Similarity is an angle, not a distance

Retrieval ranks passages by cosine similarity between the query vector and each document vector. Written out, that is the dot product normalised by both magnitudes: