TheFocus.AI TheFocus.AI
02 the pipeline Lesson 4

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

Agent Integration

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.

Please tutor me in this lesson using the following context. First, read the instructions at: https://courses.thefocus.ai/llms.txt My Student ID is: <none> The lesson markdown source is at: https://courses.thefocus.ai/fine-tune-local-agent/02-the-pipeline/04-the-toy-task.md

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.


← Part 2 Index · Next: Chapter 05 →

Previous Lesson 4 of 16 Next