파인튜닝 모델 호출하기

파인튜닝 모델 호출하기 (Calling Finetuned Models)

LiteLLM에서 OpenAI와 Vertex AI의 파인튜닝(fine-tuned) 모델을 호출하는 방법을 알려드릴게요. 모델 이름만 지정하면 SDK와 Proxy 모두에서 바로 사용할 수 있어요.

출처: 문서

본문

OpenAI

모델 이름 함수 호출
파인튜닝된 gpt-4-0613 response = completion(model="ft:gpt-4-0613", messages=messages)
파인튜닝된 gpt-4o-2024-05-13 response = completion(model="ft:gpt-4o-2024-05-13", messages=messages)
파인튜닝된 gpt-3.5-turbo-0125 response = completion(model="ft:gpt-3.5-turbo-0125", messages=messages)
파인튜닝된 gpt-3.5-turbo-1106 response = completion(model="ft:gpt-3.5-turbo-1106", messages=messages)
파인튜닝된 gpt-3.5-turbo-0613 response = completion(model="ft:gpt-3.5-turbo-0613", messages=messages)

Vertex AI

Vertex의 파인튜닝 모델은 숫자로 된 모델/엔드포인트 ID를 가져요.

  • SDK / PROXY — 다음 예시처럼 사용해요:
from litellm import completion
import os

## set ENV variables
os.environ["VERTEXAI_PROJECT"] = "hardy-device-38811"
os.environ["VERTEXAI_LOCATION"] = "us-central1"

response = completion(
  model="vertex_ai/<your-finetuned-model>",  # e.g. vertex_ai/4965075652664360960
  messages=[{ "content": "Hello, how are you?","role": "user"}],
  base_model="vertex_ai/gemini-3.1-pro-preview" # the base model - used for routing
)
  • Vertex 자격 증명을 환경 변수에 추가하기
!gcloud auth application-default login
  • config.yaml 설정하기
- model_name: finetuned-gemini
  litellm_params:
    model: vertex_ai/<ENDPOINT_ID>
    vertex_project: <PROJECT_ID>
    vertex_location: <LOCATION>
  model_info:
    base_model: vertex_ai/gemini-3.1-pro-preview # IMPORTANT
  • 테스트하기!
curl --location 'https://0.0.0.0:4000/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: ***' \
--data '{"model": "finetuned-gemini" ,"messages":[{"role": "user", "content":[{"type": "text", "text": "hi"}]}]}'

더 알아보기 (Learn more)