← All notes

RAFT

Updated 2026-10-29 · Sources 2026-10-11

Contents

Retrieval Augmented Fine-Tuning (RAFT) trains a language model to answer questions amid relevant and irrelevant documents. Retrieval changes the evidence presented at inference; fine-tuning changes how the reader uses it. RAFT combines these mechanisms without training the retriever itself.

Retrieval and adaptation

A language model assigns token-sequence probabilities:

\[p_\theta(y\mid x)=\prod_{t=1}^{\vert y\vert }p_\theta(y_t\mid x,y_{<t}).\]

Fine-tuning updates \(\theta\); retrieval selects \(D_q=\operatorname{Retrieve}(q,\mathcal C)\) from corpus \(\mathcal C\). A concatenated-context pipeline is

\[q\longrightarrow D_q\longrightarrow p_\theta(y\mid q,D_q).\]

This top-\(k\) reader uses \(p_\theta(y\mid q,D_q)\), unlike the original RAG formulation’s possible marginalization over latent documents. Changing retrieved evidence leaves weights fixed; adapting weights can teach answer style, selection, and domain behavior without maintaining a current copy of every source.

RAFT builds examples from question \(q\), evidence-bearing oracle \(d^*\), distractors \(d_1^-,\ldots,d_k^-\), and target answer \(a^*\), possibly with quotations and reasoning. It remains autoregressive supervised learning; retrieval awareness comes from the examples, not a new optimizer. This invented example illustrates the distinction:

Question: Which version introduced feature X?
Oracle: Release 2.4 introduced feature X.
Distractor: Release 2.3 improved startup time.
Target: The release note identifies version 2.4; answer: 2.4.

Real examples need source IDs, versions, spans, provenance, and permissions to distinguish support from plausible neighboring text.

Training mixture

For input \(x_i=(q_i,D_i)\) and target \(a_i=(a_{i,1},\ldots,a_{i,T_i})\), target-only supervision minimizes

\[\mathcal L_{\mathrm{SFT}}(\theta) =-\frac1n\sum_{i=1}^{n}\sum_{t=1}^{T_i} \log p_\theta(a_{i,t}\mid q_i,D_i,a_{i,<t}).\]

Question/document tokens condition the prediction and normally have masked loss. Token-normalized and per-example averages weight unequal answer lengths differently, so masking and normalization define part of the experiment.

RAFT mixes contexts using \(B_i\sim\operatorname{Bernoulli}(P)\):

\[D_i=\begin{cases} \{d_i^*\}\cup D_i^-,&B_i=1,\\ D_i^-,&B_i=0. \end{cases}\]

Even without the oracle, the target remains its answer. This can encourage answering without retrieved evidence; it is not abstention training. Replacing that target with “insufficient evidence” for source-only products changes the recipe and needs separate evaluation.

Evidence availability

Let \(H\) denote sufficient retrieved evidence and \(S\) successful grounded answering:

\[\Pr(S)=\Pr(S\mid H)\Pr(H)+\Pr(S\mid\neg H)\Pr(\neg H).\]

If supplied evidence is required and \(\Pr(S\mid\neg H)=0\), then \(\Pr(S)\le\Pr(H)\). Better attention cannot recover an absent source; for multi-hop questions, \(H\) must cover the complete evidence set. Evidence recall, conditional reader accuracy, distractor robustness, and missing-evidence behavior therefore measure distinct parts of the pipeline.

Explanations and citations

Teacher-forcing an explanation optimizes its likelihood, not proof that the model follows it internally or that every step is supported. A valid citation requires a supplied, accessible source, an accurate span, and support for the claim. An existing ID alone establishes neither quotation accuracy nor support. Strings/offsets can check exact quotations, while semantic support requires annotation or independently validated entailment. Synthetic spans need source verification before training, and correlated generated rationales and model judges cannot replace independent gold labels.

Evaluation contexts

Random question splits can leak documents, paragraphs, templates, or near duplicates. Held-out documents/versions test evidence use; confidence thresholds need separate calibration data. Controlled contexts isolate the following behaviors:

Context Test
Oracle only Reading with ideal evidence
Oracle plus distractors Irrelevant-context robustness
Retrieved top-\(k\) Deployed retrieval and reading
Distractors only Missing evidence
Conflicting dated sources Version/source priority
Correct source with changed answer Evidence use versus memorization

Ablations hold model, retriever, chunking, corpus, context budget, training tokens, and output format fixed. Different retrieval noise or chunk lengths change the reader’s input distribution; API compatibility does not preserve accuracy.

Costs and results

For training cost \(C_{\mathrm{train}}\), tuned query cost \(c_1\), and baseline \(c_0\), a cost-only break-even requires \(c_1<c_0\):

\[N_{\mathrm{break\text{-}even}}=\frac{C_{\mathrm{train}}}{c_0-c_1}.\]

This excludes quality, maintenance, data preparation, source updates, retraining, evaluation, retrieval, and escalation. If accuracy changes, cost per grounded success is more informative than cost per request. LoRA is an orthogonal adaptation choice; shorter outputs can save inference without training, so output requirements matter in comparisons.

The paper’s domain datasets, retrievers, and models support evidence-aware training under those conditions, not universal superiority or transferable percentage gains. Percentage points and relative change require the original metric and denominator. Matched-budget comparisons on held-out sources need a strong untuned reader, domain SFT, and context-aware SFT. Permission filtering, evidence verification, and abstention remain separate system components.

References

↑