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 3 · Writing the answer · Chapter 15

Choosing the generator

In one sentence: the language model that writes the answer is one replaceable part, and the way to choose it is to hold everything else fixed and measure it on your own task.

Why you should care

New models appear every few weeks, each with a leaderboard claim. Leaderboards measure general skill. Your RAG system needs one narrow skill: write a complete answer from the given documents, cite each sentence correctly, and follow the output format every time. A model that leads a general ranking may be average at this. Price and speed can differ by a factor of ten or more between models of similar quality.

Words you need

Generator
The language model that writes the answer.
Model family
The models of one maker, such as the GPT, Gemini, Claude, Qwen or DeepSeek models.
Open-weight model
A model whose trained numbers are published, so you can run it on your own machines.
Hosted model
A model you reach through a paid service.
Ablation
An experiment that changes one part of a system and keeps the rest fixed.
Format reliability
How often a model returns output in exactly the shape you asked for.
Faithfulness
Whether the answer says only what the evidence supports.

Core The idea

What to compare

QuestionHow to find out
Does it cover the key facts?Nugget scores on your own questions (Chapter 18)
Does it stay with the evidence?Citation support checks (Chapter 19)
Does it follow the format?Count the outputs your validator rejects
What does it cost?Input and output tokens per answer, times the price
How fast is it?Seconds per answer
How much can it read?The context window, against your evidence budget (Chapter 13)
Where can it run?Hosted only, or open weights. Check the rules for your data.

How to compare

  1. Fix everything else. Same questions, same evidence in the same order, same prompt, same post-processing.
  2. Change only the model.
  3. Score all outputs the same way, question by question.
  4. Compare in pairs with a sign test (Chapter 4), not by averages alone.
  5. Read ten answers yourself. Numbers miss things that a reader sees in a minute.

Step 1 is where most comparisons fail, ours included. A prompt tuned on one model can favour that model. A post-processing step built around one model's habits can favour it too.

Watch and read

For the video we confirmed that the link opens and the title and channel match. We have not watched it through.

How we did it at TREC 2026

Five of our six RAG generation runs were meant as a generator comparison. Each got the same 100 snippets in the same order and the same prompt. Only the model changed. We chose five families on purpose, so the result would not depend on one maker.

RunGeneratorRubrics, 17 narrativesAssessor nuggets, 25AutoNuggetizer nuggets, 25
Field median0.71570.48790.1547
isu-cov2-gpt5minigpt-5-mini0.87350.62990.2590
isu-cov2-gemini3fgemini-3-flash0.63530.48790.1253
isu-cov2-qwen36pqwen-3.6-plus0.65490.44250.1023
isu-cov2-gen-dsv32deepseek-v3.20.52350.46610.1041
isu-cov2-gen-haiku45claude-haiku-4.50.44020.40140.0964

Share of vital facts fully supported, as decided automatically by a language model. Official scores for the TREC 2026 RAG task. These five runs have no human preference judgments: the assessors compared only each team's two first-priority runs. Source: the RAG generation tab of our results dashboard.

The gpt-5-mini run is higher than each of the other four on every one of 24 comparisons: four runs, three sets of key facts, two measures. In 23 of the 24, the difference holds up in a paired sign test after correcting for the number of tests. The gpt-5-mini run is above the field median everywhere. The other four are above it nowhere.

What surprised us

The table does not show that gpt-5-mini is the best generator. It shows that the gpt-5-mini run scored highest. The runs differ in more than the model:
  1. The answers were shortened in different ways. The gpt-5-mini and Gemini answers were rewritten to the word limit by a model. The DeepSeek, Qwen and Claude answers were cut by rule (Chapter 14).
  2. The rewriting model was gpt-5-mini. So the gpt-5-mini run was drafted and shortened by the same model, and the Gemini run was drafted by one model and shortened by another.
  3. One model is not one model. Two narratives of the Gemini run were generated with a preview version, after the first drafts had no valid citations.
What we can say: on this task, with this prompt and this pipeline, the gpt-5-mini run covered clearly more key facts than the other four. What we cannot say is how much of that belongs to the model.

The other half of the lesson is about planning. We had five slots and spent them on five models. A stronger design would have spent two of them on one model with both ways of shortening. Then the effect of shortening could have been measured and removed from the comparison.

Try it

  1. Pick two models you can reach. Run the same ten questions, evidence and prompt through both.
  2. Count for each: outputs rejected by your validator, mean words, input and output tokens.
  3. Read the ten answers of each side by side without knowing which model wrote which. Which set do you prefer, and on how many of the ten?
  4. Now change the prompt in a way that helps the weaker model. Did the order of the two change?

Check yourself

  1. Why is a general leaderboard a weak guide for a RAG generator?
  2. What must stay fixed in a fair comparison of generators?
  3. Why did we choose models from five families?
  4. Give two reasons our table does not prove that gpt-5-mini is the best generator.
  5. What would a better use of the five run slots have been?
Answers
  1. It measures general skill, not complete, correctly cited answers in a fixed format on your documents.
  2. The questions, the evidence and its order, the prompt, and the post-processing.
  3. So the result would not depend on one maker's models.
  4. Any two of: the runs were shortened in different ways; gpt-5-mini did the rewriting; some answers came from a different model version.
  5. Use some slots for a second version of one model with the other way of shortening, to measure that effect on its own.

Go deeper

  • Prompt and model interact. A fair test tunes the prompt for each model on separate dev questions, with the same effort for each. That is costly, and without it the comparison is of one prompt, not of the models.
  • Reasoning effort. Many current models can think before answering, at a price in time and tokens. We used a low setting for every model. A higher setting might change the order.
  • Small against large. Several of our generators are their makers' smaller, cheaper models. With 119 narratives and up to 112,000 input tokens per call, cost was a real limit. Whether a larger model would add much on top of good evidence is an open question for us.
  • Models change. A hosted model's name can point to a new version next month. Record the exact name and the date for every run, as our run descriptions do.
  • Judge and generator from one family. The automatic scores here were decided by a GPT model, from the same maker as gpt-5-mini. Whether an automatic judge favours answers written by its own family is a research question (Chapter 21).
  • Project idea. Take three generators and two ways of shortening. Run all six combinations. How much of the spread in scores comes from the model, and how much from the shortening?