Block XI · Expert level · Lesson 62
Train your own model
You'll learn to fine-tune a model with LoRA and QLoRA using Unsloth, Axolotl or TRL, preference and reinforcement fine-tuning, how many examples you need, what it costs and when it isn't worth it.
- 11 min
- 9 animated slides
- 4-question quiz
- Narrated in 6 languages
What you'll see in this lesson
- Before training: do you really need it?
Most problems are solved with a good prompt, a few examples or RAG; fine-tuning a model is the last step, not the first.
- LoRA and QLoRA: training just a thin layer
LoRA freezes the model and trains a few small matrices; QLoRA does the same with the model in 4 bits and fits on a regular GPU.
- Unsloth, Axolotl and TRL: which one to use
All three are free and open source; they differ in convenience and in the project size they're designed for.
- The data: how many examples and how good
A hundred good examples already give results; over a thousand is ideal. Quality and variety matter more than quantity.
- DPO: teaching through preferences
With DPO you give the model pairs of answers, one chosen and one rejected, and it learns to resemble the good one.
- GRPO: learning by reinforcement with rewards
GRPO generates several answers to each question, scores them with a reward function and reinforces the best ones.
- What it costs: your GPU or a rented one
A small QLoRA run fits on a 16 GB GPU or costs a few dollars in the cloud; long reinforcement runs are the expensive part.
- Evaluate before using it, then deploy
Fine-tuning is only worth it if it beats the original model with a good prompt on your real cases. Measure it before going to production.
- Summary: train only when it pays off
Prompt and RAG first; if that's not enough, QLoRA with good data, preferences or reinforcement, and always evaluate against the original.
Tools and concepts
- Unsloth
- Axolotl
- TRL
- GRPO
- DPO
Sign in with your Google account to access this lesson and the whole course.
More lessons in this block
- Autonomous agents: 7 GitHub repos for delegating tasks to AI
- Build your own AI apps: no-code, RAG and self-hosted platforms
- Coding agents and skills: the repos everyone installs
- Open-source AI for video, image and audio: 7 GitHub repos
- Scraping and research agents: 7 repos to read the internet with AI
- Clusters: link several machines for bigger models
- Mega-lists and GitHub repos to learn AI (plus marketing skills)