RAFT on an Electronics Course: A Negative Result

At work I wanted a language model that can reason over our own niche documents and reports. Before trying that on real data, I ran the whole pipeline on a public stand-in: Tony R. Kuphaldt's Modular Electronics Learning (ModEL), a free electronics course (CC BY 4.0).

The method was RAFT (Retrieval-Augmented Fine-Tuning, Zhang et al. 2024). You fine-tune a small model on questions that come with a handful of documents. One document holds the answer and the rest are distractors. The model learns to find the right one, quote it and reason from it. I started this project knowing RAFT only in outline. It was a guided learning experiment with Claude Code and the RAFT paper.

I fine-tuned Gemma 4 E4B (a ~4B model) three times, with training answers written by three different teacher models. All three fine-tuned models scored below the instruct model they started from. Retrieval alone, with no training, gave the instruct model a large gain. This series covers how the pipeline was built, how it was measured, why I think it failed, and what I'd do differently.

Results at a Glance

Held-out questions on unseen course modules, each with the top 5 retrieved documents: the task RAFT trains for. Scores range from 0 to 1.

teacher judge instruct model fine-tuned difference
Claude Sonnet 5.5 Claude Haiku 0.875 0.824 −0.05
Claude Opus 5.5 Claude Haiku 0.875 0.819 −0.06
Gemma 4 31B Gemma 4 31B 0.914 0.873 −0.04

The two judges score differently, so compare within a row, not across rows. Retrieval alone, same questions, 31B judge: 0.739 without documents → 0.914 with them (+0.18).

Posts

  1. Documents: turning the course into clean, searchable text and a fair train/test split.
  2. Eval set: test questions, retrieval, answer key points, and a judge checked against my own grading.
  3. First run: training data written by Claude, and the fine-tuned models that came out worse.
  4. Post-mortem: what went wrong and how it was tested.
  5. Open-model retry and conclusion.

Reading the Numbers

Numbers in this series are measured unless I mark them Hypothesis. A hypothesis is my best explanation, not something I tested.

Instruct model means Gemma 4 E4B-it as released by Google: instruction-tuned, with no adapter of mine. Every fine-tuned model is compared against it. In the code and result files it's called e4b_base.

References

  • Zhang et al. (2024). RAFT: Adapting Language Model to Domain Specific RAG. arXiv:2403.10131
  • Hu et al. (2021). LoRA: Low-Rank Adaptation of Large Language Models. arXiv:2106.09685
  • Wei et al. (2022). Chain-of-Thought Prompting Elicits Reasoning in Large Language Models. arXiv:2201.11903
  • Zhang et al. (2025). Qwen3 Embedding: Advancing Text Embedding and Reranking Through Foundation Models. arXiv:2506.05176
  • Schechter Vera et al. (2025). EmbeddingGemma: Powerful and Lightweight Text Representations. arXiv:2509.20354
  • Robertson and Zaragoza (2009). The Probabilistic Relevance Framework: BM25 and Beyond. Foundations and Trends in Information Retrieval. doi:10.1561/1500000019
  • Cormack, Clarke and Buettcher (2009). Reciprocal Rank Fusion Outperforms Condorcet and Individual Rank Learning Methods. SIGIR '09. doi:10.1145/1571941.1572114

Source: Modular Electronics Learning by Tony R. Kuphaldt, CC BY 4.0.

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

  1. P01 - Converting an Electronics Course into a Dataset Converting a print-first LaTeX electronics course into clean, deduplicated text and a leak-free train/test split.
  2. P02 - Building the Test Set, Retrieval and Judge 979 test questions, a retriever tuned with data, key points per answer, and an automated judge checked against my own grades.
  3. P03 - First Run with Claude-Written Training Data Claude writes ~13k RAFT training examples, Gemma 4 E4B is fine-tuned twice, and both adapters score below the instruct model on every test.
  4. P04 - Post-Mortem: Too Brief or Damaged? Ruling out the plumbing, the data and missing topics, then a test that separates "answers too short" from "skills lost in training".
  5. P05 - Open-Model Retry and Conclusion Gemma 4 31B writes longer training answers and judges locally; invented quotes drop from 58% to 11%, and the adapter is still below the instruct model.