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
📦 Data management
import openai
from opentrain import Dataset
openai.api_key = "<ADD_OPENAI_API_KEY_HERE>"
dataset = Dataset.from_file("data.jsonl")
dataset.info
dataset.download(output_path="downloaded-data.jsonl")
🦾 Fine-tune
import openai
from opentrain import Train
openai.api_key = "<ADD_OPENAI_API_KEY_HERE>"
trainer = Train(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 import Inference
openai.api_key = "<ADD_OPENAI_API_KEY_HERE>"
predict = Inference(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.
Metadata
Release files for opentrain 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| opentrain-0.1.0.tar.gz | 10.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| opentrain-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.6 kB
Release files / opentrain-0.1.0.tar.gz
| Download URL | opentrain-0.1.0.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1cfaf06d1fb68943c2e24cfe2b005bba3b9efff376d7efc2561c70b82f8a100
|
|
BLAKE2b-256 checksum How to use checksums |
26010e6684857feaa45774828b80112b7d938f60822acc826ed00e728b124cd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.24.0
|
Release files / opentrain-0.1.0-py3-none-any.whl
| Download URL | opentrain-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f952f8238e0efa0726f038c745743d03be9e76c507aa279c7fb9dec1cf350eac
|
|
BLAKE2b-256 checksum How to use checksums |
e3587c8c45a94e3f71582ba5602742e9db77fee6342a2a8605eb5a017eb0c3ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.24.0
|