/fine_tuning

/fine_tuning

이 기능은 LiteLLM Enterprise 라이선스가 필요합니다. 무료 30일 평가판을 시작하거나 데모를 예약하세요. Enterprise가 무엇을 포함하는지 확인하세요.

기능 지원 비고
지원 프로바이더 OpenAI, Azure OpenAI, Vertex AI

⚡️ 지원되는 모델과 프로바이더의 전체 목록은 models.litellm.ai 참고.

기능 지원 비고
비용 추적 (Cost Tracking) 🟡 필요하면 알려주세요
로깅 (Logging) 모든 로깅 통합에서 동작

파인튜닝 엔드포인트를 사용하려면 finetune_settingsfiles_settings 를 litellm config.yaml에 추가하세요.

finetune_settings 및 files_settings 예시 config.yaml

model_list:
  - model_name: gpt-5.6-terra
    litellm_params:
      model: openai/fake
      api_key: fake-key
      api_base: https://exampleopenaiendpoint-production.up.railway.app/

# For /fine_tuning/jobs endpoints
finetune_settings:
  - custom_llm_provider: azure
    api_base: https://exampleopenaiendpoint-production.up.railway.app
    api_key: os.environ/AZURE_API_KEY
    api_version: "2023-03-15-preview"
  - custom_llm_provider: openai
    api_key: os.environ/OPENAI_API_KEY
  - custom_llm_provider: "vertex_ai"
    vertex_project: "adroit-crow-413218"
    vertex_location: "us-central1"
    vertex_credentials: "/Users/ishaanjaffer/Downloads/adroit-crow-413218-a956eef1a2a8.json"

# for /files endpoints
files_settings:
  - custom_llm_provider: azure
    api_base: https://exampleopenaiendpoint-production.up.railway.app
    api_key: fake-key
    api_version: "2023-03-15-preview"
  - custom_llm_provider: openai
    api_key: os.environ/OPENAI_API_KEY

파인튜닝용 파일 만들기

  • OpenAI Python SDK
  • curl
client = AsyncOpenAI(api_key="sk-<your-litellm-api-key>", base_url="http://0.0.0.0:4000") # base_url is your litellm proxy url

file_name = "openai_batch_completions.jsonl"
response = await client.files.create(
    extra_headers={"custom-llm-provider": "azure"}, # tell litellm proxy which provider to use
    file=open(file_name, "rb"),
    purpose="fine-tune",
)
curl http://localhost:4000/v1/files \
    -H "Authorization: Bearer ***" \
    -H "custom-llm-provider: azure" \
    -F purpose="batch" \
    -F file="@mydata.jsonl"

출처: 문서

본문

파인튜닝 작업 만들기

  • Azure OpenAI

  • OpenAI

  • OpenAI Python SDK

  • curl

ft_job = await client.fine_tuning.jobs.create(
    model="gpt-4.1-2025-04-14",                   # Azure OpenAI model you want to fine-tune
    training_file="file-abc123",                 # file_id from create file response
    extra_headers={"custom-llm-provider": "azure"}, # tell litellm proxy which provider to use
)
curl http://localhost:4000/v1/fine_tuning/jobs \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer ***" \
    -H "custom-llm-provider: azure" \
    -d '{
    "model": "gpt-4.1-2025-04-14",
    "training_file": "file-abc123"
    }'

요청 본문

  • 지원 파라미터

  • 예시 요청 본문

  • model — 타입: string, 필수: 예. 파인튜닝할 모델 이름

  • custom_llm_provider — 타입: Literal["azure", "openai", "vertex_ai"], 필수: 예. 파인튜닝할 모델 이름. 지원 프로바이더 중 하나를 선택할 수 있어요

  • training_file — 타입: string, 필수: 예. 훈련 데이터가 포함된 업로드 파일의 ID. 파일 업로드 방법은 upload file 참고. 데이터셋은 JSONL 파일로 포매팅되어야 합니다

  • hyperparameters — 타입: object, 필수: 아니요. 파인튜닝 작업에 사용되는 하이퍼파라미터.

    • batch_size — 타입: string 또는 integer, 필수: 아니요. 각 배치의 예시 수. 배치 크기가 클수록 모델 파라미터가 덜 자주 업데이트되지만 분산이 낮아짐
    • learning_rate_multiplier — 타입: string 또는 number, 필수: 아니요. 학습률의 스케일링 계수. 과적합을 피하려면 더 작은 학습률이 유용할 수 있음
    • n_epochs — 타입: string 또는 integer, 필수: 아니요. 모델을 훈련할 epoch 수. epoch는 훈련 데이터셋의 한 번 전체 순환을 뜻함
  • suffix — 타입: string 또는 null, 필수: 아니요. 기본: null. 파인튜닝된 모델 이름에 추가될 최대 18자 문자열. 예: "custom-model-name" 접미사는 ft:gpt-4o-mini:openai:custom-model-name:7p4lURel 같은 모델 이름을 만듭니다.

  • validation_file — 타입: string 또는 null, 필수: 아니요. 검증 데이터가 포함된 업로드 파일의 ID. 제공되면 이 데이터는 파인튜닝 중 정기적으로 검증 메트릭을 생성하는 데 사용됩니다

  • integrations — 타입: array 또는 null, 필수: 아니요. 파인튜닝 작업에 활성화할 통합 목록

  • seed — 타입: integer 또는 null, 필수: 아니요. seed는 작업의 재현성을 제어합니다. 같은 seed와 작업 파라미터를 전달하면 같은 결과가 나오지만 드물게 다를 수 있습니다. seed가 지정되지 않으면 자동 생성됩니다

예시 요청 본문:

{
  "model": "gpt-4.1-mini-2025-04-14",
  "training_file": "file-abcde12345",
  "hyperparameters": {
    "batch_size": 4,
    "learning_rate_multiplier": 0.1,
    "n_epochs": 3
  },
  "suffix": "custom-model-v1",
  "validation_file": "file-fghij67890",
  "seed": 42
}

파인튜닝 작업 취소

  • OpenAI Python SDK
  • curl
# cancel specific fine tuning job
cancel_ft_job = await client.fine_tuning.jobs.cancel(
    fine_tuning_job_id="123",                          # fine tuning job id
    extra_headers={"custom-llm-provider": "azure"},       # tell litellm proxy which provider to use
)

print("response from cancel ft job={}".format(cancel_ft_job))
curl -X POST http://localhost:4000/v1/fine_tuning/jobs/ftjob-abc123/cancel \
  -H "Authorization: Bearer ***" \
  -H "Content-Type: application/json" \
  -H "custom-llm-provider: azure"

파인튜닝 작업 나열

  • OpenAI Python SDK
  • curl
list_ft_jobs = await client.fine_tuning.jobs.list(
    extra_headers={"custom-llm-provider": "azure"}   # tell litellm proxy which provider to use
)

print("list of ft jobs={}".format(list_ft_jobs))
curl -X GET 'http://localhost:4000/v1/fine_tuning/jobs' \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer ***" \
     -H "custom-llm-provider: azure"

👉 Proxy API Reference

더 알아보기 (Learn more)