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

파인튜닝된 모델 사용

~20 min · openai, inference, evaluation, comparison

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

다른 모델처럼 써

파인튜닝된 모델은 ft:gpt-4.1-mini-2025-04-14:my-org:my-suffix:abc123 같은 ID 받아. 그 ID를 client.chat.completions.createmodel 파라미터로 — 나머지는 베이스 모델 쓰는 거랑 똑같아.

항상 베이스랑 비교 평가

실서비스에 파인튜닝 모델 swap 전에 held-out test 셋에서 베이스 모델이랑 head-to-head 비교 평가 돌려. 파인튜닝 버전이 타겟 메트릭에서 이기고 일반 능력 suite에서 회귀 안 해야 해.

매니지드 경로의 한계

모델 가중치 못 받아. API로만 모델 호출 가능. 벤더 락인이고, 로컬 배포 못 하고, 서빙 인프라 커스터마이즈 못 해. 풀 컨트롤 원하면 오픈소스 파인튜닝(Track 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

이전 레슨의 파인튜닝 모델로 held-out 100예제 test 셋에서 베이스 모델 head-to-head 평가. 정확도 델타 리포트. 그 다음 같은 파인튜닝 모델을 10문항 일반 능력 suite(수학, 요약, 상식)에 돌려. 회귀 다 문서화.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.