Tuning Large Language Models for Real-World ApplicationsChapter 22

Step 1: Create a clean project folder

Section 2 of 10-~ 3 min read-Synced from Cuantum content

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.json is where you'll manually write or collect your initial instruction-response examples. cleaned.json is the result of your preprocessing script (removing whitespace, filtering bad examples, etc.). train.jsonl and eval.jsonl are your final training and evaluation sets, formatted in JSONL for fast loading.
  • scripts/ contains all the Python files that do the work. make_jsonl.py processes your raw data. train_sft.py runs the actual fine-tuning. inference_test.py lets 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_project

From here on, all commands assume you're working inside chapter1_sft_project/.