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.3.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

opentrain-0.0.3-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for opentrain-0.0.3.tar.gz
Algorithm Hash digest
SHA256 9901f4ea6a56789abe8a40ae23387e62e8e3fe8dca394533567059732b391064
MD5 e302cd3475cad9ab4835960565ce51b4
BLAKE2b-256 c2a91cd95229479ac1d8984a552f53ef26d0a125bb8707f5c6761c2cb5e0bd67

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for opentrain-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3c31f89419eee4659b900cbdcefce2826babd82733e2433f3039628311677a19
MD5 a3596f2ffd3f6ef08191871b6478f8db
BLAKE2b-256 e8161366f2364e1ff4b78272f41d5bd93d665a8eece3a95c9763285a69334a96

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