Glossary
Canonical terms for this subject. Every lesson uses these words.
Pipeline
- RAG (retrieval-augmented generation)
- Answering with a model whose prompt is augmented by documents retrieved from an external index at query time. Avoid: "search + AI", grounding (that is the goal, not the mechanism).
- Chunk
- The unit of text that gets embedded, indexed and retrieved. One chunk is one retrievable fact-bundle.
- Embedding
- A fixed-length vector encoding a text's meaning, so semantic similarity becomes vector distance.
- Index
- The data structure that makes retrieval fast: a vector index for embeddings, an inverted index for keywords.
- Contextual retrieval
- Prepending a short chunk-specific context (what document, what section, what entity) before embedding and indexing the chunk. Avoid: context stuffing.
Retrieval
- Dense retrieval
- Ranking chunks by embedding similarity to the query embedding. Finds meaning, misses exact tokens.
- Sparse retrieval
- Ranking by weighted keyword overlap, canonically BM25. Finds exact tokens (codes, names, addresses), misses paraphrase.
- Hybrid retrieval
- Running dense and sparse retrieval in parallel and fusing the ranked lists.
- RRF (reciprocal rank fusion)
- Fusing ranked lists by scoring each item 1 / (k + rank) per list and summing, k typically 60.
- Metadata filter
- A hard predicate (price ≤ 400000, city = Ghent, tenant = this agency) applied by the index before or with similarity ranking. Filters are exact; similarity is approximate.
- Reranker
- A second-stage model that rescores the top candidates by reading query and chunk together (a cross-encoder), trading latency for precision.
- HyDE
- Query rewriting that embeds a hypothetical answer instead of the raw question, so the query vector lives where answers live.
- Top-k
- The k highest-ranked chunks a retrieval stage passes on. Every stage has its own k.
Evaluation
- Gold set
- A fixed list of real questions, each with the chunks that should be retrieved and the facts a correct answer must state.
- Recall@k
- The fraction of gold chunks that appear in the top k retrieved. The retrieval ceiling: the generator cannot cite what retrieval never returned.
- MRR (mean reciprocal rank)
- Average of 1 / rank of the first relevant chunk. Measures whether the right chunk is near the top, not merely present.
- Faithfulness
- The fraction of claims in the answer supported by the retrieved chunks. Low faithfulness with good retrieval means the generator is inventing.
- Context precision
- How much of what was retrieved was actually relevant. Low precision wastes context and invites distraction.
- LLM-as-judge
- Using a model to grade answers. Useful and biased: position, verbosity and self-enhancement biases are documented.
Security
- Indirect prompt injection
- Instructions hidden inside retrieved content that the model mistakes for operator instructions. The signature RAG attack. Avoid: jailbreak (that is a different attack, by the user).
- Row-level access control
- Filtering retrievable chunks by the caller's permissions at query time, inside retrieval, never after generation.
Terms are promoted here as lessons cover them; definitions tighten as understanding deepens.