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 2 · Finding the evidence · Chapter 10

How many documents?

In one sentence: a ranked list has to stop somewhere, and where it stops is a prediction about how many useful documents exist, which can be right or wrong like any other prediction.

Why you should care

For decades, search systems returned a fixed number of results: 10, 100 or 1,000. In RAG the list goes to a language model, and every extra document costs money, time and attention. Return too few and the answer misses facts. Return too many and the facts drown. In 2026 the TREC RAG track made this an explicit part of the task: return all and only the documents you believe are relevant, with a different number for each question.

Words you need

Depth (k)
How many documents a system returns for one question.
Fixed depth
The same k for every question.
Variable depth
A k chosen for each question.
Threshold
A score value. Documents that score above it are kept, the rest are dropped.
F1
One number that combines precision and recall. It is high only when both are high.
Calibration
Choosing a setting, such as a threshold, on questions where you already know the right answers.
Development (dev) set
Questions with known answers that you use to tune a system before the real test.
Transfer
Whether a setting tuned on one set of data still works on another.

Core The idea

Questions differ

“When did the bridge reopen?” may have three useful documents in the whole collection. “How do cities pay for bridge repairs?” may have three thousand. A fixed k of 100 is too many for the first question and too few for the second. Padding the first list to 100 adds 97 documents that are not useful.

Cutting by score

The common way to choose k for each question is a score threshold. The reranker gives every candidate a score. Pick one threshold. For each question, keep every document that scores above it. A question with many strong documents gets a long list, and a question with few gets a short one.

Choosing the threshold

You need a goal. “All and only” means both recall (all) and precision (only). F1 combines them:

F1 = 2 × precision × recall / (precision + recall)
Example: precision 0.5 and recall 0.8 give 2 × 0.5 × 0.8 / 1.3 = 0.615.

F1 punishes imbalance. Precision 0.1 with recall 1.0 gives only 0.18. So you cannot win by returning everything.

Calibration then goes like this:

  1. Take dev questions whose documents have been judged.
  2. Score every judged document with the reranker.
  3. Try many thresholds. For each, compute precision, recall and F1 over the dev set.
  4. Keep the threshold with the best F1, and use it unchanged on the test questions.

Step 4 hides an assumption: that a score means the same thing on the test data as on the dev data. The rest of this chapter is about that assumption.

Watch and read

We have not found a short video on this topic that we would recommend. The research name for it is “ranked list truncation”.

How we did it at TREC 2026

When the track guidelines added the variable-depth rule, the retrieval runs we had built all returned a flat 100 documents. None of them said how many documents we believed were useful. So we built one more run, isu-rrf-ce-tau.

  1. Candidates. The deep pool from Chapter 8, capped at 2,000 documents per narrative, all scored by the cross-encoder from Chapter 9.
  2. Dev data. 22 development topics with 100 judged documents each, 2,200 pairs. The judgments came from our own panel of language-model judges, on a scale from 0 to 4. We counted grade 2 or higher as useful.
  3. Calibration. We tried a grid of thresholds and kept the one with the best F1: τ = 0.00502. On the dev data it gave precision 0.776, recall 0.894 and F1 0.831, with 39 to 100 documents kept per topic, about 80 on average.
  4. The run. For each of the 119 narratives, keep every document that scores above τ. The lists came out between 119 and 1,956 documents long, with a median of 784.

We also submitted the full scored ranking, isu-rrf-ce-pool, marked as “enrichment”: a run meant to give the judges more documents to look at, not to compete. It was not scored.

Document setDocuments per narrativeSet precisionSet recallNugget gain
Track median1000.34990.10020.6268
Deep pool, reranked, top 1001000.31300.13320.6291
The same ranking, cut at τ709.90.12290.29270.8309

Official scores, 114 runs from 27 teams. Precision and recall on 82 narratives, nugget gain (AutoNuggetizer nuggets) on 25. On the 82 scored narratives our lists ran from 119 to 1,680 documents. Source: the RAG tab of our results dashboard.

The top-100 run is contained in the long run on every narrative. Adding documents can only keep or raise recall and nugget gain, and the official scores follow that on every narrative. So the last two rows are one ranking cut at two places. They show the trade exactly: seven times the documents, a little more than twice the recall, and less than half the precision.

What surprised us

The threshold did not transfer. On dev, the threshold kept about 80 documents per topic at precision 0.776. On the test narratives it kept about 710 at an official precision of 0.1229. Three things differed between calibration and test, and we cannot separate them:
  1. The pool. The dev candidates were a top-100 list. A threshold could never keep more than 100 of them, so calibration could not see what the threshold would do on 2,000 candidates.
  2. The judges. Dev used our own language-model judges. The track used its own automatic judgments. “Grade 2 or higher” need not mean the same thing in both.
  3. The scale of the scores. A cross-encoder's score for a document changes when the document is cut at a different length. Our calibration script carries a warning about exactly this. We calibrated with documents cut at 2,000 characters.
The lesson for students: calibrate on data that looks like the test, in pool depth as well as in topic. Then check the number of documents your threshold returns before you submit. A jump from 80 to 710 was a warning we could have read.

Was the long list a bad run, then? It depends on the reader. It has the highest recall and nugget gain of all our runs and the lowest precision. A person would not read 710 documents. A pipeline that next selects evidence for a writer might be glad to have them. Chapter 13 takes up the next question: how many of the documents to show the model.

Try it

  1. Compute F1 for precision 0.9 with recall 0.3, and for precision 0.6 with recall 0.6. Which is better?
  2. Take reranker scores and judgments for ten questions from the Chapter 9 lab. Find the threshold with the best F1 on five of them. Apply it to the other five. How much does F1 drop?
  3. Plot the list length for each question at your threshold. Which question gets the longest list, and does that match your sense of the topic?
  4. Now calibrate on the top 20 candidates only and apply the threshold to the top 200. What happens to the list length?

Check yourself

  1. Why is one fixed k a poor fit across questions?
  2. Why choose a threshold by F1 and not by recall?
  3. A threshold was tuned on lists of 100 candidates. Name one reason it may misbehave on lists of 2,000.
  4. Our long run contains our top-100 run. Which of its scores must be at least as high, and which need not be?
  5. What simple check before submitting could have warned us?
Answers
  1. Questions have very different numbers of useful documents.
  2. Recall alone is best when you return everything. F1 also needs precision, which matches “all and only”.
  3. Calibration never saw what the threshold keeps below rank 100, so the precision measured on dev says nothing about the deeper part.
  4. Recall and nugget gain must be at least as high. Precision need not be.
  5. Comparing the number of documents kept on test with the number kept on dev.

Go deeper

  • Ranked list truncation. There is a research line on models that read the score curve of a list and predict where to cut. Simple baselines are a fixed k, a fixed threshold, and a cut at the largest drop between neighbouring scores.
  • Calibrated scores. A score is calibrated when, among documents scored 0.8, about 80% are relevant. Raw reranker scores are not. Methods such as Platt scaling fit a curve from scores to probabilities on judged data.
  • Per-question thresholds. One global threshold assumes scores are comparable across questions. They often are not: some questions get high scores everywhere. Normalizing scores within each question is one answer.
  • Depth and the generator. The best depth for a retrieval score and the best depth for the final answer are different questions. Part 3 tests the second one directly.
  • Enrichment runs. In a pooled evaluation, deep runs help the organizers find relevant documents that nobody ranked highly. That helps everyone who later reuses the collection.
  • Project idea. Using our dev recipe, calibrate on the top 100 and then on the top 1,000 candidates. Measure how well each threshold predicts list length and precision on held-out topics.