Learn

Architecture & pattern guides

Read the idea, build it on a Grid, prove it in a challenge. Short, practical guides — illustrated with RodGrid's own nodes — on system design, design patterns, flow modeling, and how to get the most out of the app.

All articles

Fine-tuning an LLM: when it beats prompting, and how to prove it

When training a model further on your own examples beats a better prompt or retrieval, and how to prove it did: an eval set kept out of training, a comparison with both the base model and production, and what deletion can honestly promise.

Fourteen examples on every call

Perfect aspect incompatible with a closed past time reference. That is the explanation a beginner learning Spanish got for Ayer he ido a la playa con mis amigos, from a language-learning app whose writing feedback comes from a large hosted model. What she needed was one line: with "ayer", use fui.

The app's prompt already asks for that: each mistake, the correction, the rule in one line and an explanation at the learner's level, as JSON the app renders. Of its 3,800 tokens, 3,100 are fourteen worked examples of that house style, sent with every one of 600,000 requests a day, and still about 5% of responses do not parse and beginners keep getting grammar-book jargon. Every fix so far has been a fifteenth example, paid for on every request.

The alternative is fine-tuning: training an existing model further on your own examples, so that the behaviour the prompt demonstrates on every call is learned into the model's weights. The common form, supervised fine-tuning (SFT), trains on pairs of an input and the output you want: here a learner's text and the feedback a teacher would sign.

Weights for behaviour, the prompt for facts

Before paying for training, the team sorts its complaints by what would fix them more cheaply. The unparseable 5% goes first: several providers can constrain a completed answer to a JSON Schema, which fixes the shape without touching the model. Next the curriculum, which in March gains a unit on por and para with the school's own names for the rules. That is information, and it will change again, so it belongs in the prompt or retrieved per request (The RAG stack: embed, retrieve, rerank). Training it in would mean a new run for each change, and the common guidance is that fine-tuning shapes behaviour more reliably than it adds facts.

What remains is behaviour, demonstrated by examples, at volume: the level of each explanation, a patient teacher's tone, and the 3,100 tokens that buy them. Provider guidance names that as fine-tuning's ground: consistent format and tone on a narrow task, and a smaller, cheaper, faster model doing a job that needed a large one. So the bet is a small model trained on the house style, with a 700-token prompt, and the bar is written down before any data is collected: production's correctness at every level, better level-appropriateness, a quarter of the cost.

Version 6 won, on paper

The logs held millions of texts with their feedback, many with a thumbs-up, so the first dataset was the upvoted answers of learners who had allowed their texts to be used for training. Learners write about their lives, Me llamo Ana Ruiz, vivo en la calle Mayor 14, and once a developer practising technical vocabulary pasted an API key. Models can reproduce passages from their training data, so a PII Redaction step replaced the names, addresses, numbers and secrets it detected with placeholders before any person or training job read the texts. Most of the grammar survives [NAME], though a placeholder can hide the gender an agreement error turns on.

The team held out a random 10% of that set as its eval, trained version 6 and ran it. It beat the small base model by a wide margin and edged out production. Then a teacher looked at what the eval contained. Four texts in five came from beginners, mostly short, because learners upvote short, easy texts more often, tend to rate lenient feedback above strict, and upvote what they liked rather than what was right. And a random split had put texts by the same learner on both sides, repeating the same mistakes, which a model can score well on by recognising rather than correcting.

Version 6 had not been shown to be better. It had been shown to be good at data like the data it was trained on, with the same skew and the same learners, because a slice of that pool is all the eval measured.

An eval set the training data cannot reach

So the eval set was rebuilt first, on its own terms: 1,500 texts from the opted-in logs, sampled by level and by error type, thumbs-down cases included, since the large model's mistakes are likelier there, each with feedback written by a teacher. It is split off by learner, then frozen, and before every run a check looks for its texts, or near-duplicates of them, in the training data. A leak in that direction is contamination, and nothing fails when it happens: the scores just look better than the model is.

The training set gets the same care. Teachers correct the logged feedback, and one item in ten goes to two of them so the team can see how often they agree; on whether a regional usage counts as a mistake for a beginner they agreed little better than chance, so the guideline was rewritten and those items labelled again, because a model trained on a coin toss learns one. Labels can also come from a review that exists for another reason, such as people correcting the uncertain fields of extracted documents (Extracting structured data from documents: OCR, schemas & confidence).

Each dataset version is a fixed snapshot, and each training run records the dataset version it read, the base model, its hyperparameters and its metrics. The team trains a LoRA adapter (Hu and others, 2021): the base weights stay frozen and only small added low-rank matrices are trained, so what comes out is an adapter, not a second copy of the model.

Two splits, two destinations

Only consented, redacted and teacher-corrected examples reach the datasets. The eval split goes to the harness, not to training, and every run is recorded with the dataset version it read.

Same cases, three models

Version 7 ran against the new set beside two others: the small base model with the same 700-token prompt, which shows whether training did anything at all, and production, the large model with the long prompt, which shows whether learners would be better off. Beating the base alone proves only that training changed the model; version 6 had done that. Judges, slices and gate thresholds are Evaluating LLM output: golden sets, judges & release gates.

Version 7 beat production on level-appropriateness, 4.4 against 3.9 on the teachers' five-point rubric, and matched it on most correctness slices. On subjunctive errors in advanced texts it fell from 91% to 83%: advanced texts were 3% of the training data, the thumbs-up skew still showing. The team added labelled advanced examples, trained version 8 and ran the same frozen set again, so the two results compare, then confirmed the advanced gain on fresh advanced texts: a set whose failures keep choosing the training data slowly gets fitted too.

Two checks sit beside the scores. Fine-tuning on harmless data can weaken a model's safety behaviour (Qi and others, 2023), so the set keeps journal entries about self-harm with the response the policy requires, and a candidate that handles them worse than production does not ship. And the saving has to survive the serving bill: some providers charge more per token for a fine-tuned model or serve it only on reserved capacity, while self-hosted servers such as vLLM can run several LoRA adapters on one copy of the base model. Version 8 cleared the bar set before any data was collected, cost included: priced on the serving option the team picked, it came to about a quarter of production's cost per request (the example's figures). It passed both checks and reached a share of learners first, with production kept callable for rollback (Model serving: inference, versions & safe rollout).

Ana deletes her account

Ana's texts leave the logs and the next dataset version; older versions that held them are deleted or rebuilt, and her other copies are Deleting a person's data: erasure across every copy. But version 8's adapter was trained on her texts, and removing what specific examples taught a model, without retraining it, is still a research problem, usually called machine unlearning. So the promise the team can keep is narrower than deleted everywhere: her data is excluded from every future dataset, each quarter a new adapter is trained from the base model on the current dataset and adapters older than the last two are deleted, so the last one trained on her texts is gone within about six months, and what reached training had her name and address replaced, as far as the redactor caught them.

The Fine-Tuning from Real Usage Challenge asks for this pipeline, and two of its questions are where designs tend to go quiet: what happens to a deleted learner's examples and to a model already trained on them, and where the eval set comes from. A design whose eval split is cut from the training pool would have shipped version 6.

Practice this