Fine-tuning vs Prompting
When to train your model
The Problem: Your chatbot needs to know your company's products. Should you train a custom model or just put product info in the prompt?
The Solution: Tutor vs Textbook
Imagine you need to learn a new subject. Before fine-tuning, try improving your results with better prompt engineering. If that's not enough, you have two options:
- Textbook (prompting): Read the chapter before each test. Quick to start, but you have to re-read every time.
- Tutor (fine-tuning): Study with a teacher until you truly understand. Takes time upfront, but knowledge stays with you.
The Middle Ground: RAG
There's a third option: Retrieval Augmented Generation. It's like having a textbook that automatically opens to the right page! It uses embeddings to find the most relevant passages.
- Store your knowledge in a searchable database
- When a question comes in, find relevant info
- Add that info to the prompt automatically
- Model answers based on fresh, accurate data
When you do fine-tune, techniques like QLoRA combine it with quantization to keep memory usage low.
Think of it like learning with a tutor vs textbook:
- 1. Prompting is better when: Information changes frequently, need to start quickly, budget is limited, task is general-purpose
- 2. Fine-tuning is better when: Need a specific style or format, have lots of good examples, speed at inference time matters, same task repeats thousands of times
Types of Fine-tuning
- Full fine-tuning: retrain all weights. Maximum quality, but expensive (needs 8+ GPUs)
- LoRA / QLoRA: train only small adapters. Cheap and fast, 90% of the quality
- RLHF: train using human feedback. For teaching preferences, like being helpful vs harmful
- Instruction tuning: teach to follow instructions. Transforms a base model into a chatbot
Fun Fact: Start with prompting + RAG. Fine-tune only when you hit clear limits. 80% of use cases never need fine-tuning! Fine-tuning is expensive. Make sure you've exhausted cheaper options first.
Try It Yourself!
Answer a few questions about your use case, and see which approach is recommended for you!
Try it yourself
Interactive demo of this technique
Classify medical symptoms by doctor specialty
Dermatologist (redness) or Neurologist (gritty sensation might be neurological).
Not sure about the answer — need more context.
Ophthalmologist (confidence: 0.96)
Related specialists: Allergist (0.23 — if allergic conjunctivitis)
Few-shot is limited by examples in the prompt. Fine-tuning "bakes" thousands of examples into model weights — faster, cheaper per request and more accurate for narrow domain tasks.
Create a free account to solve challenges
3 AI-verified challenges for this lesson
This lesson is part of a structured LLM course.
My Learning Path