Docent · Jun 28, 2026 · 1 min read

RAG is mostly retrieval

The generation half of retrieval-augmented generation gets the attention because it’s the part that talks back. But the quality of the answer is decided upstream, in chunking, embedding, and ranking — long before a token is produced.

Relevance is a cosine similarity of normalised vectors, cosθ=abab\cos\theta = \frac{a \cdot b}{\lVert a\rVert\,\lVert b\rVert} — rank by it, take the top-kk, and most “model” problems turn out to be index problems:

score(q,d)=eqedeqed\text{score}(q, d) = \frac{\mathbf{e}_q \cdot \mathbf{e}_d}{\lVert \mathbf{e}_q\rVert\,\lVert \mathbf{e}_d\rVert}

A tiny retriever, in practice:

import numpy as np

def top_k(query_vec, doc_vecs, k=5):
    q = query_vec / np.linalg.norm(query_vec)
    d = doc_vecs / np.linalg.norm(doc_vecs, axis=1, keepdims=True)
    return np.argsort(-(d @ q))[:k]

Placeholder body. The real piece walks through a small, honest index.

← More in DocentAll topics
— / —