Training vs Fine-Tuning vs Prompting
There are three ways to change what a model does: train it, fine-tune it, or simply prompt it well. Most projects only need the last one.
Three Levels of Change
| Method | What changes | Who does it | Cost |
|---|---|---|---|
| Pre-training | The model learns language from a huge amount of text | Big AI companies | Millions of dollars, months |
| Fine-tuning | An existing model is trained a little more on your examples | Companies and developers | Moderate, needs good data |
| Prompting | Nothing in the model changes; you give better instructions and context | Everyone | Very low |
A helpful comparison: pre-training is like a student going through school and university. Fine-tuning is a short training course for one job. Prompting is giving clear instructions on the first day at work.
Pre-Training
During pre-training, the model reads a giant collection of text and code and practises one task: predicting the next token. Each time it guesses wrong, its internal numbers (called weights or parameters) are nudged a tiny bit. After trillions of tokens, it becomes good at language.
After that, companies do more training so the model follows instructions, holds a polite conversation and refuses harmful requests. This step uses human feedback and many example conversations. The result is the assistant you chat with.
You will almost never pre-train a large model yourself. To learn how training works on small models, see the Machine Learning Tutorial.
Fine-Tuning
Fine-tuning starts from an existing model and trains it further on your examples, usually hundreds or thousands of example conversations. It is good for:
- A fixed style or tone (for example, always replying like your shop's staff)
- A fixed output format that prompting cannot make reliable
- Making a smaller, cheaper model do one narrow task well
Training examples are usually stored in JSONL format: one JSON object per line. Each line is one example conversation:
Example
import json
examples = [
{"messages": [
{"role": "system", "content": "You reply to customers of Bilal Mobiles, Karachi."},
{"role": "user", "content": "Is the charger in stock?"},
{"role": "assistant", "content": "Ji haan! The 25W charger is in stock for Rs 2,500. Should I reserve one for you?"},
]},
{"messages": [
{"role": "system", "content": "You reply to customers of Bilal Mobiles, Karachi."},
{"role": "user", "content": "Do you deliver to Gulshan?"},
{"role": "assistant", "content": "Yes, we deliver to Gulshan-e-Iqbal within 24 hours. Delivery is Rs 200."},
]},
]
with open("train.jsonl", "w", encoding="utf-8") as f:
for ex in examples:
f.write(json.dumps(ex, ensure_ascii=False) + "\n")
with open("train.jsonl", encoding="utf-8") as f:
lines = f.readlines()
print("Examples written:", len(lines))
print("First line starts with:", lines[0][:45])Examples written: 2
First line starts with: {"messages": [{"role": "system", "content": "Two examples are far too few for real fine-tuning, but this is the shape. Check your provider's documentation for its exact format.
Fine-tuning is not a good way to teach facts like prices or stock levels. Facts change, and a fine-tuned model can still mix them up. Put facts in documents and use RAG instead.
Prompting
Prompting means writing clear instructions, giving context and showing a few examples, all inside the request. It is fast, cheap and easy to change. Most successful AI features in real companies are prompting plus RAG plus tools, not fine-tuning.
To get good at prompting, read the Prompt Engineering Tutorial, especially Few-Shot Prompting.
Which One Should You Choose?
Ask these questions in order:
- Can I get good results with a clear prompt and a few examples? Then stop there.
- Does the model need my own facts (prices, policies, notes)? Use RAG.
- Does it need to do things (check stock, book a slot)? Use tools (function calling).
- Do I need a very fixed style or format at large scale, and do I have many good examples? Then consider fine-tuning.
The same logic as a tiny function:
Example
def choose_approach(needs_new_facts, needs_fixed_style, have_1000_examples):
if needs_new_facts:
return "RAG: give the model your documents at question time"
if needs_fixed_style and have_1000_examples:
return "Fine-tuning: teach a style or format from many examples"
return "Prompting: write clear instructions and a few examples"
print(choose_approach(True, False, False))
print(choose_approach(False, True, True))
print(choose_approach(False, True, False))RAG: give the model your documents at question time Fine-tuning: teach a style or format from many examples Prompting: write clear instructions and a few examples
Exercise
Exercise
A clothing shop changes its prices every week and wants its chatbot to always quote the right price. What is the best approach?
