Pro
Pro lesson

Retrieval-augmented generation

Give a model the right pages before it answers, and watch what changes (and what doesn’t).

This one’s part of How Models Learn Pro — every lesson, every interactive, and new ones as they land. About 10 minutes.

Already Pro? Sign in and you’ll go straight in.

Inside “Retrieval-augmented generation”

What you’ll learn

  1. An open-book exam
  2. Search by meaning, not keywords
  3. How many passages go in? Top-k
  4. From memory versus from the sources
  5. When RAG goes wrong

Key terms

Retrieval-augmented generation (RAG)
Searching for relevant text and adding it to the prompt so a model answers from those sources.
Embedding
A list of numbers that represents a piece of text so that texts with similar meanings get similar lists.
Cosine similarity
A score from −1 to 1 for how closely two embeddings point in the same direction; higher means more similar.
Top-k retrieval
Keeping only the k highest-scoring passages from a search to put in the prompt.
Chunking
Splitting long documents into short passages so each can be embedded and retrieved separately.
Grounding
Tying a model’s answer to specific source text that a reader can check.
Citation
A pointer in an answer, like [1], to the source a fact came from.

Sources