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 14

Fitting a word budget

In one sentence: when an answer must fit a length limit, you either cut sentences by rule or have a model rewrite the answer shorter, and each way loses something different.

Why you should care

Real answers have limits: a screen, a reader's patience, a contest rule. A model asked for full coverage will often write too much. What you do with the overflow decides which facts survive. It can also quietly break citations, which is worse than losing a fact.

Words you need

Word budget
The most words an answer may have.
Trimming
Removing whole sentences until the answer fits. Nothing is rewritten.
Compression
Rewriting the answer in fewer words while trying to keep its facts.
Extractive
Built only from sentences that already exist. Trimming is extractive.
Abstractive
Newly written text. Compression is abstractive.
Redundant sentence
A sentence that adds nothing new. In our rule: one whose cited documents were all cited earlier.
Citation drift
After a rewrite, a sentence cites a document that no longer supports what the sentence says.
Gate
A test a change must pass before it is allowed to ship.

Core The idea

Suppose the limit is 1,000 words and the draft has 1,400. There are three options.

OptionHowKeepsRisks
Ask for lessPut the limit in the promptOne step, no extra costModels count words poorly. Drafts still run over, or stop early and miss parts.
TrimDelete sentences by a fixed ruleEvery remaining sentence is exactly as written, with its citationsWhole facts vanish. Which ones depends on the rule.
CompressA model rewrites the draft to fitMore facts in fewer wordsThe rewrite can change a fact or attach it to the wrong source.

A trimming rule

A good trimming rule deletes the least valuable sentences first. Ours works in three passes, each from the end of the answer backwards, and stops as soon as the answer fits:

  1. Remove sentences that have no citation.
  2. Remove sentences whose cited documents were all cited by an earlier sentence.
  3. Remove sentences from the tail.

Pass 2 rests on a guess: a sentence that draws on no new document probably adds little. The guess is cheap to compute and sometimes wrong, since one document can hold many facts.

Compression needs a gate

Compression merges and rewrites sentences. When two sentences with different sources become one, which sources should the new sentence cite? A model can get this wrong without any sign in the text. So a compressed answer must be tested: sample sentences, open the cited documents, and check that each one still supports its sentence. Set the pass mark before you look.

Watch and read

We have not found a video or a plain-language article on this exact topic that we would recommend. The textbook name for the general problem is “summarization”, with the two kinds named above.

How we did it at TREC 2026

Our prompt asked for 45 to 70 sentences, and a draft of that size can run past the limit. We first built the trimming rule above and applied it to all six runs at 1,000 words. A copy of the rule, written again from scratch for our checks, reproduces every trimmed file exactly.

In the last two days before we submitted, we tried compression. A model was asked to rewrite each raw draft into at most 980 words, keeping every distinct fact and the document identifiers of the sentences it came from. Each compressed answer then went through the same trim, assembly and repair as before.

We set a gate: a compressed run would replace the trimmed one only if at least 95% of sampled citations still supported their sentences.

RunDraft written byPassed the gate?What we submittedMean words
isu-cov2-ftgpt-5-miniYesCompressed887.9
isu-cov2-gpt5minigpt-5-miniYesCompressed854.1
isu-cov2-gemini3fgemini-3-flashYesCompressed666.9
isu-cov2-gen-dsv32deepseek-v3.2NoTrimmed946.8
isu-cov2-qwen36pqwen-3.6-plusNoTrimmed954.1
isu-cov2-gen-haiku45claude-haiku-4.5NoTrimmed920.6

Mean words per answer on the 42 evaluated narratives, counted as space-separated words. No submitted answer is above 1,000.

The compression script used gpt-5-mini, whatever model wrote the draft. Our notes from that week record what happened when it rewrote other models' drafts: the citations drifted. Three runs failed the gate and kept their trimmed files.

What surprised us

The gate protected the answers and damaged the experiment. The six runs were meant to compare generators on the same evidence. After the gate, three runs carry answers rewritten by gpt-5-mini and three carry answers cut by rule. So a difference between, say, the gpt-5-mini run and the DeepSeek run now mixes three things: who wrote the draft, how it was shortened, and who shortened it. Each decision was sound on its own. Together they broke the comparison (Chapter 15).

Two smaller surprises:

  • A compressor can refuse quietly. On one narrative the compression came back at 1,452 words, far over its limit of 980. The trim then removed 18 sentences. That answer is mostly the original draft, cut by rule, inside a run we describe as compressed.
  • Compressed answers came out shorter than they had to be. The Gemini run averages 667 words against a limit of 1,000. Unused budget is room where more facts could have gone.

Try it

  1. Write the three-pass trimming rule as a function. Test it on an answer of fifteen cited sentences with a limit of 150 words.
  2. Ask a model to compress the same answer to 150 words and keep the citations. Count the words it returns.
  3. For five compressed sentences, open the cited documents. Does each one still support its sentence?
  4. Which facts did trimming lose that compression kept, and the other way round?

Check yourself

  1. What is the difference between trimming and compression?
  2. What does pass 2 of our trimming rule assume?
  3. What is citation drift, and why is it hard to see?
  4. Why set the pass mark of a gate before looking at the results?
  5. How did the gate harm our comparison of generators?
Answers
  1. Trimming deletes whole sentences and rewrites nothing. Compression rewrites the answer in fewer words.
  2. That a sentence citing only documents already cited adds little that is new.
  3. A rewritten sentence cites a document that no longer supports it. The text reads well, so only opening the document shows the error.
  4. So the decision cannot be bent to favour the result you hoped for.
  5. Some runs were then shortened by a model and others by rule, so the runs no longer differ in the generator alone.

Go deeper

  • Budget inside the prompt. Models follow “about 40 sentences” better than “at most 1,000 words”. A sentence target plus a hard check afterwards is a workable pair.
  • Value per word. A better trimming rule would score each sentence by the key facts it adds per word and drop the lowest. That needs an estimate of the facts, which Chapter 18 provides.
  • Compress per part. Compressing each part of the answer on its own keeps sources closer to their facts and lowers the risk of drift.
  • Check all citations, not a sample. With an automatic support checker, every sentence of a compressed answer can be tested and only the failing sentences sent back.
  • Length and score. Longer answers can cover more nuggets. When runs differ in length, a score difference may partly be a length difference. Report mean words next to every score, as the table above does.
  • Project idea. On one set of drafts, compare three shorteners: our rule, a value-per-word rule, and model compression. Report nugget coverage and citation support for each.