Skip to main content

🚂 Fine-tune OpenAI models for text classification, question answering, and more

Project description

opentrain

🚂 Fine-tune OpenAI models for text classification, question answering, and more


opentrain is a simple Python package to fine-tune OpenAI models for task-specific purposes such as text classification, token classification, or question answering.

More information about OpenAI Fine-tuning at https://platform.openai.com/docs/guides/fine-tuning.

💻 Usage

🦾 Fine-tune

import openai
from opentrain.train import OpenAITrainer

openai.api_key = "<ADD_OPENAI_API_KEY_HERE>"

trainer = OpenAITrainer(model="ada")
trainer.train(
    [
        {
            "prompt": "I love to play soccer ->",
            "completion": " soccer",
        },
        {
            "prompt": "I love to play basketball ->",
            "completion": " basketball",
        },
    ],
)

🤖 Predict

import openai
from opentrain.predict import OpenAIPredict

openai.api_key = "<ADD_OPENAI_API_KEY_HERE>"

predict = OpenAIPredict(model="ada:ft-personal-2021-03-01-00-00-01")
predict.predict("I love to play ->")

⚠️ Warning

Fine-tuning OpenAI models via their API may take too long, so please be patient. Also, bear in mind that in some cases you just won't need to fine-tune an OpenAI model for your task.

To keep track of all the models you fine-tuned, you should visit https://platform.openai.com/account/usage, and then in the "Daily usage breakdown (UTC)" you'll need to select the date where you triggered the fine-tuning and click on "Fine-tune training" to see all the fine-tune training requests that you sent.

Besides that, in the OpenAI Playground at https://platform.openai.com/playground, you'll see a dropdown menu for all the available models, both the default ones and the ones you fine-tuned. Usually, in the following format <MODEL>:ft-personal-<DATE>, e.g. ada:ft-personal-2021-03-01-00-00-01.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opentrain-0.0.4.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

opentrain-0.0.4-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file opentrain-0.0.4.tar.gz.

File metadata

  • Download URL: opentrain-0.0.4.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.0

File hashes

Hashes for opentrain-0.0.4.tar.gz
Algorithm Hash digest
SHA256 61e542586da6db00255761e0e3bb1db64f61dc1eb6f7177c37b34388708b0838
MD5 1d4b558ed4dd9abbce84fd19c274fa2e
BLAKE2b-256 9becbcf3461eb56f38130e5d7d5477c0b72a8805a948dd664271bfe9edc70493

See more details on using hashes here.

File details

Details for the file opentrain-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: opentrain-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.0

File hashes

Hashes for opentrain-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a6472cad6425b07c4829740962498e22ad88f7e4b1aafcb1068260ea70a27325
MD5 ae32beb2b1a7f6574fd303f26b435eed
BLAKE2b-256 814d9959537446b2a5bad674d839c872ef7a39341c4bdf27649865d68ff64769

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page