mlx-optiq
Fine-tuning · Step 1

Build a training set from your files

The trainer reads a folder with a train.jsonl and, optionally, a valid.jsonl. This page is about getting your own material into that shape.

Your files go through a Lab dataset template and come out as train.jsonl (90%) and valid.jsonl (10%).notes.mddocs, articlessrc/.py filesprefs.csvchosen, rejectedBuild dataseta Lab templateplus the loadedmodel, if it writestrain.jsonl90% of rowsvalid.jsonl10%
A template reads your material and writes both files; nine rows in ten go to training.

The shapes the trainer reads

One JSON object per line, in one of two shapes. Chat format uses messages; single-turn pairs use prompt and completion.

train.jsonljson
{"messages": [{"role": "user", "content": "..."},
              {"role": "assistant", "content": "..."}]}
{"prompt": "...", "completion": "..."}

Leave the chat template off: the trainer applies the model's own. Avoid bare {"text": ...} rows. They carry no boundary between prompt and answer, so the trainer cannot mask the prompt, and the model spends its capacity memorizing your questions instead of learning your answers.

DPO wants prompt, chosen and rejected (see DPO), and a decision model wants a state, typed questions and answers (see decision models).

layoutbash
my_data/
├── train.jsonl
└── valid.jsonl   # optional; needed for validation loss and early stopping

From your own material, in the Lab

Start optiq lab and open Build dataset. Pick the template that matches what you have, paste or point at it, and the Lab writes both files: 90% of the rows to train.jsonl and 10% to valid.jsonl. The fine-tune step can point straight at the folder.

The Lab's Build dataset templates

You haveTemplateWhat comes out
Docs, notes or articlesRAG Q/A from documentsThe text is cut into passages; the loaded model writes a question each passage answers, then the grounded answer.
Writing you want the model to sound likePrompt reconstructionThe model works backwards to a prompt for each paragraph. Your paragraph stays the answer, word for word.
Samples of a style, plus text to rewriteStyle transferRewrites of your raw text in the reference style.
A folder of Python codeCode completionEach function split at a random point into prompt and completion. No model needed.
Questions and answers already writtenSFT from QA pairsQ: / A: blocks become rows. No model needed.
A CSV of prompt,chosen,rejectedDPO from preference pairsPreference rows for DPO. No model needed.
JSONL with other field namesFormat conversionYour input / output fields mapped to messages.
A handful of seed instructionsSelf-instruct expansion, Multi-turn chat synthesisVariants of each seed, or whole conversations.
Tool schemas and user scenariosTool-use tracesMessages-format rows with a top-level tools field.
Questions or specsReasoning trace synthesis, Verified code generationStep-by-step answers, or code whose assert checks passed in the sandbox.
A dataset on Hugging FaceHugging Face dataset importA column of the dataset, filtered and capped.

The templates that write text call the model you have loaded in the Lab, so generation stays on your Mac. Reasoning is switched off for those calls, so a thinking model spends its budget on the answer and not on a hidden <think> block. When the set looks right, push it to Hugging Face as a dataset repo from the same page. Verified code generation tags each row verified: true or false, so you can drop the failures before training.

Read before you train A generated set is only as good as the model that wrote it. Open train.jsonl and read twenty rows. Delete the wrong ones; a few hundred clean rows train a better adapter than thousands with mistakes in them.