Fine-Tuned gpt-3.5-turbo 사용하기

Fine-Tuned gpt-3.5-turbo 사용하기

LiteLLM을 사용하면 fine-tuning한 gpt-3.5-turbo 모델을 completion으로 호출할 수 있어요. 직접 만든 fine-tuned gpt-3.5-turbo 모델을 만들려면 이 튜토리얼을 따라 하세요: https://platform.openai.com/docs/guides/fine-tuning/preparing-your-dataset

fine-tuned 모델을 만들고 나면 litellm.completion()으로 호출할 수 있습니다.

출처: 문서

본문

사용법

import osfrom litellm import completion# LiteLLM reads from your .envos.environ["OPENAI_API_KEY"] = "your-api-key"response = completion(
  model="ft:gpt-3.5-turbo:my-org:custom_suffix:id",
  messages=[
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ])print(response.choices[0].message)

사용법 - OpenAI Organization ID 설정

LiteLLM은 OpenAI LLM을 호출할 때 OpenAI Organization을 지정할 수 있게 해줍니다. 자세한 내용은 여기에서 확인하세요: Organization ID 설정

이는 다음 방법 중 하나로 설정할 수 있어요:

  • 환경 변수 OPENAI_ORGANIZATION

  • litellm.completion(model=model, organization="your-organization-id") 파라미터

  • litellm.organization="your-organization-id"로 설정

import osfrom litellm import completion# LiteLLM reads from your .envos.environ["OPENAI_API_KEY"] = "your-api-key"os.environ["OPENAI_ORGANIZATION"] = "your-org-id" # Optionalresponse = completion(
  model="ft:gpt-3.5-turbo:my-org:custom_suffix:id",
  messages=[
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ])print(response.choices[0].message)

더 알아보기 (Learn more)