C.W.K.
Stream
Lesson 04 of 04 · published

Using Fine-Tuned Models

~20 min · openai, inference, evaluation, comparison

Level 0Observer
0 XP0/43 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

Use it like any model

The fine-tuned model gets an ID like ft:gpt-4.1-mini-2025-04-14:my-org:my-suffix:abc123. Pass that ID to client.chat.completions.create as the model parameter — everything else is identical to using the base model.

Always evaluate against the base

Before swapping the fine-tuned model into production, run an evaluation that compares it head-to-head with the base model on a held-out test set. The fine-tuned version should win on your target metric AND not regress on a general-capability suite.

Limitations of the managed path

You don't get the model weights. You can only call the model through the API. This means vendor lock-in, you can't deploy locally, and you can't customize the serving infrastructure. For full control, use open-source fine-tuning (Tracks 4–5).

Code

Side-by-side base vs fine-tuned evaluation·python
from openai import OpenAI
import json

client = OpenAI()

BASE = "gpt-4.1-mini-2025-04-14"
FT   = "ft:gpt-4.1-mini-2025-04-14:my-org:my-suffix:abc123"

def evaluate(model_id: str, tests: list[dict]) -> float:
    correct = 0
    for ex in tests:
        input_msgs = ex["messages"][:-1]   # everything except expected
        expected   = ex["messages"][-1]["content"]
        r = client.chat.completions.create(
            model=model_id,
            messages=input_msgs,
            temperature=0,
        )
        actual = r.choices[0].message.content
        if actual.strip().lower() == expected.strip().lower():
            correct += 1
    return correct / len(tests)

with open("test.jsonl") as f:
    tests = [json.loads(line) for line in f]

base_acc = evaluate(BASE, tests)
ft_acc   = evaluate(FT,   tests)
print(f"Base accuracy: {base_acc:.1%}")
print(f"Fine-tuned:    {ft_acc:.1%}")
print(f"Delta:         {(ft_acc - base_acc) * 100:+.1f} pp")

External links

Exercise

Take the fine-tuned model from the previous lesson and run a head-to-head evaluation against the base model on a held-out 100-example test set. Report accuracy delta. Then run the same fine-tuned model on a 10-question general-capability suite (math, summarization, common sense). Document any regression.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.