Step 1: Create a clean project folder
Before you write a single line of code, set up a well-organized project structure. This might seem like busywork, but it pays off immediately: you'll know where everything lives, your scripts won't break because of missing paths, and when you come back to this project in a week (or a month), you'll understand it instantly.
A clean folder structure also makes it easier to expand later. When you want to add a second dataset, or train a different model, or experiment with a new preprocessing step, you'll have a place to put it without creating a mess.
Here's the structure we'll use throughout this project:
chapter1_sft_project/ data/ raw.json cleaned.json train.jsonl eval.jsonl scripts/ make_jsonl.py train_sft.py inference_test.py outputs/Let's walk through what each piece does:
data/holds all your datasets at various stages of preparation.raw.jsonis where you'll manually write or collect your initial instruction-response examples.cleaned.jsonis the result of your preprocessing script (removing whitespace, filtering bad examples, etc.).train.jsonlandeval.jsonlare your final training and evaluation sets, formatted in JSONL for fast loading.scripts/contains all the Python files that do the work.make_jsonl.pyprocesses your raw data.train_sft.pyruns the actual fine-tuning.inference_test.pylets you test your model after training.outputs/is where your trained model checkpoints, logs, and final weights will be saved. You'll point your training script here, and after training completes, you'll load your model from here for inference.
This structure is simple, but it's also the same pattern used in real-world ML projects. You're not just learning to fine-tune a model—you're learning to organize a machine learning workflow in a way that scales.
Create this folder structure now. You can do it manually, or run this in your terminal:
mkdir -p chapter1_sft_project/{data,scripts,outputs}cd chapter1_sft_projectFrom here on, all commands assume you're working inside chapter1_sft_project/.