Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for all gpt-3.5 and gpt-4 model versions #346

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/guide/llms/llms.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ Autolabel makes it easy to try out different LLMs for your task and this page wi
To use models from [OpenAI](https://platform.openai.com/docs/models), you can set `provider` to `openai` when creating a labeling configuration. The specific model that will be queried can be specified using the `name` key. Autolabel currently supports the following models from OpenAI:

* `text-davinci-003`
* `gpt-3.5-turbo`
* `gpt-4` (8K Context)
* `gpt-3.5-turbo` and `gpt-3.5-turbo-0613` (4,096 max tokens)
* `gpt-3.5-turbo-16k` and `gpt-3.5-turbo-16k--613` (16,384 max tokens)
* `gpt-4` and `gpt-4-0613` (8,192 max tokens)
* `gpt-4-32k` and `gpt-4-32k-0613` (32,768 max tokens)

`gpt-4` (8K Context) is the most capable (and most expensive) model from OpenAI, while `gpt-3.5-turbo` is the cheapest (but still quite capable). `gpt-4` costs 15 times `gpt-3.5-turbo`, at $0.03/1K input tokens and $0.06/1K output tokens while `gpt-3.5-turbo` costs only $0.0015/1K input tokens and $0.002/1K output tokens. `text-davinci-003` model on the other hand costs $0.02/1K tokens. Detailed pricing for these models is available [here](https://openai.com/pricing).
`gpt-4` set of models are the most capable (and most expensive) from OpenAI, while `gpt-3.5-turbo` set of models are cheap (but still quite capable). Detailed pricing for these models is available [here](https://openai.com/pricing).

### Setup
To use OpenAI models with Autolabel, make sure to first install the relevant packages by running:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies = [
"numpy >= 1.23.0",
"requests >= 2.27.0",
"datasets >= 2.7.0",
"langchain >= 0.0.190",
"langchain >= 0.0.194",
"nervaluate >= 0.1.8",
"pandas >= 1.3.0",
"scikit-learn >= 1.0.0",
Expand Down
14 changes: 13 additions & 1 deletion src/autolabel/models/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ class OpenAILLM(BaseModel):
"gpt-3.5-turbo",
"gpt-3.5-turbo-0613",
"gpt-3.5-turbo-16k",
"gpt-3.5-turbo-16k-0613",
"gpt-4",
"gpt-4-0613",
"gpt-4-32k",
"gpt-4-32k-0613",
]
MODELS_WITH_TOKEN_PROBS = ["text-curie-001", "text-davinci-003"]

Expand All @@ -39,15 +43,23 @@ class OpenAILLM(BaseModel):
"gpt-3.5-turbo": 0.0015 / 1000,
"gpt-3.5-turbo-0613": 0.0015 / 1000,
"gpt-3.5-turbo-16k": 0.003 / 1000,
"gpt-3.5-turbo-16k-0613": 0.003 / 1000,
"gpt-4": 0.03 / 1000,
"gpt-4-0613": 0.03 / 1000,
"gpt-4-32k": 0.06 / 1000,
"gpt-4-32k-0613": 0.06 / 1000,
}
COST_PER_COMPLETION_TOKEN = {
"text-davinci-003": 0.02 / 1000,
"text-curie-001": 0.002 / 1000,
"gpt-3.5-turbo": 0.002 / 1000,
"gpt-3.5-turbo-0613": 0.002 / 1000,
"gpt-3.5-turbo-16k": 0.004 / 1000,
"gpt-4": 0.06 / 1000, # $0.06 per 1000 tokens in response
"gpt-3.5-turbo-16k-0613": 0.004 / 1000,
"gpt-4": 0.06 / 1000,
"gpt-4-0613": 0.06 / 1000,
"gpt-4-32k": 0.12 / 1000,
"gpt-4-32k-0613": 0.12 / 1000,
}

@cached_property
Expand Down