together 1.5.17__py3-none-any.whl → 2.0.0a8__py3-none-any.whl
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/__init__.py +101 -63
- together/_base_client.py +1995 -0
- together/_client.py +1033 -0
- together/_compat.py +219 -0
- together/_constants.py +14 -0
- together/_exceptions.py +108 -0
- together/_files.py +123 -0
- together/_models.py +857 -0
- together/_qs.py +150 -0
- together/_resource.py +43 -0
- together/_response.py +830 -0
- together/_streaming.py +370 -0
- together/_types.py +260 -0
- together/_utils/__init__.py +64 -0
- together/_utils/_compat.py +45 -0
- together/_utils/_datetime_parse.py +136 -0
- together/_utils/_logs.py +25 -0
- together/_utils/_proxy.py +65 -0
- together/_utils/_reflection.py +42 -0
- together/_utils/_resources_proxy.py +24 -0
- together/_utils/_streams.py +12 -0
- together/_utils/_sync.py +58 -0
- together/_utils/_transform.py +457 -0
- together/_utils/_typing.py +156 -0
- together/_utils/_utils.py +421 -0
- together/_version.py +4 -0
- together/lib/.keep +4 -0
- together/lib/__init__.py +23 -0
- together/{cli → lib/cli}/api/endpoints.py +108 -75
- together/lib/cli/api/evals.py +588 -0
- together/{cli → lib/cli}/api/files.py +20 -17
- together/{cli/api/finetune.py → lib/cli/api/fine_tuning.py} +161 -120
- together/lib/cli/api/models.py +140 -0
- together/{cli → lib/cli}/api/utils.py +6 -7
- together/{cli → lib/cli}/cli.py +16 -24
- together/{constants.py → lib/constants.py} +17 -12
- together/lib/resources/__init__.py +11 -0
- together/lib/resources/files.py +999 -0
- together/lib/resources/fine_tuning.py +280 -0
- together/lib/resources/models.py +35 -0
- together/lib/types/__init__.py +13 -0
- together/lib/types/error.py +9 -0
- together/lib/types/fine_tuning.py +455 -0
- together/{utils → lib/utils}/__init__.py +6 -14
- together/{utils → lib/utils}/_log.py +11 -16
- together/lib/utils/files.py +628 -0
- together/lib/utils/serializer.py +10 -0
- together/{utils → lib/utils}/tools.py +19 -55
- together/resources/__init__.py +225 -33
- together/resources/audio/__init__.py +72 -21
- together/resources/audio/audio.py +198 -0
- together/resources/audio/speech.py +574 -122
- together/resources/audio/transcriptions.py +282 -0
- together/resources/audio/translations.py +256 -0
- together/resources/audio/voices.py +135 -0
- together/resources/batches.py +417 -0
- together/resources/chat/__init__.py +30 -21
- together/resources/chat/chat.py +102 -0
- together/resources/chat/completions.py +1063 -263
- together/resources/code_interpreter/__init__.py +33 -0
- together/resources/code_interpreter/code_interpreter.py +258 -0
- together/resources/code_interpreter/sessions.py +135 -0
- together/resources/completions.py +884 -225
- together/resources/embeddings.py +172 -68
- together/resources/endpoints.py +598 -395
- together/resources/evals.py +452 -0
- together/resources/files.py +398 -121
- together/resources/fine_tuning.py +1033 -0
- together/resources/hardware.py +181 -0
- together/resources/images.py +256 -108
- together/resources/jobs.py +214 -0
- together/resources/models.py +238 -90
- together/resources/rerank.py +190 -92
- together/resources/videos.py +374 -0
- together/types/__init__.py +65 -109
- together/types/audio/__init__.py +10 -0
- together/types/audio/speech_create_params.py +75 -0
- together/types/audio/transcription_create_params.py +54 -0
- together/types/audio/transcription_create_response.py +111 -0
- together/types/audio/translation_create_params.py +40 -0
- together/types/audio/translation_create_response.py +70 -0
- together/types/audio/voice_list_response.py +23 -0
- together/types/audio_speech_stream_chunk.py +16 -0
- together/types/autoscaling.py +13 -0
- together/types/autoscaling_param.py +15 -0
- together/types/batch_create_params.py +24 -0
- together/types/batch_create_response.py +14 -0
- together/types/batch_job.py +45 -0
- together/types/batch_list_response.py +10 -0
- together/types/chat/__init__.py +18 -0
- together/types/chat/chat_completion.py +60 -0
- together/types/chat/chat_completion_chunk.py +61 -0
- together/types/chat/chat_completion_structured_message_image_url_param.py +18 -0
- together/types/chat/chat_completion_structured_message_text_param.py +13 -0
- together/types/chat/chat_completion_structured_message_video_url_param.py +18 -0
- together/types/chat/chat_completion_usage.py +13 -0
- together/types/chat/chat_completion_warning.py +9 -0
- together/types/chat/completion_create_params.py +329 -0
- together/types/code_interpreter/__init__.py +5 -0
- together/types/code_interpreter/session_list_response.py +31 -0
- together/types/code_interpreter_execute_params.py +45 -0
- together/types/completion.py +42 -0
- together/types/completion_chunk.py +66 -0
- together/types/completion_create_params.py +138 -0
- together/types/dedicated_endpoint.py +44 -0
- together/types/embedding.py +24 -0
- together/types/embedding_create_params.py +31 -0
- together/types/endpoint_create_params.py +43 -0
- together/types/endpoint_list_avzones_response.py +11 -0
- together/types/endpoint_list_params.py +18 -0
- together/types/endpoint_list_response.py +41 -0
- together/types/endpoint_update_params.py +27 -0
- together/types/eval_create_params.py +263 -0
- together/types/eval_create_response.py +16 -0
- together/types/eval_list_params.py +21 -0
- together/types/eval_list_response.py +10 -0
- together/types/eval_status_response.py +100 -0
- together/types/evaluation_job.py +139 -0
- together/types/execute_response.py +108 -0
- together/types/file_delete_response.py +13 -0
- together/types/file_list.py +12 -0
- together/types/file_purpose.py +9 -0
- together/types/file_response.py +31 -0
- together/types/file_type.py +7 -0
- together/types/fine_tuning_cancel_response.py +194 -0
- together/types/fine_tuning_content_params.py +24 -0
- together/types/fine_tuning_delete_params.py +11 -0
- together/types/fine_tuning_delete_response.py +12 -0
- together/types/fine_tuning_list_checkpoints_response.py +21 -0
- together/types/fine_tuning_list_events_response.py +12 -0
- together/types/fine_tuning_list_response.py +199 -0
- together/types/finetune_event.py +41 -0
- together/types/finetune_event_type.py +33 -0
- together/types/finetune_response.py +177 -0
- together/types/hardware_list_params.py +16 -0
- together/types/hardware_list_response.py +58 -0
- together/types/image_data_b64.py +15 -0
- together/types/image_data_url.py +15 -0
- together/types/image_file.py +23 -0
- together/types/image_generate_params.py +85 -0
- together/types/job_list_response.py +47 -0
- together/types/job_retrieve_response.py +43 -0
- together/types/log_probs.py +18 -0
- together/types/model_list_response.py +10 -0
- together/types/model_object.py +42 -0
- together/types/model_upload_params.py +36 -0
- together/types/model_upload_response.py +23 -0
- together/types/rerank_create_params.py +36 -0
- together/types/rerank_create_response.py +36 -0
- together/types/tool_choice.py +23 -0
- together/types/tool_choice_param.py +23 -0
- together/types/tools_param.py +23 -0
- together/types/training_method_dpo.py +22 -0
- together/types/training_method_sft.py +18 -0
- together/types/video_create_params.py +86 -0
- together/types/video_job.py +57 -0
- together-2.0.0a8.dist-info/METADATA +680 -0
- together-2.0.0a8.dist-info/RECORD +164 -0
- {together-1.5.17.dist-info → together-2.0.0a8.dist-info}/WHEEL +1 -1
- together-2.0.0a8.dist-info/entry_points.txt +2 -0
- {together-1.5.17.dist-info → together-2.0.0a8.dist-info/licenses}/LICENSE +1 -1
- together/abstract/api_requestor.py +0 -729
- together/cli/api/chat.py +0 -276
- together/cli/api/completions.py +0 -119
- together/cli/api/images.py +0 -93
- together/cli/api/models.py +0 -55
- together/client.py +0 -176
- together/error.py +0 -194
- together/filemanager.py +0 -389
- together/legacy/__init__.py +0 -0
- together/legacy/base.py +0 -27
- together/legacy/complete.py +0 -93
- together/legacy/embeddings.py +0 -27
- together/legacy/files.py +0 -146
- together/legacy/finetune.py +0 -177
- together/legacy/images.py +0 -27
- together/legacy/models.py +0 -44
- together/resources/batch.py +0 -136
- together/resources/code_interpreter.py +0 -82
- together/resources/finetune.py +0 -1064
- together/together_response.py +0 -50
- together/types/abstract.py +0 -26
- together/types/audio_speech.py +0 -110
- together/types/batch.py +0 -53
- together/types/chat_completions.py +0 -197
- together/types/code_interpreter.py +0 -57
- together/types/common.py +0 -66
- together/types/completions.py +0 -107
- together/types/embeddings.py +0 -35
- together/types/endpoints.py +0 -123
- together/types/error.py +0 -16
- together/types/files.py +0 -90
- together/types/finetune.py +0 -398
- together/types/images.py +0 -44
- together/types/models.py +0 -45
- together/types/rerank.py +0 -43
- together/utils/api_helpers.py +0 -124
- together/utils/files.py +0 -425
- together/version.py +0 -6
- together-1.5.17.dist-info/METADATA +0 -525
- together-1.5.17.dist-info/RECORD +0 -69
- together-1.5.17.dist-info/entry_points.txt +0 -3
- /together/{abstract → lib/cli}/__init__.py +0 -0
- /together/{cli → lib/cli/api}/__init__.py +0 -0
- /together/{cli/api/__init__.py → py.typed} +0 -0
together/types/endpoints.py
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from datetime import datetime
|
|
4
|
-
from typing import Any, Dict, Literal, Optional, Union
|
|
5
|
-
|
|
6
|
-
from pydantic import BaseModel, Field
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class TogetherJSONModel(BaseModel):
|
|
10
|
-
"""Base model with JSON serialization support."""
|
|
11
|
-
|
|
12
|
-
def model_dump(self, **kwargs: Any) -> Dict[str, Any]:
|
|
13
|
-
exclude_none = kwargs.pop("exclude_none", True)
|
|
14
|
-
data = super().model_dump(exclude_none=exclude_none, **kwargs)
|
|
15
|
-
|
|
16
|
-
# Convert datetime objects to ISO format strings
|
|
17
|
-
for key, value in data.items():
|
|
18
|
-
if isinstance(value, datetime):
|
|
19
|
-
data[key] = value.isoformat()
|
|
20
|
-
|
|
21
|
-
return data
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class Autoscaling(TogetherJSONModel):
|
|
25
|
-
"""Configuration for automatic scaling of replicas based on demand."""
|
|
26
|
-
|
|
27
|
-
min_replicas: int = Field(
|
|
28
|
-
description="The minimum number of replicas to maintain, even when there is no load"
|
|
29
|
-
)
|
|
30
|
-
max_replicas: int = Field(
|
|
31
|
-
description="The maximum number of replicas to scale up to under load"
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class EndpointPricing(TogetherJSONModel):
|
|
36
|
-
"""Pricing details for using an endpoint."""
|
|
37
|
-
|
|
38
|
-
cents_per_minute: float = Field(
|
|
39
|
-
description="Cost per minute of endpoint uptime in cents"
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class HardwareSpec(TogetherJSONModel):
|
|
44
|
-
"""Detailed specifications of a hardware configuration."""
|
|
45
|
-
|
|
46
|
-
gpu_type: str = Field(description="The type/model of GPU")
|
|
47
|
-
gpu_link: str = Field(description="The GPU interconnect technology")
|
|
48
|
-
gpu_memory: Union[float, int] = Field(description="Amount of GPU memory in GB")
|
|
49
|
-
gpu_count: int = Field(description="Number of GPUs in this configuration")
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
class HardwareAvailability(TogetherJSONModel):
|
|
53
|
-
"""Indicates the current availability status of a hardware configuration."""
|
|
54
|
-
|
|
55
|
-
status: Literal["available", "unavailable", "insufficient"] = Field(
|
|
56
|
-
description="The availability status of the hardware configuration"
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
class HardwareWithStatus(TogetherJSONModel):
|
|
61
|
-
"""Hardware configuration details with optional availability status."""
|
|
62
|
-
|
|
63
|
-
object: Literal["hardware"] = Field(description="The type of object")
|
|
64
|
-
id: str = Field(description="Unique identifier for the hardware configuration")
|
|
65
|
-
pricing: EndpointPricing = Field(
|
|
66
|
-
description="Pricing details for this hardware configuration"
|
|
67
|
-
)
|
|
68
|
-
specs: HardwareSpec = Field(description="Detailed specifications of this hardware")
|
|
69
|
-
availability: Optional[HardwareAvailability] = Field(
|
|
70
|
-
default=None,
|
|
71
|
-
description="Current availability status of this hardware configuration",
|
|
72
|
-
)
|
|
73
|
-
updated_at: datetime = Field(
|
|
74
|
-
description="Timestamp of when the hardware status was last updated"
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
class BaseEndpoint(TogetherJSONModel):
|
|
79
|
-
"""Base class for endpoint models with common fields."""
|
|
80
|
-
|
|
81
|
-
object: Literal["endpoint"] = Field(description="The type of object")
|
|
82
|
-
id: Optional[str] = Field(
|
|
83
|
-
default=None, description="Unique identifier for the endpoint"
|
|
84
|
-
)
|
|
85
|
-
name: str = Field(description="System name for the endpoint")
|
|
86
|
-
model: str = Field(description="The model deployed on this endpoint")
|
|
87
|
-
type: str = Field(description="The type of endpoint")
|
|
88
|
-
owner: str = Field(description="The owner of this endpoint")
|
|
89
|
-
state: Literal[
|
|
90
|
-
"PENDING", "STARTING", "STARTED", "STOPPING", "STOPPED", "FAILED", "ERROR"
|
|
91
|
-
] = Field(description="Current state of the endpoint")
|
|
92
|
-
created_at: datetime = Field(description="Timestamp when the endpoint was created")
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
class ListEndpoint(BaseEndpoint):
|
|
96
|
-
"""Details about an endpoint when listed via the list endpoint."""
|
|
97
|
-
|
|
98
|
-
type: Literal["dedicated", "serverless"] = Field(description="The type of endpoint")
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
class DedicatedEndpoint(BaseEndpoint):
|
|
102
|
-
"""Details about a dedicated endpoint deployment."""
|
|
103
|
-
|
|
104
|
-
id: str = Field(description="Unique identifier for the endpoint")
|
|
105
|
-
type: Literal["dedicated"] = Field(description="The type of endpoint")
|
|
106
|
-
display_name: str = Field(description="Human-readable name for the endpoint")
|
|
107
|
-
hardware: str = Field(
|
|
108
|
-
description="The hardware configuration used for this endpoint"
|
|
109
|
-
)
|
|
110
|
-
autoscaling: Autoscaling = Field(
|
|
111
|
-
description="Configuration for automatic scaling of the endpoint"
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
__all__ = [
|
|
116
|
-
"DedicatedEndpoint",
|
|
117
|
-
"ListEndpoint",
|
|
118
|
-
"Autoscaling",
|
|
119
|
-
"EndpointPricing",
|
|
120
|
-
"HardwareSpec",
|
|
121
|
-
"HardwareAvailability",
|
|
122
|
-
"HardwareWithStatus",
|
|
123
|
-
]
|
together/types/error.py
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from pydantic import Field
|
|
4
|
-
|
|
5
|
-
from together.types.abstract import BaseModel
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class TogetherErrorResponse(BaseModel):
|
|
9
|
-
# error message
|
|
10
|
-
message: str | None = None
|
|
11
|
-
# error type
|
|
12
|
-
type_: str | None = Field(None, alias="type")
|
|
13
|
-
# param causing error
|
|
14
|
-
param: str | None = None
|
|
15
|
-
# error code
|
|
16
|
-
code: str | None = None
|
together/types/files.py
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from enum import Enum
|
|
4
|
-
from typing import List, Literal
|
|
5
|
-
|
|
6
|
-
from pydantic import Field
|
|
7
|
-
|
|
8
|
-
from together.types.abstract import BaseModel
|
|
9
|
-
from together.types.common import (
|
|
10
|
-
ObjectType,
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class FilePurpose(str, Enum):
|
|
15
|
-
FineTune = "fine-tune"
|
|
16
|
-
BatchAPI = "batch-api"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class FileType(str, Enum):
|
|
20
|
-
jsonl = "jsonl"
|
|
21
|
-
parquet = "parquet"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class FileRequest(BaseModel):
|
|
25
|
-
"""
|
|
26
|
-
Files request type
|
|
27
|
-
"""
|
|
28
|
-
|
|
29
|
-
# training file ID
|
|
30
|
-
training_file: str
|
|
31
|
-
# base model string
|
|
32
|
-
model: str
|
|
33
|
-
# number of epochs to train for
|
|
34
|
-
n_epochs: int
|
|
35
|
-
# training learning rate
|
|
36
|
-
learning_rate: float
|
|
37
|
-
# number of checkpoints to save
|
|
38
|
-
n_checkpoints: int | None = None
|
|
39
|
-
# training batch size
|
|
40
|
-
batch_size: int | None = None
|
|
41
|
-
# up to 40 character suffix for output model name
|
|
42
|
-
suffix: str | None = None
|
|
43
|
-
# weights & biases api key
|
|
44
|
-
wandb_api_key: str | None = None
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
class FileResponse(BaseModel):
|
|
48
|
-
"""
|
|
49
|
-
Files API response type
|
|
50
|
-
"""
|
|
51
|
-
|
|
52
|
-
id: str
|
|
53
|
-
object: Literal[ObjectType.File]
|
|
54
|
-
# created timestamp
|
|
55
|
-
created_at: int | None = None
|
|
56
|
-
type: FileType | None = None
|
|
57
|
-
purpose: FilePurpose | None = None
|
|
58
|
-
filename: str | None = None
|
|
59
|
-
# file byte size
|
|
60
|
-
bytes: int | None = None
|
|
61
|
-
# JSONL line count
|
|
62
|
-
line_count: int | None = Field(None, alias="LineCount")
|
|
63
|
-
processed: bool | None = Field(None, alias="Processed")
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
class FileList(BaseModel):
|
|
67
|
-
# object type
|
|
68
|
-
object: Literal["list"] | None = None
|
|
69
|
-
# list of fine-tune job objects
|
|
70
|
-
data: List[FileResponse] | None = None
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
class FileDeleteResponse(BaseModel):
|
|
74
|
-
# file id
|
|
75
|
-
id: str
|
|
76
|
-
# object type
|
|
77
|
-
object: Literal[ObjectType.File]
|
|
78
|
-
# is deleted
|
|
79
|
-
deleted: bool
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
class FileObject(BaseModel):
|
|
83
|
-
# object type
|
|
84
|
-
object: Literal["local"] | None = None
|
|
85
|
-
# fine-tune job id
|
|
86
|
-
id: str | None = None
|
|
87
|
-
# local path filename
|
|
88
|
-
filename: str | None = None
|
|
89
|
-
# size in bytes
|
|
90
|
-
size: int | None = None
|
together/types/finetune.py
DELETED
|
@@ -1,398 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from enum import Enum
|
|
4
|
-
from typing import List, Literal, Any
|
|
5
|
-
|
|
6
|
-
from pydantic import Field, StrictBool, field_validator
|
|
7
|
-
|
|
8
|
-
from together.types.abstract import BaseModel
|
|
9
|
-
from together.types.common import (
|
|
10
|
-
ObjectType,
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class FinetuneJobStatus(str, Enum):
|
|
15
|
-
"""
|
|
16
|
-
Possible fine-tune job status
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
STATUS_PENDING = "pending"
|
|
20
|
-
STATUS_QUEUED = "queued"
|
|
21
|
-
STATUS_RUNNING = "running"
|
|
22
|
-
STATUS_COMPRESSING = "compressing"
|
|
23
|
-
STATUS_UPLOADING = "uploading"
|
|
24
|
-
STATUS_CANCEL_REQUESTED = "cancel_requested"
|
|
25
|
-
STATUS_CANCELLED = "cancelled"
|
|
26
|
-
STATUS_ERROR = "error"
|
|
27
|
-
STATUS_USER_ERROR = "user_error"
|
|
28
|
-
STATUS_COMPLETED = "completed"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class FinetuneEventLevels(str, Enum):
|
|
32
|
-
"""
|
|
33
|
-
Fine-tune job event status levels
|
|
34
|
-
"""
|
|
35
|
-
|
|
36
|
-
NULL = ""
|
|
37
|
-
INFO = "Info"
|
|
38
|
-
WARNING = "Warning"
|
|
39
|
-
ERROR = "Error"
|
|
40
|
-
LEGACY_INFO = "info"
|
|
41
|
-
LEGACY_IWARNING = "warning"
|
|
42
|
-
LEGACY_IERROR = "error"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
class FinetuneEventType(str, Enum):
|
|
46
|
-
"""
|
|
47
|
-
Fine-tune job event types
|
|
48
|
-
"""
|
|
49
|
-
|
|
50
|
-
JOB_PENDING = "JOB_PENDING"
|
|
51
|
-
JOB_START = "JOB_START"
|
|
52
|
-
JOB_STOPPED = "JOB_STOPPED"
|
|
53
|
-
MODEL_DOWNLOADING = "MODEL_DOWNLOADING"
|
|
54
|
-
MODEL_DOWNLOAD_COMPLETE = "MODEL_DOWNLOAD_COMPLETE"
|
|
55
|
-
TRAINING_DATA_DOWNLOADING = "TRAINING_DATA_DOWNLOADING"
|
|
56
|
-
TRAINING_DATA_DOWNLOAD_COMPLETE = "TRAINING_DATA_DOWNLOAD_COMPLETE"
|
|
57
|
-
VALIDATION_DATA_DOWNLOADING = "VALIDATION_DATA_DOWNLOADING"
|
|
58
|
-
VALIDATION_DATA_DOWNLOAD_COMPLETE = "VALIDATION_DATA_DOWNLOAD_COMPLETE"
|
|
59
|
-
WANDB_INIT = "WANDB_INIT"
|
|
60
|
-
TRAINING_START = "TRAINING_START"
|
|
61
|
-
CHECKPOINT_SAVE = "CHECKPOINT_SAVE"
|
|
62
|
-
BILLING_LIMIT = "BILLING_LIMIT"
|
|
63
|
-
EPOCH_COMPLETE = "EPOCH_COMPLETE"
|
|
64
|
-
EVAL_COMPLETE = "EVAL_COMPLETE"
|
|
65
|
-
TRAINING_COMPLETE = "TRAINING_COMPLETE"
|
|
66
|
-
MODEL_COMPRESSING = "COMPRESSING_MODEL"
|
|
67
|
-
MODEL_COMPRESSION_COMPLETE = "MODEL_COMPRESSION_COMPLETE"
|
|
68
|
-
MODEL_UPLOADING = "MODEL_UPLOADING"
|
|
69
|
-
MODEL_UPLOAD_COMPLETE = "MODEL_UPLOAD_COMPLETE"
|
|
70
|
-
JOB_COMPLETE = "JOB_COMPLETE"
|
|
71
|
-
JOB_ERROR = "JOB_ERROR"
|
|
72
|
-
JOB_USER_ERROR = "JOB_USER_ERROR"
|
|
73
|
-
CANCEL_REQUESTED = "CANCEL_REQUESTED"
|
|
74
|
-
JOB_RESTARTED = "JOB_RESTARTED"
|
|
75
|
-
REFUND = "REFUND"
|
|
76
|
-
WARNING = "WARNING"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
class DownloadCheckpointType(Enum):
|
|
80
|
-
DEFAULT = "default"
|
|
81
|
-
MERGED = "merged"
|
|
82
|
-
ADAPTER = "adapter"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
class FinetuneEvent(BaseModel):
|
|
86
|
-
"""
|
|
87
|
-
Fine-tune event type
|
|
88
|
-
"""
|
|
89
|
-
|
|
90
|
-
# object type
|
|
91
|
-
object: Literal[ObjectType.FinetuneEvent]
|
|
92
|
-
# created at datetime stamp
|
|
93
|
-
created_at: str | None = None
|
|
94
|
-
# event log level
|
|
95
|
-
level: FinetuneEventLevels | None = None
|
|
96
|
-
# event message string
|
|
97
|
-
message: str | None = None
|
|
98
|
-
# event type
|
|
99
|
-
type: FinetuneEventType | None = None
|
|
100
|
-
# optional: model parameter count
|
|
101
|
-
param_count: int | None = None
|
|
102
|
-
# optional: dataset token count
|
|
103
|
-
token_count: int | None = None
|
|
104
|
-
# optional: weights & biases url
|
|
105
|
-
wandb_url: str | None = None
|
|
106
|
-
# event hash
|
|
107
|
-
hash: str | None = None
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
class TrainingType(BaseModel):
|
|
111
|
-
"""
|
|
112
|
-
Abstract training type
|
|
113
|
-
"""
|
|
114
|
-
|
|
115
|
-
type: str
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
class FullTrainingType(TrainingType):
|
|
119
|
-
"""
|
|
120
|
-
Training type for full fine-tuning
|
|
121
|
-
"""
|
|
122
|
-
|
|
123
|
-
type: str = "Full"
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
class LoRATrainingType(TrainingType):
|
|
127
|
-
"""
|
|
128
|
-
Training type for LoRA adapters training
|
|
129
|
-
"""
|
|
130
|
-
|
|
131
|
-
lora_r: int
|
|
132
|
-
lora_alpha: int
|
|
133
|
-
lora_dropout: float = 0.0
|
|
134
|
-
lora_trainable_modules: str = "all-linear"
|
|
135
|
-
type: str = "Lora"
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
class TrainingMethod(BaseModel):
|
|
139
|
-
"""
|
|
140
|
-
Training method type
|
|
141
|
-
"""
|
|
142
|
-
|
|
143
|
-
method: str
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
class TrainingMethodSFT(TrainingMethod):
|
|
147
|
-
"""
|
|
148
|
-
Training method type for SFT training
|
|
149
|
-
"""
|
|
150
|
-
|
|
151
|
-
method: Literal["sft"] = "sft"
|
|
152
|
-
train_on_inputs: StrictBool | Literal["auto"] = "auto"
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
class TrainingMethodDPO(TrainingMethod):
|
|
156
|
-
"""
|
|
157
|
-
Training method type for DPO training
|
|
158
|
-
"""
|
|
159
|
-
|
|
160
|
-
method: Literal["dpo"] = "dpo"
|
|
161
|
-
dpo_beta: float | None = None
|
|
162
|
-
dpo_normalize_logratios_by_length: bool = False
|
|
163
|
-
dpo_reference_free: bool = False
|
|
164
|
-
rpo_alpha: float | None = None
|
|
165
|
-
simpo_gamma: float | None = None
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
class FinetuneRequest(BaseModel):
|
|
169
|
-
"""
|
|
170
|
-
Fine-tune request type
|
|
171
|
-
"""
|
|
172
|
-
|
|
173
|
-
# training file ID
|
|
174
|
-
training_file: str
|
|
175
|
-
# validation file id
|
|
176
|
-
validation_file: str | None = None
|
|
177
|
-
# base model string
|
|
178
|
-
model: str | None = None
|
|
179
|
-
# number of epochs to train for
|
|
180
|
-
n_epochs: int
|
|
181
|
-
# training learning rate
|
|
182
|
-
learning_rate: float
|
|
183
|
-
# learning rate scheduler type and args
|
|
184
|
-
lr_scheduler: LinearLRScheduler | CosineLRScheduler | None = None
|
|
185
|
-
# learning rate warmup ratio
|
|
186
|
-
warmup_ratio: float
|
|
187
|
-
# max gradient norm
|
|
188
|
-
max_grad_norm: float
|
|
189
|
-
# weight decay
|
|
190
|
-
weight_decay: float
|
|
191
|
-
# number of checkpoints to save
|
|
192
|
-
n_checkpoints: int | None = None
|
|
193
|
-
# number of evaluation loops to run
|
|
194
|
-
n_evals: int | None = None
|
|
195
|
-
# training batch size
|
|
196
|
-
batch_size: int | None = None
|
|
197
|
-
# up to 40 character suffix for output model name
|
|
198
|
-
suffix: str | None = None
|
|
199
|
-
# weights & biases api key
|
|
200
|
-
wandb_key: str | None = None
|
|
201
|
-
# weights & biases base url
|
|
202
|
-
wandb_base_url: str | None = None
|
|
203
|
-
# wandb project name
|
|
204
|
-
wandb_project_name: str | None = None
|
|
205
|
-
# wandb run name
|
|
206
|
-
wandb_name: str | None = None
|
|
207
|
-
# training type
|
|
208
|
-
training_type: FullTrainingType | LoRATrainingType | None = None
|
|
209
|
-
# training method
|
|
210
|
-
training_method: TrainingMethodSFT | TrainingMethodDPO = Field(
|
|
211
|
-
default_factory=TrainingMethodSFT
|
|
212
|
-
)
|
|
213
|
-
# from step
|
|
214
|
-
from_checkpoint: str | None = None
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
class FinetuneResponse(BaseModel):
|
|
218
|
-
"""
|
|
219
|
-
Fine-tune API response type
|
|
220
|
-
"""
|
|
221
|
-
|
|
222
|
-
# job ID
|
|
223
|
-
id: str | None = None
|
|
224
|
-
# training file id
|
|
225
|
-
training_file: str | None = None
|
|
226
|
-
# validation file id
|
|
227
|
-
validation_file: str | None = None
|
|
228
|
-
# base model name
|
|
229
|
-
model: str | None = None
|
|
230
|
-
# output model name
|
|
231
|
-
output_name: str | None = Field(None, alias="model_output_name")
|
|
232
|
-
# adapter output name
|
|
233
|
-
adapter_output_name: str | None = None
|
|
234
|
-
# number of epochs
|
|
235
|
-
n_epochs: int | None = None
|
|
236
|
-
# number of checkpoints to save
|
|
237
|
-
n_checkpoints: int | None = None
|
|
238
|
-
# number of evaluation loops
|
|
239
|
-
n_evals: int | None = None
|
|
240
|
-
# training batch size
|
|
241
|
-
batch_size: int | None = None
|
|
242
|
-
# training learning rate
|
|
243
|
-
learning_rate: float | None = None
|
|
244
|
-
# learning rate scheduler type and args
|
|
245
|
-
lr_scheduler: LinearLRScheduler | CosineLRScheduler | EmptyLRScheduler | None = None
|
|
246
|
-
# learning rate warmup ratio
|
|
247
|
-
warmup_ratio: float | None = None
|
|
248
|
-
# max gradient norm
|
|
249
|
-
max_grad_norm: float | None = None
|
|
250
|
-
# weight decay
|
|
251
|
-
weight_decay: float | None = None
|
|
252
|
-
# number of steps between evals
|
|
253
|
-
eval_steps: int | None = None
|
|
254
|
-
# training type
|
|
255
|
-
training_type: TrainingType | None = None
|
|
256
|
-
# created/updated datetime stamps
|
|
257
|
-
created_at: str | None = None
|
|
258
|
-
updated_at: str | None = None
|
|
259
|
-
# job status
|
|
260
|
-
status: FinetuneJobStatus | None = None
|
|
261
|
-
# job id
|
|
262
|
-
job_id: str | None = None
|
|
263
|
-
# list of fine-tune events
|
|
264
|
-
events: List[FinetuneEvent] | None = None
|
|
265
|
-
# dataset token count
|
|
266
|
-
token_count: int | None = None
|
|
267
|
-
# model parameter count
|
|
268
|
-
param_count: int | None = None
|
|
269
|
-
# fine-tune job price
|
|
270
|
-
total_price: int | None = None
|
|
271
|
-
# total number of training steps
|
|
272
|
-
total_steps: int | None = None
|
|
273
|
-
# number of steps completed (incrementing counter)
|
|
274
|
-
steps_completed: int | None = None
|
|
275
|
-
# number of epochs completed (incrementing counter)
|
|
276
|
-
epochs_completed: int | None = None
|
|
277
|
-
# number of evaluation loops completed (incrementing counter)
|
|
278
|
-
evals_completed: int | None = None
|
|
279
|
-
# place in job queue (decrementing counter)
|
|
280
|
-
queue_depth: int | None = None
|
|
281
|
-
# weights & biases base url
|
|
282
|
-
wandb_base_url: str | None = None
|
|
283
|
-
# wandb project name
|
|
284
|
-
wandb_project_name: str | None = None
|
|
285
|
-
# wandb run name
|
|
286
|
-
wandb_name: str | None = None
|
|
287
|
-
# weights & biases job url
|
|
288
|
-
wandb_url: str | None = None
|
|
289
|
-
# training file metadata
|
|
290
|
-
training_file_num_lines: int | None = Field(None, alias="TrainingFileNumLines")
|
|
291
|
-
training_file_size: int | None = Field(None, alias="TrainingFileSize")
|
|
292
|
-
train_on_inputs: StrictBool | Literal["auto"] | None = "auto"
|
|
293
|
-
from_checkpoint: str | None = None
|
|
294
|
-
|
|
295
|
-
@field_validator("training_type")
|
|
296
|
-
@classmethod
|
|
297
|
-
def validate_training_type(cls, v: TrainingType) -> TrainingType:
|
|
298
|
-
if v.type == "Full" or v.type == "":
|
|
299
|
-
return FullTrainingType(**v.model_dump())
|
|
300
|
-
elif v.type == "Lora":
|
|
301
|
-
return LoRATrainingType(**v.model_dump())
|
|
302
|
-
else:
|
|
303
|
-
raise ValueError("Unknown training type")
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
class FinetuneList(BaseModel):
|
|
307
|
-
# object type
|
|
308
|
-
object: Literal["list"] | None = None
|
|
309
|
-
# list of fine-tune job objects
|
|
310
|
-
data: List[FinetuneResponse] | None = None
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
class FinetuneListEvents(BaseModel):
|
|
314
|
-
# object type
|
|
315
|
-
object: Literal["list"] | None = None
|
|
316
|
-
# list of fine-tune events
|
|
317
|
-
data: List[FinetuneEvent] | None = None
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
class FinetuneDownloadResult(BaseModel):
|
|
321
|
-
# object type
|
|
322
|
-
object: Literal["local"] | None = None
|
|
323
|
-
# fine-tune job id
|
|
324
|
-
id: str | None = None
|
|
325
|
-
# checkpoint step number
|
|
326
|
-
checkpoint_step: int | None = None
|
|
327
|
-
# local path filename
|
|
328
|
-
filename: str | None = None
|
|
329
|
-
# size in bytes
|
|
330
|
-
size: int | None = None
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
class FinetuneFullTrainingLimits(BaseModel):
|
|
334
|
-
max_batch_size: int
|
|
335
|
-
max_batch_size_dpo: int = -1
|
|
336
|
-
min_batch_size: int
|
|
337
|
-
|
|
338
|
-
def __init__(self, **data: Any) -> None:
|
|
339
|
-
super().__init__(**data)
|
|
340
|
-
if self.max_batch_size_dpo == -1:
|
|
341
|
-
half_max = self.max_batch_size // 2
|
|
342
|
-
rounded_half_max = (half_max // 8) * 8
|
|
343
|
-
self.max_batch_size_dpo = max(self.min_batch_size, rounded_half_max)
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
class FinetuneLoraTrainingLimits(FinetuneFullTrainingLimits):
|
|
347
|
-
max_rank: int
|
|
348
|
-
target_modules: List[str]
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
class FinetuneTrainingLimits(BaseModel):
|
|
352
|
-
max_num_epochs: int
|
|
353
|
-
max_learning_rate: float
|
|
354
|
-
min_learning_rate: float
|
|
355
|
-
full_training: FinetuneFullTrainingLimits | None = None
|
|
356
|
-
lora_training: FinetuneLoraTrainingLimits | None = None
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
class LinearLRSchedulerArgs(BaseModel):
|
|
360
|
-
min_lr_ratio: float | None = 0.0
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
class CosineLRSchedulerArgs(BaseModel):
|
|
364
|
-
min_lr_ratio: float | None = 0.0
|
|
365
|
-
num_cycles: float | None = 0.5
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
class FinetuneLRScheduler(BaseModel):
|
|
369
|
-
lr_scheduler_type: str
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
class LinearLRScheduler(FinetuneLRScheduler):
|
|
373
|
-
lr_scheduler_type: Literal["linear"] = "linear"
|
|
374
|
-
lr_scheduler_args: LinearLRSchedulerArgs | None = None
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
class CosineLRScheduler(FinetuneLRScheduler):
|
|
378
|
-
lr_scheduler_type: Literal["cosine"] = "cosine"
|
|
379
|
-
lr_scheduler_args: CosineLRSchedulerArgs | None = None
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
# placeholder for old fine-tuning jobs with no lr_scheduler_type specified
|
|
383
|
-
class EmptyLRScheduler(FinetuneLRScheduler):
|
|
384
|
-
lr_scheduler_type: Literal[""]
|
|
385
|
-
lr_scheduler_args: None = None
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
class FinetuneCheckpoint(BaseModel):
|
|
389
|
-
"""
|
|
390
|
-
Fine-tuning checkpoint information
|
|
391
|
-
"""
|
|
392
|
-
|
|
393
|
-
# checkpoint type (e.g. "Intermediate", "Final", "Final Merged", "Final Adapter")
|
|
394
|
-
type: str
|
|
395
|
-
# timestamp when the checkpoint was created
|
|
396
|
-
timestamp: str
|
|
397
|
-
# checkpoint name/identifier
|
|
398
|
-
name: str
|
together/types/images.py
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import List, Literal
|
|
4
|
-
|
|
5
|
-
from together.types.abstract import BaseModel
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class ImageRequest(BaseModel):
|
|
9
|
-
# input or list of inputs
|
|
10
|
-
prompt: str
|
|
11
|
-
# model to query
|
|
12
|
-
model: str
|
|
13
|
-
# num generation steps
|
|
14
|
-
steps: int | None = 20
|
|
15
|
-
# seed
|
|
16
|
-
seed: int | None = None
|
|
17
|
-
# number of results to return
|
|
18
|
-
n: int | None = 1
|
|
19
|
-
# pixel height
|
|
20
|
-
height: int | None = 1024
|
|
21
|
-
# pixel width
|
|
22
|
-
width: int | None = 1024
|
|
23
|
-
# negative prompt
|
|
24
|
-
negative_prompt: str | None = None
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class ImageChoicesData(BaseModel):
|
|
28
|
-
# response index
|
|
29
|
-
index: int
|
|
30
|
-
# base64 image response
|
|
31
|
-
b64_json: str | None = None
|
|
32
|
-
# URL hosting image
|
|
33
|
-
url: str | None = None
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
class ImageResponse(BaseModel):
|
|
37
|
-
# job id
|
|
38
|
-
id: str | None = None
|
|
39
|
-
# query model
|
|
40
|
-
model: str | None = None
|
|
41
|
-
# object type
|
|
42
|
-
object: Literal["list"] | None = None
|
|
43
|
-
# list of embedding choices
|
|
44
|
-
data: List[ImageChoicesData] | None = None
|