https://github.com/alvarobartt/opentrain
🚂 Fine-tune OpenAI models for text classification, question answering, and more
https://github.com/alvarobartt/opentrain
fine-tune openai openai-datasets openai-python
Last synced: 3 months ago
JSON representation
🚂 Fine-tune OpenAI models for text classification, question answering, and more
- Host: GitHub
- URL: https://github.com/alvarobartt/opentrain
- Owner: alvarobartt
- License: mit
- Created: 2023-04-12T10:24:18.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-01T09:15:03.000Z (about 3 years ago)
- Last Synced: 2026-02-15T04:53:08.634Z (4 months ago)
- Topics: fine-tune, openai, openai-datasets, openai-python
- Language: Python
- Homepage: https://alvarobartt.github.io/opentrain/
- Size: 613 KB
- Stars: 17
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
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
```python
import openai
from opentrain import Dataset
openai.api_key = ""
dataset = Dataset.from_file("data.jsonl")
dataset.info
dataset.download(output_path="downloaded-data.jsonl")
```
### 🦾 Fine-tune
```python
import openai
from opentrain import Train
openai.api_key = ""
trainer = Train(model="ada")
trainer.train(
[
{
"prompt": "I love to play soccer ->",
"completion": " soccer",
},
{
"prompt": "I love to play basketball ->",
"completion": " basketball",
},
],
)
```
### 🤖 Predict
```python
import openai
from opentrain import Inference
openai.api_key = ""
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 `:ft-personal-`, e.g. `ada:ft-personal-2021-03-01-00-00-01`.