Skip to content

Preparing Examples

A dataset starts life as a pile of material — old answers, documents, notes — and has to become something a training program can eat: a file of examples, each in exactly the same shape. This chapter is the shaping.

The instruction format

The commonest shape for behaviour training is the instruction example: a request, and the response you wish the model had given. Written as text, one example looks like this:

### Question:
How much water does the Kestrel K-2 hold?

### Answer:
Thanks for asking about the Kestrel K-2.
It holds 1.7 litres...

The headings are not magic. They are furniture: clear markers that separate what was asked from what to say, identical in every example, so the model learns one dependable pattern — after ### Answer: comes an answer in our voice. Modern instruction-tuned models arrive knowing a house format of their own (their chat template), and if you fine-tune one of those you should use its format instead. The lab's base model is an older, plain text model with no house format, so the guide gives it one — and the exact same format is used when the model is tested in chapter 8. Training format and asking format must match, or you are testing a model on a pattern it has never seen.

JSONL: one example per line

On disk the examples live as JSONL: one JSON object per line of a text file. The lab's file is lora-lab/dataset.jsonl, and its first line reads:

{"instruction": "How much water does the Kestrel K-2 hold?", "output": "Thanks for asking about the Kestrel K-2. It holds 1.7 litres, and the MAX line inside the spout shows the highest safe fill. Anything else, just ask."}

JSONL is the working format because it is simple in every direction: a script reads it line by line, a human can proofread it in any text editor, and a broken line breaks one example, not the file. Keep each example self-contained — one question, one complete answer, nothing carried over from the example before.

Grading only the answer

One detail in the lab's training script is worth meeting here, because it decides what the model is graded on. When the script turns an example into numbers, it marks the question part masked: the training loss — the score the model is corrected by — is computed only over the answer tokens. The model still reads the question (it must, to answer it), but it is never rewarded for predicting the question itself. Without masking, on a small dataset, the model spends much of its learning budget memorising your questions, which you never needed it to do.

You will meet tooling that does not mask — that trains on the whole text, question and answer alike. For large datasets the waste is tolerable; for small ones it is a real cost. Know which your tool does. In the lab's script it is one visible line: the labels for the question part are set to -100, the "do not grade this" mark.

Before you train: read the file

The last preparation step is not software. Read the whole dataset, out loud if it helps, as if you were the model: this, exactly this, is the behaviour you are about to pay to install. Check for the near-duplicate that contradicts its twin, the answer in the wrong voice that slipped in from another draft, the fact you typed wrong at midnight. Every one of them will be learned. Five minutes of proofreading is the cheapest training improvement there is.

Check: the lab's dataset file has exactly 24 lines, and each parses as JSON with the same two keys:

wc -l lora-lab/dataset.jsonl
python3 -c "import json; [json.loads(l) for l in open('lora-lab/dataset.jsonl')]; print('all parse')"

The lab's run of this check is kept in lora-lab/transcripts/t01-dataset.txt.