ContentsRAG from Scratch to TRECAdisak Sukul · Iowa State University

Start here

Part 1 · Foundations

Part 2 · Finding the evidence

Part 3 · Writing the answer

Part 4 · Judging RAG

Part 5 · TREC and the 2026 tracks

Part 6 · Case studies: our submissions

Part 7 · Beyond text: video

Part 8 · Streams and advanced RAG

Back matter

Part 1 · Foundations · Chapter 1

Why language models need to look things up

In one sentence: a language model writes from what it absorbed in training, so it can be out of date, it cannot see private or new documents, and it can state wrong things in a confident voice, and letting it look things up fixes much of that.

Why you should care

If you build anything with a language model, the first serious complaint you will hear is “it made that up”. Before you can fix this, you need to know why it happens. The answer shapes every design decision in the rest of the book.

Words you need

Large language model (LLM)
A program trained on a very large amount of text to predict the next piece of text. Chat assistants are built on LLMs.
Token
The unit a model reads and writes: a word or a piece of a word.
Training data
The text the model learned from.
Knowledge cutoff
The date after which the model has seen nothing.
Context window
Everything the model can read at once when it answers: your question plus any text you give it.
Prompt
The text you send to the model.
Hallucination
A statement by the model that is fluent and confident and not true, or not supported by anything it was given.
Grounding
Tying each statement in an answer to a source that the reader can check.

Core The idea

A language model does one thing: given some text, it predicts what text comes next. It was trained on billions of sentences, so its predictions are very good. Ask it for the capital of France and “Paris” is by far the most likely next word.

Notice what is missing. The model does not look anything up. It has no list of facts. It has a compressed impression of its training text, and it writes what sounds most likely. Usually what sounds likely is true. Sometimes it is not.

Three limits of answering from memory

LimitWhat happensExample
It is frozen in timeThe model knows nothing after its knowledge cutoff.Ask about last week's news and it will not know, or it will guess.
It never saw your documentsPrivate, local or rare text was not in the training data.Your university's course rules, a company's manuals, a new research paper.
It fills gaps with likely textWhen the model does not know, the most likely next words can still form a confident, wrong answer.A reference to a paper that does not exist, with realistic authors and a realistic title.

There is a fourth problem, and it is about you, the reader. Even when the answer is right, you cannot check it. The model does not say where the claim came from.

Closed book and open book

Think of two exams. In a closed-book exam you answer from memory. In an open-book exam you may look at the textbook, and a good examiner asks you to give the page.

Closed book

The model answers from memory. Fast and simple. Out of date, blind to private documents, and you cannot check the answer.

Open book

A search step first fetches documents. The model answers from those and cites them. This is retrieval-augmented generation.

An open book does not make the student honest by itself. A student can still copy the wrong page, or write from memory and add a page number that looks right. So an open-book system needs two more things: a good way to find the right pages (Part 2) and a way to check the citations (Part 4).

A small example

Question: “What did the city council decide about the bridge last month?”

  • From memory: the model cannot know. A careful model says so. A less careful one writes a plausible paragraph about budgets and repairs.
  • With lookup: a search finds the council minutes. The model writes “The council approved the repair budget [1] and postponed the new lane [2]”, and you can open [1] and [2].

The second answer is better in three ways. It is current, it uses a document the model never saw in training, and it can be checked.

Watch and read

For these videos we confirmed that the link opens and the title and channel match. The notes describe the topic.

How we did it at TREC 2026

The TREC RAG track is an open-book exam by design. Each question is a long paragraph, the narrative. The answer may be up to 1,024 words. Each sentence of the answer can cite up to three documents from the track's collection, ClimbMix.

In our system the writer, GPT-5 mini, was given 100 documents for each narrative and one instruction for all runs: write cited sentences from these documents. Every citation had to be one of the 100. We did not ask the model what it knew. We asked it what the documents said.

The track then checks both halves of the open-book idea. Does the answer contain the key facts (nuggets, Chapter 18)? And do the cited documents support the sentences (Chapter 19)?

What surprised us

The open book did not end the problem. It moved it. Once the model writes from documents, the question becomes which documents, how much of each, and in what order. Our two main runs gave the same writer the same 100 documents, cut short in one run and long in the other, and the answers were scored differently. Most of our year went into those “which and how much” questions, not into the model.

Try it

  1. Ask any chat assistant about something that happened last week in your town. Note what it says and whether it admits it does not know.
  2. Ask it for three research papers on a narrow topic you know well, with authors and years. Check each one. How many exist exactly as stated?
  3. Now paste in two paragraphs from a real source and ask the same question with the instruction “answer only from the text below and quote the sentence you used”. Compare the answers.

Check yourself

  1. What does a language model actually compute?
  2. Name the three limits of answering from memory.
  3. What is the difference between a wrong answer and a hallucination?
  4. Why does an open book not guarantee a correct answer?
  5. What can a reader do with a cited answer that they cannot do with an uncited one?
Answers
  1. The most likely next tokens, given the text so far.
  2. It is frozen at its knowledge cutoff, it never saw private or new documents, and it fills gaps with likely-sounding text.
  3. A hallucination is a wrong or unsupported statement delivered fluently and confidently, with no signal that the model is unsure.
  4. The system can fetch the wrong documents, and the model can still misread them or add claims from memory.
  5. Open the source and check the claim.

Go deeper

  • Parametric and non-parametric memory. What the model stores in its weights is called parametric memory. A document collection it can search is non-parametric memory. RAG combines the two, and the original RAG paper uses exactly these words (see Chapter 2).
  • Is “hallucination” the right word? Some researchers prefer “confabulation” or simply “unsupported claim”. For evaluation the second is the most useful, because it can be tested: is there a retrieved document that supports this sentence?
  • Knowledge conflicts. What should a model do when a retrieved document disagrees with what it learned in training? Systems differ, and the behaviour is hard to control with a prompt alone.
  • Project idea. Collect 30 questions whose answers changed after a model's knowledge cutoff. Measure how often the model answers with the old fact, says it does not know, or guesses.