together 1.5.8__tar.gz → 1.5.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {together-1.5.8 → together-1.5.11}/PKG-INFO +11 -10
- {together-1.5.8 → together-1.5.11}/README.md +8 -8
- {together-1.5.8 → together-1.5.11}/pyproject.toml +5 -2
- {together-1.5.8 → together-1.5.11}/src/together/cli/api/endpoints.py +1 -1
- {together-1.5.8 → together-1.5.11}/src/together/cli/api/finetune.py +10 -10
- {together-1.5.8 → together-1.5.11}/src/together/resources/finetune.py +45 -16
- {together-1.5.8 → together-1.5.11}/src/together/types/finetune.py +2 -3
- {together-1.5.8 → together-1.5.11}/src/together/utils/files.py +8 -1
- {together-1.5.8 → together-1.5.11}/LICENSE +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/__init__.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/abstract/__init__.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/abstract/api_requestor.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/cli/__init__.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/cli/api/__init__.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/cli/api/chat.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/cli/api/completions.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/cli/api/files.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/cli/api/images.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/cli/api/models.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/cli/api/utils.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/cli/cli.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/client.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/constants.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/error.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/filemanager.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/legacy/__init__.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/legacy/base.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/legacy/complete.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/legacy/embeddings.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/legacy/files.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/legacy/finetune.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/legacy/images.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/legacy/models.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/resources/__init__.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/resources/audio/__init__.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/resources/audio/speech.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/resources/chat/__init__.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/resources/chat/completions.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/resources/code_interpreter.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/resources/completions.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/resources/embeddings.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/resources/endpoints.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/resources/files.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/resources/images.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/resources/models.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/resources/rerank.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/together_response.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/types/__init__.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/types/abstract.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/types/audio_speech.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/types/chat_completions.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/types/code_interpreter.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/types/common.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/types/completions.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/types/embeddings.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/types/endpoints.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/types/error.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/types/files.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/types/images.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/types/models.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/types/rerank.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/utils/__init__.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/utils/_log.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/utils/api_helpers.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/utils/tools.py +0 -0
- {together-1.5.8 → together-1.5.11}/src/together/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: together
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.11
|
|
4
4
|
Summary: Python client for Together's Cloud Platform!
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: Together AI
|
|
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Provides-Extra: pyarrow
|
|
16
17
|
Requires-Dist: aiohttp (>=3.9.3,<4.0.0)
|
|
17
18
|
Requires-Dist: click (>=8.1.7,<9.0.0)
|
|
18
19
|
Requires-Dist: eval-type-backport (>=0.1.3,<0.3.0)
|
|
@@ -20,7 +21,7 @@ Requires-Dist: filelock (>=3.13.1,<4.0.0)
|
|
|
20
21
|
Requires-Dist: numpy (>=1.23.5) ; python_version < "3.12"
|
|
21
22
|
Requires-Dist: numpy (>=1.26.0) ; python_version >= "3.12"
|
|
22
23
|
Requires-Dist: pillow (>=11.1.0,<12.0.0)
|
|
23
|
-
Requires-Dist: pyarrow (>=10.0.1)
|
|
24
|
+
Requires-Dist: pyarrow (>=10.0.1) ; extra == "pyarrow"
|
|
24
25
|
Requires-Dist: pydantic (>=2.6.3,<3.0.0)
|
|
25
26
|
Requires-Dist: requests (>=2.31.0,<3.0.0)
|
|
26
27
|
Requires-Dist: rich (>=13.8.1,<15.0.0)
|
|
@@ -92,7 +93,7 @@ client = Together()
|
|
|
92
93
|
|
|
93
94
|
# Simple text message
|
|
94
95
|
response = client.chat.completions.create(
|
|
95
|
-
model="
|
|
96
|
+
model="meta-llama/Llama-4-Scout-17B-16E-Instruct",
|
|
96
97
|
messages=[{"role": "user", "content": "tell me about new york"}],
|
|
97
98
|
)
|
|
98
99
|
print(response.choices[0].message.content)
|
|
@@ -182,7 +183,7 @@ from together import Together
|
|
|
182
183
|
|
|
183
184
|
client = Together()
|
|
184
185
|
stream = client.chat.completions.create(
|
|
185
|
-
model="
|
|
186
|
+
model="meta-llama/Llama-4-Scout-17B-16E-Instruct",
|
|
186
187
|
messages=[{"role": "user", "content": "tell me about new york"}],
|
|
187
188
|
stream=True,
|
|
188
189
|
)
|
|
@@ -207,7 +208,7 @@ async def async_chat_completion(messages):
|
|
|
207
208
|
async_client = AsyncTogether()
|
|
208
209
|
tasks = [
|
|
209
210
|
async_client.chat.completions.create(
|
|
210
|
-
model="
|
|
211
|
+
model="meta-llama/Llama-4-Scout-17B-16E-Instruct",
|
|
211
212
|
messages=[{"role": "user", "content": message}],
|
|
212
213
|
)
|
|
213
214
|
for message in messages
|
|
@@ -230,7 +231,7 @@ from together import Together
|
|
|
230
231
|
client = Together()
|
|
231
232
|
|
|
232
233
|
response = client.chat.completions.create(
|
|
233
|
-
model="
|
|
234
|
+
model="meta-llama/Llama-3.2-3B-Instruct-Turbo",
|
|
234
235
|
messages=[{"role": "user", "content": "tell me about new york"}],
|
|
235
236
|
logprobs=1
|
|
236
237
|
)
|
|
@@ -381,7 +382,7 @@ client.files.delete(id="file-d0d318cb-b7d9-493a-bd70-1cfe089d3815") # deletes a
|
|
|
381
382
|
|
|
382
383
|
### Fine-tunes
|
|
383
384
|
|
|
384
|
-
The finetune API is used for fine-tuning and allows developers to create finetuning jobs. It also has several methods to list all jobs, retrive statuses and get checkpoints. Please refer to our fine-tuning docs [here](https://docs.together.ai/docs/fine-tuning-
|
|
385
|
+
The finetune API is used for fine-tuning and allows developers to create finetuning jobs. It also has several methods to list all jobs, retrive statuses and get checkpoints. Please refer to our fine-tuning docs [here](https://docs.together.ai/docs/fine-tuning-quickstart).
|
|
385
386
|
|
|
386
387
|
```python
|
|
387
388
|
from together import Together
|
|
@@ -390,7 +391,7 @@ client = Together()
|
|
|
390
391
|
|
|
391
392
|
client.fine_tuning.create(
|
|
392
393
|
training_file = 'file-d0d318cb-b7d9-493a-bd70-1cfe089d3815',
|
|
393
|
-
model = '
|
|
394
|
+
model = 'meta-llama/Llama-3.2-3B-Instruct',
|
|
394
395
|
n_epochs = 3,
|
|
395
396
|
n_checkpoints = 1,
|
|
396
397
|
batch_size = "max",
|
|
@@ -428,7 +429,7 @@ for model in models:
|
|
|
428
429
|
together chat.completions \
|
|
429
430
|
--message "system" "You are a helpful assistant named Together" \
|
|
430
431
|
--message "user" "What is your name?" \
|
|
431
|
-
--model
|
|
432
|
+
--model meta-llama/Llama-4-Scout-17B-16E-Instruct
|
|
432
433
|
```
|
|
433
434
|
|
|
434
435
|
The Chat Completions CLI enables streaming tokens to stdout by default. To disable streaming, use `--no-stream`.
|
|
@@ -438,7 +439,7 @@ The Chat Completions CLI enables streaming tokens to stdout by default. To disab
|
|
|
438
439
|
```bash
|
|
439
440
|
together completions \
|
|
440
441
|
"Large language models are " \
|
|
441
|
-
--model
|
|
442
|
+
--model meta-llama/Llama-4-Scout-17B-16E-Instruct \
|
|
442
443
|
--max-tokens 512 \
|
|
443
444
|
--stop "."
|
|
444
445
|
```
|
|
@@ -58,7 +58,7 @@ client = Together()
|
|
|
58
58
|
|
|
59
59
|
# Simple text message
|
|
60
60
|
response = client.chat.completions.create(
|
|
61
|
-
model="
|
|
61
|
+
model="meta-llama/Llama-4-Scout-17B-16E-Instruct",
|
|
62
62
|
messages=[{"role": "user", "content": "tell me about new york"}],
|
|
63
63
|
)
|
|
64
64
|
print(response.choices[0].message.content)
|
|
@@ -148,7 +148,7 @@ from together import Together
|
|
|
148
148
|
|
|
149
149
|
client = Together()
|
|
150
150
|
stream = client.chat.completions.create(
|
|
151
|
-
model="
|
|
151
|
+
model="meta-llama/Llama-4-Scout-17B-16E-Instruct",
|
|
152
152
|
messages=[{"role": "user", "content": "tell me about new york"}],
|
|
153
153
|
stream=True,
|
|
154
154
|
)
|
|
@@ -173,7 +173,7 @@ async def async_chat_completion(messages):
|
|
|
173
173
|
async_client = AsyncTogether()
|
|
174
174
|
tasks = [
|
|
175
175
|
async_client.chat.completions.create(
|
|
176
|
-
model="
|
|
176
|
+
model="meta-llama/Llama-4-Scout-17B-16E-Instruct",
|
|
177
177
|
messages=[{"role": "user", "content": message}],
|
|
178
178
|
)
|
|
179
179
|
for message in messages
|
|
@@ -196,7 +196,7 @@ from together import Together
|
|
|
196
196
|
client = Together()
|
|
197
197
|
|
|
198
198
|
response = client.chat.completions.create(
|
|
199
|
-
model="
|
|
199
|
+
model="meta-llama/Llama-3.2-3B-Instruct-Turbo",
|
|
200
200
|
messages=[{"role": "user", "content": "tell me about new york"}],
|
|
201
201
|
logprobs=1
|
|
202
202
|
)
|
|
@@ -347,7 +347,7 @@ client.files.delete(id="file-d0d318cb-b7d9-493a-bd70-1cfe089d3815") # deletes a
|
|
|
347
347
|
|
|
348
348
|
### Fine-tunes
|
|
349
349
|
|
|
350
|
-
The finetune API is used for fine-tuning and allows developers to create finetuning jobs. It also has several methods to list all jobs, retrive statuses and get checkpoints. Please refer to our fine-tuning docs [here](https://docs.together.ai/docs/fine-tuning-
|
|
350
|
+
The finetune API is used for fine-tuning and allows developers to create finetuning jobs. It also has several methods to list all jobs, retrive statuses and get checkpoints. Please refer to our fine-tuning docs [here](https://docs.together.ai/docs/fine-tuning-quickstart).
|
|
351
351
|
|
|
352
352
|
```python
|
|
353
353
|
from together import Together
|
|
@@ -356,7 +356,7 @@ client = Together()
|
|
|
356
356
|
|
|
357
357
|
client.fine_tuning.create(
|
|
358
358
|
training_file = 'file-d0d318cb-b7d9-493a-bd70-1cfe089d3815',
|
|
359
|
-
model = '
|
|
359
|
+
model = 'meta-llama/Llama-3.2-3B-Instruct',
|
|
360
360
|
n_epochs = 3,
|
|
361
361
|
n_checkpoints = 1,
|
|
362
362
|
batch_size = "max",
|
|
@@ -394,7 +394,7 @@ for model in models:
|
|
|
394
394
|
together chat.completions \
|
|
395
395
|
--message "system" "You are a helpful assistant named Together" \
|
|
396
396
|
--message "user" "What is your name?" \
|
|
397
|
-
--model
|
|
397
|
+
--model meta-llama/Llama-4-Scout-17B-16E-Instruct
|
|
398
398
|
```
|
|
399
399
|
|
|
400
400
|
The Chat Completions CLI enables streaming tokens to stdout by default. To disable streaming, use `--no-stream`.
|
|
@@ -404,7 +404,7 @@ The Chat Completions CLI enables streaming tokens to stdout by default. To disab
|
|
|
404
404
|
```bash
|
|
405
405
|
together completions \
|
|
406
406
|
"Large language models are " \
|
|
407
|
-
--model
|
|
407
|
+
--model meta-llama/Llama-4-Scout-17B-16E-Instruct \
|
|
408
408
|
--max-tokens 512 \
|
|
409
409
|
--stop "."
|
|
410
410
|
```
|
|
@@ -12,7 +12,7 @@ build-backend = "poetry.masonry.api"
|
|
|
12
12
|
|
|
13
13
|
[tool.poetry]
|
|
14
14
|
name = "together"
|
|
15
|
-
version = "1.5.
|
|
15
|
+
version = "1.5.11"
|
|
16
16
|
authors = ["Together AI <support@together.ai>"]
|
|
17
17
|
description = "Python client for Together's Cloud Platform!"
|
|
18
18
|
readme = "README.md"
|
|
@@ -37,13 +37,16 @@ aiohttp = "^3.9.3"
|
|
|
37
37
|
filelock = "^3.13.1"
|
|
38
38
|
eval-type-backport = ">=0.1.3,<0.3.0"
|
|
39
39
|
click = "^8.1.7"
|
|
40
|
-
pyarrow = ">=10.0.1"
|
|
40
|
+
pyarrow = { version = ">=10.0.1", optional = true }
|
|
41
41
|
numpy = [
|
|
42
42
|
{ version = ">=1.23.5", python = "<3.12" },
|
|
43
43
|
{ version = ">=1.26.0", python = ">=3.12" },
|
|
44
44
|
]
|
|
45
45
|
pillow = "^11.1.0"
|
|
46
46
|
|
|
47
|
+
[tool.poetry.extras]
|
|
48
|
+
pyarrow = ["pyarrow"]
|
|
49
|
+
|
|
47
50
|
[tool.poetry.group.quality]
|
|
48
51
|
optional = true
|
|
49
52
|
|
|
@@ -82,7 +82,7 @@ def endpoints(ctx: click.Context) -> None:
|
|
|
82
82
|
@click.option(
|
|
83
83
|
"--model",
|
|
84
84
|
required=True,
|
|
85
|
-
help="The model to deploy (e.g.
|
|
85
|
+
help="The model to deploy (e.g. meta-llama/Llama-4-Scout-17B-16E-Instruct)",
|
|
86
86
|
)
|
|
87
87
|
@click.option(
|
|
88
88
|
"--min-replicas",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
|
+
import re
|
|
4
5
|
from datetime import datetime, timezone
|
|
5
6
|
from textwrap import wrap
|
|
6
7
|
from typing import Any, Literal
|
|
7
|
-
import re
|
|
8
8
|
|
|
9
9
|
import click
|
|
10
10
|
from click.core import ParameterSource # type: ignore[attr-defined]
|
|
@@ -13,17 +13,17 @@ from tabulate import tabulate
|
|
|
13
13
|
|
|
14
14
|
from together import Together
|
|
15
15
|
from together.cli.api.utils import BOOL_WITH_AUTO, INT_WITH_MAX
|
|
16
|
+
from together.types.finetune import (
|
|
17
|
+
DownloadCheckpointType,
|
|
18
|
+
FinetuneEventType,
|
|
19
|
+
FinetuneTrainingLimits,
|
|
20
|
+
)
|
|
16
21
|
from together.utils import (
|
|
17
22
|
finetune_price_to_dollars,
|
|
23
|
+
format_timestamp,
|
|
18
24
|
log_warn,
|
|
19
25
|
log_warn_once,
|
|
20
26
|
parse_timestamp,
|
|
21
|
-
format_timestamp,
|
|
22
|
-
)
|
|
23
|
-
from together.types.finetune import (
|
|
24
|
-
DownloadCheckpointType,
|
|
25
|
-
FinetuneTrainingLimits,
|
|
26
|
-
FinetuneEventType,
|
|
27
27
|
)
|
|
28
28
|
|
|
29
29
|
|
|
@@ -348,9 +348,9 @@ def list(ctx: click.Context) -> None:
|
|
|
348
348
|
"Model Output Name": "\n".join(wrap(i.output_name or "", width=30)),
|
|
349
349
|
"Status": i.status,
|
|
350
350
|
"Created At": i.created_at,
|
|
351
|
-
"Price": f"""${
|
|
352
|
-
float(str(i.total_price))
|
|
353
|
-
|
|
351
|
+
"Price": f"""${
|
|
352
|
+
finetune_price_to_dollars(float(str(i.total_price)))
|
|
353
|
+
}""", # convert to string for mypy typing
|
|
354
354
|
}
|
|
355
355
|
)
|
|
356
356
|
table = tabulate(display_list, headers="keys", tablefmt="grid", showindex=True)
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import re
|
|
4
4
|
from pathlib import Path
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import List, Dict, Literal
|
|
6
6
|
|
|
7
7
|
from rich import print as rprint
|
|
8
8
|
|
|
@@ -69,7 +69,7 @@ def create_finetune_request(
|
|
|
69
69
|
wandb_base_url: str | None = None,
|
|
70
70
|
wandb_project_name: str | None = None,
|
|
71
71
|
wandb_name: str | None = None,
|
|
72
|
-
train_on_inputs: bool | Literal["auto"] =
|
|
72
|
+
train_on_inputs: bool | Literal["auto"] | None = None,
|
|
73
73
|
training_method: str = "sft",
|
|
74
74
|
dpo_beta: float | None = None,
|
|
75
75
|
from_checkpoint: str | None = None,
|
|
@@ -101,6 +101,11 @@ def create_finetune_request(
|
|
|
101
101
|
raise ValueError(
|
|
102
102
|
f"LoRA adapters are not supported for the selected model ({model_or_checkpoint})."
|
|
103
103
|
)
|
|
104
|
+
|
|
105
|
+
if lora_dropout is not None:
|
|
106
|
+
if not 0 <= lora_dropout < 1.0:
|
|
107
|
+
raise ValueError("LoRA dropout must be in [0, 1) range.")
|
|
108
|
+
|
|
104
109
|
lora_r = lora_r if lora_r is not None else model_limits.lora_training.max_rank
|
|
105
110
|
lora_alpha = lora_alpha if lora_alpha is not None else lora_r * 2
|
|
106
111
|
training_type = LoRATrainingType(
|
|
@@ -166,6 +171,18 @@ def create_finetune_request(
|
|
|
166
171
|
f"training_method must be one of {', '.join(AVAILABLE_TRAINING_METHODS)}"
|
|
167
172
|
)
|
|
168
173
|
|
|
174
|
+
if train_on_inputs is not None and training_method != "sft":
|
|
175
|
+
raise ValueError("train_on_inputs is only supported for SFT training")
|
|
176
|
+
|
|
177
|
+
if train_on_inputs is None and training_method == "sft":
|
|
178
|
+
log_warn_once(
|
|
179
|
+
"train_on_inputs is not set for SFT training, it will be set to 'auto'"
|
|
180
|
+
)
|
|
181
|
+
train_on_inputs = "auto"
|
|
182
|
+
|
|
183
|
+
if dpo_beta is not None and training_method != "dpo":
|
|
184
|
+
raise ValueError("dpo_beta is only supported for DPO training")
|
|
185
|
+
|
|
169
186
|
lr_scheduler: FinetuneLRScheduler
|
|
170
187
|
if lr_scheduler_type == "cosine":
|
|
171
188
|
if scheduler_num_cycles <= 0.0:
|
|
@@ -183,8 +200,10 @@ def create_finetune_request(
|
|
|
183
200
|
lr_scheduler_args=LinearLRSchedulerArgs(min_lr_ratio=min_lr_ratio),
|
|
184
201
|
)
|
|
185
202
|
|
|
186
|
-
training_method_cls: TrainingMethodSFT | TrainingMethodDPO
|
|
187
|
-
if training_method == "
|
|
203
|
+
training_method_cls: TrainingMethodSFT | TrainingMethodDPO
|
|
204
|
+
if training_method == "sft":
|
|
205
|
+
training_method_cls = TrainingMethodSFT(train_on_inputs=train_on_inputs)
|
|
206
|
+
elif training_method == "dpo":
|
|
188
207
|
training_method_cls = TrainingMethodDPO(dpo_beta=dpo_beta)
|
|
189
208
|
|
|
190
209
|
finetune_request = FinetuneRequest(
|
|
@@ -206,7 +225,6 @@ def create_finetune_request(
|
|
|
206
225
|
wandb_base_url=wandb_base_url,
|
|
207
226
|
wandb_project_name=wandb_project_name,
|
|
208
227
|
wandb_name=wandb_name,
|
|
209
|
-
train_on_inputs=train_on_inputs,
|
|
210
228
|
training_method=training_method_cls,
|
|
211
229
|
from_checkpoint=from_checkpoint,
|
|
212
230
|
)
|
|
@@ -281,7 +299,7 @@ class FineTuning:
|
|
|
281
299
|
wandb_name: str | None = None,
|
|
282
300
|
verbose: bool = False,
|
|
283
301
|
model_limits: FinetuneTrainingLimits | None = None,
|
|
284
|
-
train_on_inputs: bool | Literal["auto"] =
|
|
302
|
+
train_on_inputs: bool | Literal["auto"] | None = None,
|
|
285
303
|
training_method: str = "sft",
|
|
286
304
|
dpo_beta: float | None = None,
|
|
287
305
|
from_checkpoint: str | None = None,
|
|
@@ -326,12 +344,12 @@ class FineTuning:
|
|
|
326
344
|
Defaults to False.
|
|
327
345
|
model_limits (FinetuneTrainingLimits, optional): Limits for the hyperparameters the model in Fine-tuning.
|
|
328
346
|
Defaults to None.
|
|
329
|
-
train_on_inputs (bool or "auto"): Whether to mask the user messages in conversational data or prompts in instruction data.
|
|
347
|
+
train_on_inputs (bool or "auto", optional): Whether to mask the user messages in conversational data or prompts in instruction data.
|
|
330
348
|
"auto" will automatically determine whether to mask the inputs based on the data format.
|
|
331
349
|
For datasets with the "text" field (general format), inputs will not be masked.
|
|
332
350
|
For datasets with the "messages" field (conversational format) or "prompt" and "completion" fields
|
|
333
351
|
(Instruction format), inputs will be masked.
|
|
334
|
-
Defaults to "auto".
|
|
352
|
+
Defaults to None, or "auto" if training_method is "sft" (set in create_finetune_request).
|
|
335
353
|
training_method (str, optional): Training method. Defaults to "sft".
|
|
336
354
|
Supported methods: "sft", "dpo".
|
|
337
355
|
dpo_beta (float, optional): DPO beta parameter. Defaults to None.
|
|
@@ -545,7 +563,7 @@ class FineTuning:
|
|
|
545
563
|
*,
|
|
546
564
|
output: Path | str | None = None,
|
|
547
565
|
checkpoint_step: int | None = None,
|
|
548
|
-
checkpoint_type: DownloadCheckpointType = DownloadCheckpointType.DEFAULT,
|
|
566
|
+
checkpoint_type: DownloadCheckpointType | str = DownloadCheckpointType.DEFAULT,
|
|
549
567
|
) -> FinetuneDownloadResult:
|
|
550
568
|
"""
|
|
551
569
|
Downloads compressed fine-tuned model or checkpoint to local disk.
|
|
@@ -558,7 +576,7 @@ class FineTuning:
|
|
|
558
576
|
Defaults to None.
|
|
559
577
|
checkpoint_step (int, optional): Specifies step number for checkpoint to download.
|
|
560
578
|
Defaults to -1 (download the final model)
|
|
561
|
-
checkpoint_type (CheckpointType, optional): Specifies which checkpoint to download.
|
|
579
|
+
checkpoint_type (CheckpointType | str, optional): Specifies which checkpoint to download.
|
|
562
580
|
Defaults to CheckpointType.DEFAULT.
|
|
563
581
|
|
|
564
582
|
Returns:
|
|
@@ -582,6 +600,16 @@ class FineTuning:
|
|
|
582
600
|
|
|
583
601
|
ft_job = self.retrieve(id)
|
|
584
602
|
|
|
603
|
+
# convert str to DownloadCheckpointType
|
|
604
|
+
if isinstance(checkpoint_type, str):
|
|
605
|
+
try:
|
|
606
|
+
checkpoint_type = DownloadCheckpointType(checkpoint_type.lower())
|
|
607
|
+
except ValueError:
|
|
608
|
+
enum_strs = ", ".join(e.value for e in DownloadCheckpointType)
|
|
609
|
+
raise ValueError(
|
|
610
|
+
f"Invalid checkpoint type: {checkpoint_type}. Choose one of {{{enum_strs}}}."
|
|
611
|
+
)
|
|
612
|
+
|
|
585
613
|
if isinstance(ft_job.training_type, FullTrainingType):
|
|
586
614
|
if checkpoint_type != DownloadCheckpointType.DEFAULT:
|
|
587
615
|
raise ValueError(
|
|
@@ -592,10 +620,11 @@ class FineTuning:
|
|
|
592
620
|
if checkpoint_type == DownloadCheckpointType.DEFAULT:
|
|
593
621
|
checkpoint_type = DownloadCheckpointType.MERGED
|
|
594
622
|
|
|
595
|
-
if checkpoint_type
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
623
|
+
if checkpoint_type in {
|
|
624
|
+
DownloadCheckpointType.MERGED,
|
|
625
|
+
DownloadCheckpointType.ADAPTER,
|
|
626
|
+
}:
|
|
627
|
+
url += f"&checkpoint={checkpoint_type.value}"
|
|
599
628
|
else:
|
|
600
629
|
raise ValueError(
|
|
601
630
|
f"Invalid checkpoint type for LoRATrainingType: {checkpoint_type}"
|
|
@@ -682,7 +711,7 @@ class AsyncFineTuning:
|
|
|
682
711
|
wandb_name: str | None = None,
|
|
683
712
|
verbose: bool = False,
|
|
684
713
|
model_limits: FinetuneTrainingLimits | None = None,
|
|
685
|
-
train_on_inputs: bool | Literal["auto"] =
|
|
714
|
+
train_on_inputs: bool | Literal["auto"] | None = None,
|
|
686
715
|
training_method: str = "sft",
|
|
687
716
|
dpo_beta: float | None = None,
|
|
688
717
|
from_checkpoint: str | None = None,
|
|
@@ -732,7 +761,7 @@ class AsyncFineTuning:
|
|
|
732
761
|
For datasets with the "text" field (general format), inputs will not be masked.
|
|
733
762
|
For datasets with the "messages" field (conversational format) or "prompt" and "completion" fields
|
|
734
763
|
(Instruction format), inputs will be masked.
|
|
735
|
-
Defaults to "auto".
|
|
764
|
+
Defaults to None, or "auto" if training_method is "sft" (set in create_finetune_request).
|
|
736
765
|
training_method (str, optional): Training method. Defaults to "sft".
|
|
737
766
|
Supported methods: "sft", "dpo".
|
|
738
767
|
dpo_beta (float, optional): DPO beta parameter. Defaults to None.
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
from enum import Enum
|
|
4
4
|
from typing import List, Literal, Any
|
|
5
5
|
|
|
6
|
-
from pydantic import
|
|
6
|
+
from pydantic import Field, StrictBool, field_validator
|
|
7
7
|
|
|
8
8
|
from together.types.abstract import BaseModel
|
|
9
9
|
from together.types.common import (
|
|
@@ -149,6 +149,7 @@ class TrainingMethodSFT(TrainingMethod):
|
|
|
149
149
|
"""
|
|
150
150
|
|
|
151
151
|
method: Literal["sft"] = "sft"
|
|
152
|
+
train_on_inputs: StrictBool | Literal["auto"] = "auto"
|
|
152
153
|
|
|
153
154
|
|
|
154
155
|
class TrainingMethodDPO(TrainingMethod):
|
|
@@ -201,8 +202,6 @@ class FinetuneRequest(BaseModel):
|
|
|
201
202
|
wandb_name: str | None = None
|
|
202
203
|
# training type
|
|
203
204
|
training_type: FullTrainingType | LoRATrainingType | None = None
|
|
204
|
-
# train on inputs
|
|
205
|
-
train_on_inputs: StrictBool | Literal["auto"] = "auto"
|
|
206
205
|
# training method
|
|
207
206
|
training_method: TrainingMethodSFT | TrainingMethodDPO = Field(
|
|
208
207
|
default_factory=TrainingMethodSFT
|
|
@@ -6,7 +6,6 @@ from pathlib import Path
|
|
|
6
6
|
from traceback import format_exc
|
|
7
7
|
from typing import Any, Dict, List
|
|
8
8
|
|
|
9
|
-
from pyarrow import ArrowInvalid, parquet
|
|
10
9
|
|
|
11
10
|
from together.constants import (
|
|
12
11
|
MAX_FILE_SIZE_GB,
|
|
@@ -372,6 +371,14 @@ def _check_jsonl(file: Path) -> Dict[str, Any]:
|
|
|
372
371
|
|
|
373
372
|
|
|
374
373
|
def _check_parquet(file: Path) -> Dict[str, Any]:
|
|
374
|
+
try:
|
|
375
|
+
# Pyarrow is optional as it's large (~80MB) and isn't compatible with older systems.
|
|
376
|
+
from pyarrow import ArrowInvalid, parquet
|
|
377
|
+
except ImportError:
|
|
378
|
+
raise ImportError(
|
|
379
|
+
"pyarrow is not installed and is required to use parquet files. Please install it via `pip install together[pyarrow]`"
|
|
380
|
+
)
|
|
381
|
+
|
|
375
382
|
report_dict: Dict[str, Any] = {}
|
|
376
383
|
|
|
377
384
|
try:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|