AI Learning Hub
advanced

Fine-tune vs RAG vs prompt engineering

Three levers people confuse for each other. Pick wrong and you waste weeks. Pick right and you ship in days.

What's actually happening

The decision tree:

Walk this top-down before reaching for fine-tuning — most teams stop at step 1 or 2.

Real-world examples

Under the hood (optional)

A typical fine-tune workflow with OpenAI is three steps: upload your labelled training data, kick off the job, then call the resulting custom model. Skip if you don't code — the actual decision (when to fine-tune at all) was the lesson.

Show example code (Python, ~12 lines)click to expand
from openai import OpenAI
client = OpenAI()
 
# 1. Upload labelled JSONL: {"messages": [{"role":"user",...},{"role":"assistant",...}]}
file = client.files.create(file=open("training.jsonl", "rb"), purpose="fine-tune")
 
# 2. Kick off the job
job = client.fine_tuning.jobs.create(
    training_file=file.id,
    model="gpt-4o-mini-2024-07-18",
)
 
# 3. Wait, then use the resulting model
finetuned_model = "ft:gpt-4o-mini-2024-07-18:org::abc123"
 
resp = client.chat.completions.create(model=finetuned_model, messages=[...])

For open models, the equivalent is LoRA or full fine-tuning with libraries like transformers, axolotl, or unsloth, on your own GPUs.

Check your understanding

  1. 1. You want a chatbot that answers from your internal wiki. What do you start with?
  2. 2. When is fine-tuning the right answer?
  3. 3. Most common combination in modern production AI:

Found this useful? Share it with someone learning AI.

Further reading

Related lessons in this track