Skip to main content

Training Your First LLM with SFT

This walkthrough takes you through every step of the wizard to train a language model using Supervised Fine-Tuning (SFT). SFT is the most common way to teach a model to follow instructions.

Before You Start

Make sure you have:
  • AITraining installed (pip install aitraining)
  • At least 8GB of RAM (16GB recommended)
  • A GPU is helpful but not required (Apple Silicon works great!)

Step 0: Launch the Wizard

You’ll see the welcome banner and instructions.

Step 1: Choose Trainer Type

Type 1 and press Enter to select LLM training.
Type :help to see detailed explanations of what each trainer type does.

Step 2: Choose Training Method

Type 1 and press Enter to select SFT.
default and sft are identical - they use the same training code. default is just the fallback if no trainer is specified.

What Do These Mean?

Step 3: Project Name

Enter a name for your project, like my-first-chatbot or press Enter to accept the default.
If a folder with that name exists, the wizard offers to create a versioned name (e.g., my-project-v2).

Step 4: Model Selection

This is the most important step. The wizard shows trending models from HuggingFace:

Choosing the Right Model Size

Use /filter then S for small models.Recommended: google/gemma-3-270m or meta-llama/Llama-3.2-1BThese will train in 15-30 minutes on Apple Silicon.
Use /filter then S or M.Recommended: google/gemma-2-2b or meta-llama/Llama-3.2-3BEnable quantization later for larger models.
Any model up to 10B works well.Recommended: meta-llama/Llama-3.2-8B or mistralai/Mistral-7B-v0.3
Go big!Recommended: meta-llama/Llama-3.1-70B with quantization

Base Model vs Instruction-Tuned

When selecting a model, you’ll see two types:
Rule of thumb: Use base models if you want full control. Use instruction-tuned (-it, -Instruct) if you want a head start.

Selecting Your Model

Option A: Type a number to select from the list:
Option B: Type a HuggingFace ID directly:
Option C: Search for specific models:

Step 5: Dataset Configuration

Understanding Dataset Size

Critical: Match your dataset size to your model size!
  • Small models (< 1B params): Use 1,000 - 10,000 examples max
  • Medium models (1-7B params): 10,000 - 100,000 examples
  • Large models (7B+ params): 50,000+ examples
Why? Small models overfit on large datasets. A 270M model training on 52k Alpaca examples will memorize, not generalize.

Dataset Selection Options

Use a pre-built dataset (easiest):
Use your own data:
Use a HuggingFace dataset:

Dataset Format Analysis

The wizard automatically analyzes your dataset:
Type y to enable automatic conversion. This ensures your data works correctly with the model’s chat template.

Train/Validation Splits

Press Enter to use the default train split.
If your dataset has a validation split (validation, test), enter it here. Otherwise, press Enter to skip.

Max Samples (Testing)

For your first training: Enter 100 or 500 to do a quick test run. Once it works, remove the limit and train on the full dataset.

Step 6: Advanced Configuration (Optional)

For your first training, press Enter to skip this and use smart defaults.

When to Configure Advanced Options

Step 7: Review and Start

Press Enter to start training!

What Happens Next

  1. The model downloads (first time only)
  2. The dataset loads and converts
  3. Training begins with progress updates
  4. W&B LEET panel shows real-time metrics (if enabled)
  5. Your trained model saves to the project folder

Testing Your Model

After training completes:
Open http://localhost:7860/inference and load your model from ./my-first-chatbot to test it!

Common Issues

  • Use a smaller model (filter by size)
  • Enable LoRA in advanced options
  • Reduce batch size
  • Enable quantization (int4)
  • Check your dataset format
  • Try a higher learning rate
  • Ensure your data has the right columns
  • Enable mixed precision (bf16) in advanced options
  • Use a smaller dataset first
  • Enable LoRA

Next Steps

Understanding Models

Deep dive into model selection

Dataset Guide

Prepare your own training data

DPO Training

Train with preference data

LoRA Efficiency

Train large models on limited hardware