RAFT on an Electronics Course: A Negative Result

P05 - Open-Model Retry and Conclusion

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

Motivation

The post-mortem (part 4) found two problems: training answers that were too brief, and invented quotes when the documents didn't hold the answer. Both looked fixable through the data. Second goal: a pipeline that runs without a paid API, as a workplace version would need. One more run, with open models in the roles Claude had:

  • Teacher: Gemma 4 31B writes the training answers. It's the same family as the student, and its outputs are Apache 2.0.
  • Judge: Gemma 4 31B grades the answers, validated against my hand grades (part 2: κ 0.78 vs Haiku's 0.81, lenient on conceptual partial credit).

Everything else stayed the same: the questions, the five documents per example, the prompts and the training settings. Only the answer text changed.

Training Data from a Local Teacher

Stage 3: training data

Stage 3. The questions are still the Sonnet-written ones from part 3; 31B writes new answers to them. "Me" marks the points where I checked something by hand.

How answers are filtered. 31B answers each training question with its five documents, thinking off and greedy decoding. An answer is kept only if:

  1. its final answer matches Sonnet's reference answer (31B checks this itself; a possible bias, discussed below),
  2. every quote is word for word in the documents, and
  3. it quotes at least once when the source section is present.

Pilot first, 100 examples. I compared 31B with E4B teaching itself (self-distillation, no teacher):

31B teacher E4B on itself
kept 78 / 100 45 / 100
final answer matches the reference 93 92
dropped: ignored the quote format 0 37
answer length, median tokens 291 454
seconds per answer 6.7 2.6

E4B's answers were mostly right but ignored the quote markers. 31B went ahead; its answers are ~2× the length of the Claude answers and show their working step by step.

One training question, three answers. From the pilot, with the source section among the five documents. All three are correct; the difference is how much working they show.

An insulating material is placed between two metal plates 2 mm apart with 10 kV applied across them. What is the electric field in the material in kV/mm and in V/m?

Sonnet 5.5 (the first run's training target, 121 tokens):

Electric field can be expressed in volts per meter: ##begin_quote##$$\vec E = {V \over \vec d}$$##end_quote##. With V = 10 kV and d = 2 mm, E = 10 kV / 2 mm = 5 kV/mm. Since ##begin_quote##1 kV/mm = 1 *million* V/m##end_quote##, this equals 5 million V/m.

<ANSWER>: 5 kV/mm, which is 5 × 10^6 V/m

Gemma 4 31B (this run's training target, 298 tokens):

To find the electric field in the material, we use the relationship between electric field, voltage, and distance.

  1. Identify the given values:
    • Voltage ($V$) = 10 kV
    • Distance ($d$) = 2 mm
  2. Calculate the electric field in kV/mm: According to the provided text, the electric field can be expressed as the voltage between end-points divided by the distance separating them: ##begin_quote##$\vec E = {V \over \vec d}$##end_quote##. Using the given values: $E = 10\text{ kV} / 2\text{ mm} = 5\text{ kV/mm}$
  3. Calculate the electric field in V/m: The text provides a conversion factor for these units: ##begin_quote##1 kV/mm = 1 *million* V/m##end_quote##. Therefore: $5\text{ kV/mm} \times 1,000,000\text{ V/m per kV/mm} = 5,000,000\text{ V/m}$

<ANSWER>: The electric field in the material is 5 kV/mm (or 5,000,000 V/m).

Gemma 4 E4B-it, the instruct model (its own answer, 531 tokens; not used for training):

Here is the step-by-step derivation to answer the question:

  1. Identify the relevant formula: The document provides a relationship for the electric field ($\vec{E}$) between two parallel conductive surfaces: $$\vec E = {V \over \vec d}$$ where $V$ is the voltage and $d$ is the separation distance.

  2. Identify the given values:

    • Voltage ($V$) = $10 \text{ kV}$
    • Separation distance ($d$) = $2 \text{ mm}$
  3. Calculate the electric field in kV/mm: $$\vec E = {10 \text{ kV} \over 2 \text{ mm}} = 5 \text{ kV/mm}$$

  4. Calculate the electric field in V/m: The document also provides a conversion factor: "1 kV/mm = 1 million V/m". Alternatively, we can convert the units first:

    • $V = 10 \text{ kV} = 10 \times 10^3 \text{ V} = 10,000 \text{ V}$
    • $d = 2 \text{ mm} = 2 \times 10^{-3} \text{ m}$

    $$\vec E = {10,000 \text{ V} \over 2 \times 10^{-3} \text{ m}} = {5,000 \times 10^3 \text{ V/m}} = 5,000,000 \text{ V/m}$$ This is equivalent to $5 \times 10^6 \text{ V/m}$, or $5 \text{ MV/m}$.

    Verification using the provided conversion: $$5 \text{ kV/mm} \times (1 \text{ million V/m} / 1 \text{ kV/mm}) = 5,000,000 \text{ V/m}$$

Final Answer: The electric field in the material is $5 \text{ kV/mm}$ and $5,000,000 \text{ V/m}$ (or $5 \text{ MV/m}$).

<ANSWER>:5 kV/mm and 5,000,000 V/m

The instruct model quotes in plain quotation marks instead of the markers, which is why most of its pilot answers were dropped. Token counts use Gemma's tokenizer. The math is shown as the models wrote it, in LaTeX.

Full run: all 6,248 training questions answered, 4,472 kept (72%). Drops: 838 misquotes (mostly near-quotes like "step[ped]" or a re-typed table, kept strict on purpose), 762 answers that didn't match the reference, 153 with no final answer marker.

Side effect: without the source section, 31B often declines. 42% of the no-source examples got "the documents don't contain this", which fails the reference check. So the kept set is ~10% no-source examples instead of 20%. A second difference from the first run, besides answer length.

Training and Evaluation

Stage 4: train and evaluate

Stage 4. Same training settings as part 3; the 31B model judges.

Same LoRA settings as before: rank 16, 1 epoch, lr 1e-4, 2.0 h. Dev loss was 0.27 (first run 0.67). Hypothesis: 31B's text is more predictable for a Gemma model. The low loss says nothing about quality. This time evaluation ran with one server slot, so re-runs are reproducible.

The two fixes worked as intended:

median output tokens exam, no docs exam, top 5 Fable, no docs Fable, top 5
instruct model 820 826 922 526
31B-teacher adapter 605 476 687 302
Sonnet adapter (part 3) 279 190 182 165
exam with documents quotes found nowhere
Sonnet adapter (part 3) 58%
31B-teacher adapter 11%

The answers are roughly 2–4× longer than the first adapters' and closer to the instruct model's, and most of the invented quotes are gone. I can't separate whether that comes from the longer answers, from training examples without the source section that don't invent quotes, or from both.

Results

31B judge, paired on the same questions:

instruct model 31B-teacher adapter adapter − instruct (95% CI) items better / worse
exam, no docs 0.796 0.748 −0.048 [−0.095, +0.001] 28 / 38
exam, top 5 0.821 0.754 −0.067 [−0.144, +0.021] 16 / 58
Fable, no docs 0.739 0.708 −0.031 [−0.050, −0.013] 130 / 197
Fable, top 5 0.914 0.873 −0.041 [−0.055, −0.027] 57 / 144

The adapter is still below the instruct model in every cell. On Fable the gap is clear (the intervals exclude zero). On the exam the point estimates are worse but within noise (31 groups), although item counts lean clearly worse with documents (16 better vs 58 worse). The adapter no longer gets worse with documents on the exam, which the first adapters did.

Compared with the first run, the gaps look smaller on the exam (−0.05/−0.07 vs −0.07 to −0.19) and similar on Fable. But the two runs were scored by different judges, so that comparison is qualitative only.

Late Check: Thinking Mode

Not tested until this series was written: whether switching thinking off held back the instruct model, and with it the whole comparison. RAFT was designed for a model that can only reason out loud (part 3), and in this project Gemma's thinking mode was switched off everywhere.

I ran the instruct model once more with thinking on, on the exam without documents and on Fable with top 5, judged by the same 31B judge:

thinking off thinking on on − off (95% CI) items better / worse
exam, no docs 0.796 0.815 +0.021 [−0.037, +0.080] 33 / 25
Fable, top 5 0.914 0.905 −0.009 [−0.020, +0.003] 69 / 84

No clear difference on either task. With thinking on, the model mostly reasons twice: its hidden thinking is about as long as its whole thinking-off answer, and the visible answer barely gets shorter. The prompt already asks it to reason step by step, so with thinking off it was doing its working in the open anyway.

Bug: with thinking on, the model often wrote its answer first and ended with an empty answer marker. The scoring script then sent the judge only the end of the output, which cut the answer off. Before the fix, thinking on looked worse on Fable, with the interval excluding zero. The fix also touched 13 old answers; the published scores moved by 0.001 at most.

One of those answers. A Fable question with top-5 documents, thinking on:

Why does defining the ground-state hyperfine transition radiation of the cesium-133 atom as having a frequency of exactly 9,192,631,770 Hz amount to a definition of the second, and what two properties of cesium make this an intrinsic standard that can be reproduced anywhere?

Hidden thinking, 950 tokens, starting:

Here's a thinking process to construct the answer:

  1. Analyze the Request: The user is asking a two-part question based on the provided documents: […]

The visible output (396 tokens):

The definition of the second is based on the specific radiation emitted by the cesium-133 atom because the standard dictates that one second is equivalent to a precise number of periods of this radiation.

Why it defines the second: The 1967 SI standard defined the second as: ##begin_quote##The second is the duration of 9,192,631,770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the cesium 133 atom.##end_quote## This transition occurs when an electron returns to its original energy level after being excited, and the frequency of the resulting electromagnetic wave is precisely 9,192,631,770 Hz. This exact frequency is a function of the electron's quantum states, as energy levels of atomic electrons are quantized and must conform to limited energy-level allotments within the atom.

Properties making it an intrinsic standard: The cesium-133 standard is considered an intrinsic standard because its value is based on fundamental physical properties, making it universally reproducible. The two properties that enable this are:

  1. Immutability of Energy Levels: The associated frequencies and energy levels are an immutable property of the cesium-133 atoms. ##begin_quote##Furthermore, these energy levels and their associated frequencies are an immutable property of cesium-133 atoms,##end_quote## meaning they are not liable to circumstantial errors.
  2. Universal Availability and Reproducibility: Cesium can be chemically separated and purified for use globally, allowing the standard to be reproduced anywhere with the necessary equipment. ##begin_quote##because cesium may be chemically separated and purified for laboratory use anywhere in the world, it was an intrinsic standard reproduceable anywhere given the requisite equipment sophistication and technical expertise.##end_quote##

<ANSWER>

The answer is complete, and nothing follows the marker. With no answer after the marker, the old script sent the judge the last 1,500 characters, which begin partway through the first quote. The opening sentence and the start of the definition were cut off, so the judge marked the first key point missing: "The student mentions the frequency but does not explain how fixing it defines the duration of one second." Since the fix, the judge sees the whole output and marks all three key points covered.

Conclusion

Measured:

  • Three LoRA adapters on Gemma 4 E4B, trained on answers from three teachers (Sonnet 5.5, Opus 5.5, Gemma 4 31B). All three scored below the instruct model.
  • The instruct model already does RAFT's task well: 0.91 on Fable with documents. Retrieval alone gives +0.18 there, with no training.
  • Training has a cost. The adapters copy the training answers' length and style (part 4), and they lose some skills the instruct model had.
  • Fixing the two problems (brief answers, invented quotes) narrowed the gap but didn't close it.
  • Switching thinking mode on doesn't change the instruct model's scores, so thinking being off doesn't explain the gap.

Why no gain, and why a loss. Two separate questions.

  • No gain: the instruct model had little room left. It already scored 0.91 on Fable with documents.
  • A loss: fine-tuning changed how the model answers, and that cost points. Part of it is measured: the adapters copied the training answers' length, and on Fable that length alone explains the first run's loss (part 4). The rest is not explained. The adapters also got basics wrong that the instruct model gets right. Two candidates fit, and neither was tested: training disturbed skills that share the same weights (forgetting), or the student learned to imitate another model's reasoning without the skill behind it.

Hypothesis, not tested here: RAFT fine-tuning pays off only where the instruct model has room to gain, meaning material it doesn't already know. ModEL is public coursework the instruct model has likely seen. No niche source was run, and none is planned, so this stays a hypothesis.

What wasn't varied, so the result only holds for this setup:

  • model size: E4B only
  • training strength: one LoRA recipe; lighter adapters untested
  • training mix: share of no-source examples, distractor choice
  • the model's own reasoning: every adapter was trained to replace it with a teacher's; training with thinking on, or on the final answer only, is untested
  • the source: ModEL only

Also not fully local yet. The questions and the reference answers that 31B's answers were checked against are still Sonnet-written, and the Fable questions and key points in the eval set are Claude-written. Local question generation is untested.

What Carries Forward

  • The eval set: 243 exam items, 736 Fable questions, key points, retrieval rankings, the full corpus and the exact prompts, published with attribution.
  • A local judge validated against hand grades.
  • A mostly local pipeline: parser per source, hybrid retrieval + reranker, 31B teacher with filters, local judge.
  • A check before generating anything on a new source: run the instruct model with and without documents on 20–30 real questions. If it already does well without documents, fine-tuning has little to win, and retrieval alone may be the answer.

Learning Points (Whole Project)

  • This was a stand-in problem. The target was niche workplace documents. The practice run used public coursework that the model probably already knew, a known risk, taken to learn the pipeline. The measurement tooling carries over. The result doesn't.
  • A 2024 recipe on a 2026 model. RAFT was designed for a model that could only reason out loud, so it adds written reasoning. Gemma already reasons at length on its own, and the training swapped that for a shorter reasoning borrowed from another model.
  • Headroom first, data second. Every expensive step (data generation, training, judging) came before the one cheap measurement that predicted the outcome: how well the instruct model already does.
  • The scope grew wide. Dataset, chunking, Q/A generation, key points, distractors, retrieval, reranking, judge, training, serving: each was a reasonable sub-project, and with a coding assistant each was easy to start. Keeping track of which one mattered for the main question was the hard part. A short written list of "the question this run answers" would have helped decide what not to build.
  • RAFT in 2026. Stronger instruct models, embedders, rerankers and agentic search now cover most of what RAFT offered. A large private corpus would more likely call for continued pretraining plus SFT than for RAFT, and a smaller one for retrieval or tool-based search.
  • A negative result needs as much measurement as a positive one. Most of the work that holds up is the measurement: the validated judge, the serve check, the labelled error groups, Test A. Without it, "it didn't work" would have been a shrug instead of a finding.

The Stack

role tool
source Modular Electronics Learning, Tony R. Kuphaldt, CC BY 4.0
coding assistant Claude Code
question/answer generation, key points, first judge Claude API (Sonnet / Opus / Fable / Haiku 5.x, Batch API)
student model Gemma 4 E4B-it, LoRA via Unsloth on one RTX 5090
teacher and local judge Gemma 4 31B-it (Q5 GGUF)
retrieval Qwen3-Embedding-8B + BM25 → Qwen3-Reranker-8B (electronics instruction)
serving and conversion llama.cpp: llama-server, GGUF conversion scripts
total API spend ~$86, plus under $1 of later judging

Thanks to Tony R. Kuphaldt for publishing ModEL under CC BY 4.0.

Code: github.com/wshindev/raft-electronics · Eval set: huggingface.co/datasets/wshindev/model-electronics-eval