|
4 | 4 | from .registry import get_encoding
|
5 | 5 |
|
6 | 6 | # TODO: these will likely be replaced by an API endpoint
|
7 |
| -MODEL_PREFIX_TO_ENCODING: dict[str, str] = { |
| 7 | +_MODEL_PREFIX_TO_ENCODING: dict[str, str] = { |
8 | 8 | # chat
|
9 | 9 | "gpt-4-": "cl100k_base", # e.g., gpt-4-0314, etc., plus gpt-4-32k
|
10 | 10 | "gpt-3.5-turbo-": "cl100k_base", # e.g, gpt-3.5-turbo-0301, -0401, etc.
|
11 |
| - "gpt-35-turbo": "cl100k_base", # Azure deployment name |
| 11 | + "gpt-35-turbo-": "cl100k_base", # Azure deployment name |
| 12 | + # fine-tuned |
| 13 | + "ft:gpt-4": "cl100k_base", |
| 14 | + "ft:gpt-3.5-turbo": "cl100k_base", |
| 15 | + "ft:davinci-002": "cl100k_base", |
| 16 | + "ft:babbage-002": "cl100k_base", |
12 | 17 | }
|
13 | 18 |
|
14 |
| -MODEL_TO_ENCODING: dict[str, str] = { |
| 19 | +_MODEL_TO_ENCODING: dict[str, str] = { |
15 | 20 | # chat
|
16 | 21 | "gpt-4": "cl100k_base",
|
17 | 22 | "gpt-3.5-turbo": "cl100k_base",
|
18 | 23 | "gpt-35-turbo": "cl100k_base", # Azure deployment name
|
19 |
| - # text |
| 24 | + # base |
| 25 | + "davinci-002": "cl100k_base", |
| 26 | + "babbage-002": "cl100k_base", |
| 27 | + # embeddings |
| 28 | + "text-embedding-ada-002": "cl100k_base", |
| 29 | + # DEPRECATED MODELS |
| 30 | + # text (DEPRECATED) |
20 | 31 | "text-davinci-003": "p50k_base",
|
21 | 32 | "text-davinci-002": "p50k_base",
|
22 | 33 | "text-davinci-001": "r50k_base",
|
|
27 | 38 | "curie": "r50k_base",
|
28 | 39 | "babbage": "r50k_base",
|
29 | 40 | "ada": "r50k_base",
|
30 |
| - # code |
| 41 | + # code (DEPRECATED) |
31 | 42 | "code-davinci-002": "p50k_base",
|
32 | 43 | "code-davinci-001": "p50k_base",
|
33 | 44 | "code-cushman-002": "p50k_base",
|
34 | 45 | "code-cushman-001": "p50k_base",
|
35 | 46 | "davinci-codex": "p50k_base",
|
36 | 47 | "cushman-codex": "p50k_base",
|
37 |
| - # edit |
| 48 | + # edit (DEPRECATED) |
38 | 49 | "text-davinci-edit-001": "p50k_edit",
|
39 | 50 | "code-davinci-edit-001": "p50k_edit",
|
40 |
| - # embeddings |
41 |
| - "text-embedding-ada-002": "cl100k_base", |
42 |
| - # old embeddings |
| 51 | + # old embeddings (DEPRECATED) |
43 | 52 | "text-similarity-davinci-001": "r50k_base",
|
44 | 53 | "text-similarity-curie-001": "r50k_base",
|
45 | 54 | "text-similarity-babbage-001": "r50k_base",
|
|
58 | 67 | def encoding_for_model(model_name: str) -> Encoding:
|
59 | 68 | """Returns the encoding used by a model."""
|
60 | 69 | encoding_name = None
|
61 |
| - if model_name in MODEL_TO_ENCODING: |
62 |
| - encoding_name = MODEL_TO_ENCODING[model_name] |
| 70 | + if model_name in _MODEL_TO_ENCODING: |
| 71 | + encoding_name = _MODEL_TO_ENCODING[model_name] |
63 | 72 | else:
|
64 | 73 | # Check if the model matches a known prefix
|
65 | 74 | # Prefix matching avoids needing library updates for every model version release
|
66 | 75 | # Note that this can match on non-existent models (e.g., gpt-3.5-turbo-FAKE)
|
67 |
| - for model_prefix, model_encoding_name in MODEL_PREFIX_TO_ENCODING.items(): |
| 76 | + for model_prefix, model_encoding_name in _MODEL_PREFIX_TO_ENCODING.items(): |
68 | 77 | if model_name.startswith(model_prefix):
|
69 | 78 | return get_encoding(model_encoding_name)
|
70 | 79 |
|
|
0 commit comments