RAFT on an Electronics Course: A Negative Result

P03 - First Run with Claude-Written Training Data

Numbers are measured unless marked Hypothesis. The goal, the method and the references are on the front page of this series.

A RAFT Training Example

Each example is one question, five documents and a target answer. In the target, the model quotes the document that holds the answer, reasons from it, and ends with a final answer. Below is a real example from the training set, shortened. Four of the five documents are distractors.

System: Answer the question using the documents provided. Some documents may be irrelevant. Reason step by step, quoting the supporting text from the documents as ##begin_quote##...##end_quote##, then give the final answer after <ANSWER>:.

User: five <DOCUMENT> blocks, then: Question: A series-parallel circuit is reduced to a single equivalent resistance of 5 Ω connected to a 20 V source. What total source current flows, and why is this the current that carries into the first expansion step when the 5 Ω is split into 4 Ω and 1 Ω in series?

Assistant (the training target): Ohm's Law gives the source current from the source voltage and the single equivalent resistance: I = 20 V / 5 Ω = 4 A. The document states ##begin_quote##a source voltage of 20 Volts applied across a single equivalent resistance value of 5 Ohms yields a current of 4 Amperes through the source##end_quote##. When the 5 Ω is expanded into 4 Ω and 1 Ω in series, the current carries over because ##begin_quote##series-connected components must share the same current##end_quote##. So 4 A flows through both the 4 Ω and 1 Ω parts. <ANSWER>: 4 A; it carries over to both the 4 Ω and 1 Ω parts because series-connected components share the same current.

Note the length of that answer; it matters in part 4.

At test time every model, fine-tuned or not, got the same system prompt: the one above when documents are given, and without documents a short version:

Answer the question. Reason step by step, then give the final answer after <ANSWER>:.

Where the Reasoning Goes

In the RAFT paper (Zhang et al. 2024) the student was LLaMA-2-7B-chat. That model has no separate thinking mode, so the only way it can reason is to write the reasoning out. The paper therefore trains on chain-of-thought answers (Wei et al. 2022) written by GPT-4: quotes from the document, then the reasoning. Its ablation shows the written reasoning is what makes the method work.

Gemma 4 does have a thinking mode: it can reason in a hidden block before it answers. Here that mode was off everywhere, in training and in every test, because the training answers carry their reasoning as visible text. That makes the visible answer E4B's only scratch space.

With thinking off, the instruct model still reasons in its answer: 500–900 tokens of its own working. Training replaced that with the teachers' write-ups. Sonnet and Opus wrote with their own hidden thinking switched on, but only the short write-up after it became training text.

Part 5 checks whether switching thinking off held back the instruct model. It didn't.

Generating the Training Data

Questions and answers. For each of the 3,054 training sections, a Claude model wrote 1–4 questions with quoted reasoning and a final answer. I ran it twice on the same sections and prompt:

Sonnet 5.5 Opus 5.5
questions 6,883 6,839
quotes that match the source word for word 98.3% 99.4%
cost (Batch API) $15.08 $34.66

Unplanned Opus run: one batch went out with Opus set as the model. Cancelling would still have billed the finished part, so I let it run as a comparison of a stronger, pricier generator. Both gave the same result.

Quality filter. Every quote is checked against its section. Questions with a quote that isn't word for word, or with no quote at all, are dropped (~4.6% for Sonnet). RAFT teaches citing, so a wrong citation is worse than a missing example.

Decontamination. A generated question is dropped if it's too close to any exam question: embedding similarity ≥ 0.80, or a shared run of 13 words. The line was set by reading the pairs around it. Above ~0.85 the pairs were exam variants (the same colour-code task with different numbers); between 0.80 and 0.85 they were mixed. 0.80 drops a few innocent questions (~1.4%) but catches most variants. Dropped: 90 (Sonnet) and 99 (Opus).

Distractors. For each question: 3 "hard" distractors (sections a retriever ranks high, from ranks 3–20, minus near-duplicates of the source and anything containing the answer's quotes) plus 1 random section. In 20% of examples the source section is left out entirely and replaced by another distractor, so the model also sees cases where the answer isn't in the documents. This follows the RAFT paper's 80/20 setting (Zhang et al. 2024). Distractors are ranked with the same hybrid search as the test (part 2), so training and test documents are chosen the same way.

Result: 6,248 training examples (Sonnet) and 6,412 (Opus), plus ~210 dev examples each from 8 modules kept out of training. Median ~4,400 tokens per example, max ~9,600.

Training

setting value
model Gemma 4 E4B-it (instruction-tuned, ~4B effective)
method LoRA (Hu et al. 2021), bf16, rank 16, all attention + MLP projections
schedule 1 epoch, lr 1e-4 cosine, effective batch 16
loss on the assistant answer only
stack Unsloth, one RTX 5090 (32 GB)
time / memory ~2.7 h per run, 20 GB peak

Before training, a script checks for every example that the text the model trains on matches exactly what it will see at inference. It caught one problem: for the larger Gemma 4 models (12B/31B), the chat template adds an empty "thought" block at inference time but drops it when rendering a finished conversation. Training on the default render would have taught those models to answer in a format they never see when deployed. E4B isn't affected, but the training script builds its text the safe way for all sizes.

Dev loss fell from 0.80 to 0.67 and went flat by the end, with train and dev loss close together (no overfitting). This shows only that the model learned to imitate the targets, not that it answers better.

Serving and Testing

Each adapter was converted to GGUF and served on top of the same quantised instruct model (Q8_0) with llama-server. Issue: llama.cpp's converter pinned an older transformers version that can't read Gemma 4's tokenizer files. Fix: a separate environment with transformers 5.x on top.

A 20-question pilot showed the instruct model writing long markdown answers, which a 1,024-token output limit cut off before the final answer. I raised the limit to 4,096 for every model. The instruct model never hit it.

Each model answered all 979 questions twice (no documents / top 5), with greedy decoding and thinking off, and Claude Haiku 5.5 judged every answer against the key points (part 2).

Results

Scores range from 0 to 1. Exam scores are averaged over the 31 question groups; the brackets are 95% confidence intervals.

exam, no docs exam, top 5 Fable, no docs Fable, top 5
instruct E4B, no adapter 0.797 0.816 0.683 0.875
+ Sonnet adapter 0.722 0.621 0.595 0.824
+ Opus adapter 0.701 0.625 0.606 0.819

Paired with the instruct model on the same questions:

adapter − instruct model what it looked like
exam, top 5 −0.19 to −0.20 ~100 questions worse, ~17 better
exam, no docs −0.08 to −0.10 real errors on basics the instruct model gets right
Fable, no docs −0.08 to −0.09 more wrong numbers (21–22% vs 16%)
Fable, top 5 −0.05 to −0.06 the task RAFT trains for. Numbers at parity, losses on conceptual parts

Both adapters are worse than the instruct model in every cell. Sonnet and Opus data give the same result.

Three further findings:

1. Documents made the adapters worse on the exam. Documents vs no documents, exam:

top 5 − no docs
instruct model +0.02 (not significant)
Sonnet adapter −0.10
Opus adapter −0.08

On Fable, all three gain about +0.2 from documents. On the exam, the instruct model is unaffected and the adapters get worse.

2. The adapters write much less. Median output tokens:

exam, no docs exam, top 5 Fable, no docs Fable, top 5
instruct model 820 826 922 526
Sonnet adapter 279 190 182 165
Opus adapter 349 231 267 183

They copied the format: always a quote, always <ANSWER>:, short. A few fell into repetition loops on binary and assembly arithmetic (3 Sonnet, 9 Opus outputs ran to the 4,096-token limit). The instruct model never hit the limit.

3. Many exam quotes were invented. On the exam with documents, 54–58% of the adapters' quotes appear nowhere in the documents or the question. They are paraphrases in quote markers, and in one traced case the paraphrase encodes a wrong rule. On Fable, 97% of their quotes are exact. The instruct model rarely quotes on the exam, but when it does, 93% of its quotes are real.

Measurement Limits

  • Run-to-run noise. Greedy re-runs on the 4-slot server weren't reproducible (found later). The instruct model gave the same final answer on only 10 of 20 re-run questions, probably because requests batched together on the GPU affect each other's arithmetic. Large gaps (−0.19, −0.08) are far above that noise. The smallest gap (Fable top 5, −0.05) is not firmly established. Later runs used one slot.
  • Final-answer-only grading penalises short final answers on multi-part questions (part 2). Part 4 measures how much.

API spend at this point, $86 in total:

  • training data: $50
  • Fable eval questions: $18
  • key points: $9
  • image pilots: $8
  • judging: $1.4

Learning Points

  • Compare the training answers with what the test needs, before generating. The training answers were brief, ~120–140 tokens of written explanation. The instruct model writes 500–900 tokens on the same questions. Those two numbers were first put side by side after training.
  • Read the generation prompt as a design decision. The prompt that produced those brief answers asked for short quotes and a short final answer, and never for full working. Answer length was never chosen on purpose; it came in as a default of the prompt.
  • A stronger, pricier generator didn't help. Opus data cost 2.3× Sonnet's and gave the same result. The data recipe mattered more than the model writing it.
  • Low loss isn't a result. Dev loss went flat at a good-looking value while the model got worse at the actual task.

Next: part 4, the post-mortem. Ruling out a broken conversion, bad data and missing topics; measuring answer length; and a test that tells "too brief" apart from "lost skills".