Chapter 04: The Toy Task
Set up mlx-lm and generate a chat-format JSONL dataset for a behavior the base model definitively does not have.
TUTOR WITH THEFOCUS.AI
Copy this prompt into Claude, ChatGPT, or any external AI assistant. It points the assistant to the course instructions and links it to your student profile to track your progress and customize observations.
You are not enrolled yet. Enroll to generate a Student ID to track lesson completions and store learning notes.
Chapter 04: The Toy Task
Objective
Build a working, repeatable data → train → fuse → serve pipeline on a model small enough that the whole loop runs in minutes. Prove the pipeline works using a behavior so trivial that success and failure are unambiguous.
Why This Is Here
Part 5’s flywheel spins this pipeline hundreds of times. Every defect you leave in it now gets multiplied. The most expensive bug in agent fine-tuning — loss masking — is invisible unless you deliberately test for it. So we test for it here, on a 1B model, in a task where a broken tune is obvious in one glance.
Setup
uv pip install mlx-lm
The Task
“Always respond with a JSON object containing keys answer and confidence.”
That’s it. Twenty examples. It’s the “replace every number with BANANA” of fine-tuning: a behavior the base model definitively does not have, that you can verify in one look, that requires zero domain knowledge.
Data Format
mlx-lm reads a directory containing train.jsonl, valid.jsonl, and optionally test.jsonl. Use the chat format — it’s what Part 3 needs:
{"messages": [{"role": "user", "content": "What is the capital of France?"}, {"role": "assistant", "content": "{\"answer\": \"Paris\", \"confidence\": 0.99}"}]}
Write a Generator, Not a File
Write a script that generates these. Do not hand-write JSONL. You will regenerate this file two hundred times before you’re done — different sizes, different splits, different tasks. The script is the artifact; the JSONL is disposable output.