together 0.2.5__tar.gz → 0.2.7__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-0.2.5 → together-0.2.7}/PKG-INFO +68 -225
- {together-0.2.5 → together-0.2.7}/README.md +48 -6
- {together-0.2.5 → together-0.2.7}/pyproject.toml +34 -19
- {together-0.2.5 → together-0.2.7}/src/together/__init__.py +16 -0
- {together-0.2.5 → together-0.2.7}/src/together/cli/cli.py +2 -1
- {together-0.2.5 → together-0.2.7}/src/together/commands/chat.py +20 -12
- {together-0.2.5 → together-0.2.7}/src/together/commands/complete.py +34 -26
- together-0.2.7/src/together/commands/embeddings.py +48 -0
- {together-0.2.5 → together-0.2.7}/src/together/commands/files.py +75 -9
- {together-0.2.5 → together-0.2.7}/src/together/commands/finetune.py +132 -117
- {together-0.2.5 → together-0.2.7}/src/together/commands/image.py +14 -11
- {together-0.2.5 → together-0.2.7}/src/together/commands/models.py +81 -16
- {together-0.2.5 → together-0.2.7}/src/together/complete.py +2 -4
- together-0.2.7/src/together/embeddings.py +35 -0
- {together-0.2.5 → together-0.2.7}/src/together/error.py +4 -0
- {together-0.2.5 → together-0.2.7}/src/together/files.py +12 -9
- {together-0.2.5 → together-0.2.7}/src/together/finetune.py +23 -48
- {together-0.2.5 → together-0.2.7}/src/together/image.py +1 -2
- {together-0.2.5 → together-0.2.7}/src/together/models.py +5 -10
- {together-0.2.5 → together-0.2.7}/src/together/utils.py +35 -23
- together-0.2.7/src/together/version.py +6 -0
- together-0.2.5/.github/workflows/check_code_quality.yml +0 -54
- together-0.2.5/.github/workflows/rdme-docs.yml +0 -22
- together-0.2.5/.github/workflows/upload-to-pypi.yml +0 -33
- together-0.2.5/.gitignore +0 -129
- together-0.2.5/examples/antihallucination.jsonl +0 -238
- together-0.2.5/examples/jokes_dataset.json +0 -304
- together-0.2.5/examples/jokes_example.py +0 -14
- together-0.2.5/src/together/version.py +0 -1
- {together-0.2.5 → together-0.2.7}/LICENSE +0 -0
- {together-0.2.5 → together-0.2.7}/src/together/cli/__init__.py +0 -0
- {together-0.2.5 → together-0.2.7}/src/together/commands/__init__.py +0 -0
- {together-0.2.5 → together-0.2.7}/src/together/tools/__init__.py +0 -0
- {together-0.2.5 → together-0.2.7}/src/together/tools/conversation.py +0 -0
|
@@ -1,228 +1,28 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: together
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: Python client for Together's Cloud Platform!
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Author
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
http://www.apache.org/licenses/
|
|
11
|
-
|
|
12
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
13
|
-
|
|
14
|
-
1. Definitions.
|
|
15
|
-
|
|
16
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
17
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
18
|
-
|
|
19
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
20
|
-
the copyright owner that is granting the License.
|
|
21
|
-
|
|
22
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
23
|
-
other entities that control, are controlled by, or are under common
|
|
24
|
-
control with that entity. For the purposes of this definition,
|
|
25
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
26
|
-
direction or management of such entity, whether by contract or
|
|
27
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
28
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
29
|
-
|
|
30
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
31
|
-
exercising permissions granted by this License.
|
|
32
|
-
|
|
33
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
34
|
-
including but not limited to software source code, documentation
|
|
35
|
-
source, and configuration files.
|
|
36
|
-
|
|
37
|
-
"Object" form shall mean any form resulting from mechanical
|
|
38
|
-
transformation or translation of a Source form, including but
|
|
39
|
-
not limited to compiled object code, generated documentation,
|
|
40
|
-
and conversions to other media types.
|
|
41
|
-
|
|
42
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
43
|
-
Object form, made available under the License, as indicated by a
|
|
44
|
-
copyright notice that is included in or attached to the work
|
|
45
|
-
(an example is provided in the Appendix below).
|
|
46
|
-
|
|
47
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
48
|
-
form, that is based on (or derived from) the Work and for which the
|
|
49
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
50
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
51
|
-
of this License, Derivative Works shall not include works that remain
|
|
52
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
53
|
-
the Work and Derivative Works thereof.
|
|
54
|
-
|
|
55
|
-
"Contribution" shall mean any work of authorship, including
|
|
56
|
-
the original version of the Work and any modifications or additions
|
|
57
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
58
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
59
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
60
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
61
|
-
means any form of electronic, verbal, or written communication sent
|
|
62
|
-
to the Licensor or its representatives, including but not limited to
|
|
63
|
-
communication on electronic mailing lists, source code control systems,
|
|
64
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
65
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
66
|
-
excluding communication that is conspicuously marked or otherwise
|
|
67
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
68
|
-
|
|
69
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
70
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
71
|
-
subsequently incorporated within the Work.
|
|
72
|
-
|
|
73
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
77
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
78
|
-
Work and such Derivative Works in Source or Object form.
|
|
79
|
-
|
|
80
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
81
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
82
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
83
|
-
(except as stated in this section) patent license to make, have made,
|
|
84
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
85
|
-
where such license applies only to those patent claims licensable
|
|
86
|
-
by such Contributor that are necessarily infringed by their
|
|
87
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
88
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
89
|
-
institute patent litigation against any entity (including a
|
|
90
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
91
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
92
|
-
or contributory patent infringement, then any patent licenses
|
|
93
|
-
granted to You under this License for that Work shall terminate
|
|
94
|
-
as of the date such litigation is filed.
|
|
95
|
-
|
|
96
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
97
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
98
|
-
modifications, and in Source or Object form, provided that You
|
|
99
|
-
meet the following conditions:
|
|
100
|
-
|
|
101
|
-
(a) You must give any other recipients of the Work or
|
|
102
|
-
Derivative Works a copy of this License; and
|
|
103
|
-
|
|
104
|
-
(b) You must cause any modified files to carry prominent notices
|
|
105
|
-
stating that You changed the files; and
|
|
106
|
-
|
|
107
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
108
|
-
that You distribute, all copyright, patent, trademark, and
|
|
109
|
-
attribution notices from the Source form of the Work,
|
|
110
|
-
excluding those notices that do not pertain to any part of
|
|
111
|
-
the Derivative Works; and
|
|
112
|
-
|
|
113
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
114
|
-
distribution, then any Derivative Works that You distribute must
|
|
115
|
-
include a readable copy of the attribution notices contained
|
|
116
|
-
within such NOTICE file, excluding those notices that do not
|
|
117
|
-
pertain to any part of the Derivative Works, in at least one
|
|
118
|
-
of the following places: within a NOTICE text file distributed
|
|
119
|
-
as part of the Derivative Works; within the Source form or
|
|
120
|
-
documentation, if provided along with the Derivative Works; or,
|
|
121
|
-
within a display generated by the Derivative Works, if and
|
|
122
|
-
wherever such third-party notices normally appear. The contents
|
|
123
|
-
of the NOTICE file are for informational purposes only and
|
|
124
|
-
do not modify the License. You may add Your own attribution
|
|
125
|
-
notices within Derivative Works that You distribute, alongside
|
|
126
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
127
|
-
that such additional attribution notices cannot be construed
|
|
128
|
-
as modifying the License.
|
|
129
|
-
|
|
130
|
-
You may add Your own copyright statement to Your modifications and
|
|
131
|
-
may provide additional or different license terms and conditions
|
|
132
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
133
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
134
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
135
|
-
the conditions stated in this License.
|
|
136
|
-
|
|
137
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
138
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
139
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
140
|
-
this License, without any additional terms or conditions.
|
|
141
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
142
|
-
the terms of any separate license agreement you may have executed
|
|
143
|
-
with Licensor regarding such Contributions.
|
|
144
|
-
|
|
145
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
146
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
147
|
-
except as required for reasonable and customary use in describing the
|
|
148
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
149
|
-
|
|
150
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
151
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
152
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
153
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
154
|
-
implied, including, without limitation, any warranties or conditions
|
|
155
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
156
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
157
|
-
appropriateness of using or redistributing the Work and assume any
|
|
158
|
-
risks associated with Your exercise of permissions under this License.
|
|
159
|
-
|
|
160
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
161
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
162
|
-
unless required by applicable law (such as deliberate and grossly
|
|
163
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
164
|
-
liable to You for damages, including any direct, indirect, special,
|
|
165
|
-
incidental, or consequential damages of any character arising as a
|
|
166
|
-
result of this License or out of the use or inability to use the
|
|
167
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
168
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
169
|
-
other commercial damages or losses), even if such Contributor
|
|
170
|
-
has been advised of the possibility of such damages.
|
|
171
|
-
|
|
172
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
173
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
174
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
175
|
-
or other liability obligations and/or rights consistent with this
|
|
176
|
-
License. However, in accepting such obligations, You may act only
|
|
177
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
178
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
179
|
-
defend, and hold each Contributor harmless for any liability
|
|
180
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
181
|
-
of your accepting any such warranty or additional liability.
|
|
182
|
-
|
|
183
|
-
END OF TERMS AND CONDITIONS
|
|
184
|
-
|
|
185
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
186
|
-
|
|
187
|
-
To apply the Apache License to your work, attach the following
|
|
188
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
189
|
-
replaced with your own identifying information. (Don't include
|
|
190
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
191
|
-
comment syntax for the file format. We also recommend that a
|
|
192
|
-
file or class name and description of purpose be included on the
|
|
193
|
-
same "printed page" as the copyright notice for easier
|
|
194
|
-
identification within third-party archives.
|
|
195
|
-
|
|
196
|
-
Copyright [yyyy] [name of copyright owner]
|
|
197
|
-
|
|
198
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
199
|
-
you may not use this file except in compliance with the License.
|
|
200
|
-
You may obtain a copy of the License at
|
|
201
|
-
|
|
202
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
203
|
-
|
|
204
|
-
Unless required by applicable law or agreed to in writing, software
|
|
205
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
206
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
207
|
-
See the License for the specific language governing permissions and
|
|
208
|
-
limitations under the License.
|
|
209
|
-
License-File: LICENSE
|
|
5
|
+
Home-page: https://github.com/togethercomputer/together
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Author: Together AI
|
|
8
|
+
Author-email: support@together.ai
|
|
9
|
+
Requires-Python: >=3.7,<4.0
|
|
210
10
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
211
11
|
Classifier: Operating System :: POSIX :: Linux
|
|
212
12
|
Classifier: Programming Language :: Python :: 3
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
Requires-Dist:
|
|
220
|
-
Requires-Dist:
|
|
221
|
-
Requires-Dist:
|
|
222
|
-
Requires-Dist:
|
|
223
|
-
Requires-Dist:
|
|
224
|
-
|
|
225
|
-
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Requires-Dist: requests (>=2.31.0,<3.0.0)
|
|
20
|
+
Requires-Dist: sseclient-py (>=1.7.2,<2.0.0)
|
|
21
|
+
Requires-Dist: tabulate (>=0.9.0,<0.10.0)
|
|
22
|
+
Requires-Dist: tqdm (>=4.66.1,<5.0.0)
|
|
23
|
+
Requires-Dist: typer (>=0.9.0,<0.10.0)
|
|
24
|
+
Project-URL: Bug Tracker, https://github.com/togethercomputer/together/issues
|
|
25
|
+
Project-URL: Repository, https://github.com/togethercomputer/together
|
|
226
26
|
Description-Content-Type: text/markdown
|
|
227
27
|
|
|
228
28
|
The [Together Python Library](https://pypi.org/project/together/) is the official Python client for Together's API platform, providing a convenient way for interacting with the Together APIs and enables easy integration of the inference API with your applications.
|
|
@@ -554,7 +354,34 @@ Job creation details:
|
|
|
554
354
|
Do you want to submit the job? [y/N]
|
|
555
355
|
```
|
|
556
356
|
|
|
557
|
-
|
|
357
|
+
Here is an example of only part of the `resp` response to highlight some of the useful information about your finetune job.
|
|
358
|
+
|
|
359
|
+
```
|
|
360
|
+
{ 'Suffix': 'my-demo-finetune',
|
|
361
|
+
'batch_size': 4,
|
|
362
|
+
'created_at': '2023-11-07T19:04:30.579Z',
|
|
363
|
+
'enable_checkpoints': False,
|
|
364
|
+
'epochs_completed': 0,
|
|
365
|
+
'events': [ { 'checkpoint_path': '',
|
|
366
|
+
'created_at': '2023-11-07T19:04:30.579Z',
|
|
367
|
+
'hash': '',
|
|
368
|
+
'level': '',
|
|
369
|
+
'message': 'Fine tune request created',
|
|
370
|
+
'model_path': '',
|
|
371
|
+
'object': 'fine-tune-event',
|
|
372
|
+
'param_count': 0,
|
|
373
|
+
'token_count': 0,
|
|
374
|
+
'training_offset': 0,
|
|
375
|
+
'type': 'JOB_PENDING',
|
|
376
|
+
'wandb_url': ''}],
|
|
377
|
+
'id': 'ft-494cbd75-3057-44b4-8186-045c14be8d03',
|
|
378
|
+
'learning_rate': 1e-05,
|
|
379
|
+
'model': 'togethercomputer/RedPajama-INCITE-Chat-3B-v1',
|
|
380
|
+
'model_output_name': 'carson/RedPajama-INCITE-Chat-3B-v1-my-demo-finetune-2023-11-07-19-04-30',
|
|
381
|
+
'wandb_url': '...'}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
The response `resp` has alot of information for you that you can retrieve again later with `together.Finetune.retrieve` using the `fine_tune_id` for this job. You can find this `fine_tune_id` in `resp['id']` and use it to check in on how your finetune job is doing.
|
|
558
385
|
|
|
559
386
|
```python
|
|
560
387
|
print(together.Finetune.retrieve(fine_tune_id=fine_tune_id)) # retrieves information on finetune event
|
|
@@ -563,14 +390,16 @@ print(together.Finetune.is_final_model_available(fine_tune_id=fine_tune_id)) # T
|
|
|
563
390
|
print(together.Finetune.get_checkpoints(fine_tune_id=fine_tune_id)) # list of checkpoints
|
|
564
391
|
```
|
|
565
392
|
|
|
566
|
-
The `get_job_status` should change from `pending` to `running` to `completed` as `is_final_model_available` changes from `False` to `True`. Once the
|
|
393
|
+
The `get_job_status` should change from `pending` to `running` to `completed` as `is_final_model_available` changes from `False` to `True`. Once in the `running` state, you can retrieve the `wandb_url` and visit this page to monitor the learning progress of this finetune job.
|
|
394
|
+
|
|
395
|
+
Under `model_output_name` you will find the unique name that will be given to the new finetuned model whose creation is underway. This name includes your username, the base model name, your suffix and the datetime the job was created. In addition to using the API to track the status as shown above, you can use `model_output_name` to find helpful features related to the new model within the Jobs section of your account on our webpage.
|
|
567
396
|
|
|
568
|
-
`
|
|
397
|
+
Once the final model is available, you should be able to see your new model under `together.Models.list()` under `model_output_name`.
|
|
569
398
|
|
|
570
399
|
Now you can download your model using `together.Finetune.download(fine_tune_id)` or start using your model on our inference engine (may take a few minutes after finetuning to become available) by first starting your new model instance:
|
|
571
400
|
|
|
572
401
|
```
|
|
573
|
-
together.Models.start(
|
|
402
|
+
together.Models.start(model_output_name)
|
|
574
403
|
```
|
|
575
404
|
|
|
576
405
|
then calling it to do completions:
|
|
@@ -578,14 +407,14 @@ then calling it to do completions:
|
|
|
578
407
|
```
|
|
579
408
|
output = together.Complete.create(
|
|
580
409
|
prompt = "Isaac Asimov's Three Laws of Robotics are:\n\n1. ",
|
|
581
|
-
model =
|
|
410
|
+
model = model_output_name,
|
|
582
411
|
)
|
|
583
412
|
```
|
|
584
413
|
|
|
585
414
|
To check whether your model is finished deploying, you can use the `Models.ready` like so:
|
|
586
415
|
|
|
587
416
|
```
|
|
588
|
-
together.Models.ready(
|
|
417
|
+
together.Models.ready(model_output_name)
|
|
589
418
|
```
|
|
590
419
|
|
|
591
420
|
```
|
|
@@ -651,6 +480,16 @@ print(output_text)
|
|
|
651
480
|
Space Robots are a great way to get your kids interested in science. After all, they are the future!
|
|
652
481
|
```
|
|
653
482
|
|
|
483
|
+
## Embeddings API
|
|
484
|
+
|
|
485
|
+
Embeddings are vector representations of sequences. You can use these vectors for measuring the overall similarity between texts. Embeddings are useful for tasks such as search and retrieval.
|
|
486
|
+
|
|
487
|
+
```python
|
|
488
|
+
resp = together.Embeddings.create("embed this sentence into a single vector", model="togethercomputer/bert-base-uncased")
|
|
489
|
+
|
|
490
|
+
print(resp['data'][0]['embedding']) # [0.06659205, 0.07896972, 0.007910785 ........]
|
|
491
|
+
```
|
|
492
|
+
|
|
654
493
|
## Colab Tutorial
|
|
655
494
|
|
|
656
495
|
Follow along in our Colab (Google Colaboratory) Notebook Tutorial [Example Finetuning Project](https://colab.research.google.com/drive/11DwtftycpDSgp3Z1vnV-Cy68zvkGZL4K?usp=sharing).
|
|
@@ -710,6 +549,9 @@ together finetune download ft-dd93c727-f35e-41c2-a370-7d55b54128fa
|
|
|
710
549
|
|
|
711
550
|
# inference using your new finetuned model (with new finetuned model name from together models list)
|
|
712
551
|
together complete "Space robots are" -m yourname/ft-dd93c727-f35e-41c2-a370-7d55b54128fa-2023-08-16-10-15-09
|
|
552
|
+
|
|
553
|
+
# create an embedding from your input sequence
|
|
554
|
+
together embeddings "embed this sentence into a single vector" -m togethercomputer/bert-base-uncased
|
|
713
555
|
```
|
|
714
556
|
|
|
715
557
|
## Contributing
|
|
@@ -721,3 +563,4 @@ together complete "Space robots are" -m yourname/ft-dd93c727-f35e-41c2-a370-7d55
|
|
|
721
563
|
- And if necessary, `ruff . --fix`
|
|
722
564
|
- `mypy --strict .`
|
|
723
565
|
4. Create a PR
|
|
566
|
+
|
|
@@ -327,7 +327,34 @@ Job creation details:
|
|
|
327
327
|
Do you want to submit the job? [y/N]
|
|
328
328
|
```
|
|
329
329
|
|
|
330
|
-
|
|
330
|
+
Here is an example of only part of the `resp` response to highlight some of the useful information about your finetune job.
|
|
331
|
+
|
|
332
|
+
```
|
|
333
|
+
{ 'Suffix': 'my-demo-finetune',
|
|
334
|
+
'batch_size': 4,
|
|
335
|
+
'created_at': '2023-11-07T19:04:30.579Z',
|
|
336
|
+
'enable_checkpoints': False,
|
|
337
|
+
'epochs_completed': 0,
|
|
338
|
+
'events': [ { 'checkpoint_path': '',
|
|
339
|
+
'created_at': '2023-11-07T19:04:30.579Z',
|
|
340
|
+
'hash': '',
|
|
341
|
+
'level': '',
|
|
342
|
+
'message': 'Fine tune request created',
|
|
343
|
+
'model_path': '',
|
|
344
|
+
'object': 'fine-tune-event',
|
|
345
|
+
'param_count': 0,
|
|
346
|
+
'token_count': 0,
|
|
347
|
+
'training_offset': 0,
|
|
348
|
+
'type': 'JOB_PENDING',
|
|
349
|
+
'wandb_url': ''}],
|
|
350
|
+
'id': 'ft-494cbd75-3057-44b4-8186-045c14be8d03',
|
|
351
|
+
'learning_rate': 1e-05,
|
|
352
|
+
'model': 'togethercomputer/RedPajama-INCITE-Chat-3B-v1',
|
|
353
|
+
'model_output_name': 'carson/RedPajama-INCITE-Chat-3B-v1-my-demo-finetune-2023-11-07-19-04-30',
|
|
354
|
+
'wandb_url': '...'}
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
The response `resp` has alot of information for you that you can retrieve again later with `together.Finetune.retrieve` using the `fine_tune_id` for this job. You can find this `fine_tune_id` in `resp['id']` and use it to check in on how your finetune job is doing.
|
|
331
358
|
|
|
332
359
|
```python
|
|
333
360
|
print(together.Finetune.retrieve(fine_tune_id=fine_tune_id)) # retrieves information on finetune event
|
|
@@ -336,14 +363,16 @@ print(together.Finetune.is_final_model_available(fine_tune_id=fine_tune_id)) # T
|
|
|
336
363
|
print(together.Finetune.get_checkpoints(fine_tune_id=fine_tune_id)) # list of checkpoints
|
|
337
364
|
```
|
|
338
365
|
|
|
339
|
-
The `get_job_status` should change from `pending` to `running` to `completed` as `is_final_model_available` changes from `False` to `True`. Once the
|
|
366
|
+
The `get_job_status` should change from `pending` to `running` to `completed` as `is_final_model_available` changes from `False` to `True`. Once in the `running` state, you can retrieve the `wandb_url` and visit this page to monitor the learning progress of this finetune job.
|
|
340
367
|
|
|
341
|
-
`
|
|
368
|
+
Under `model_output_name` you will find the unique name that will be given to the new finetuned model whose creation is underway. This name includes your username, the base model name, your suffix and the datetime the job was created. In addition to using the API to track the status as shown above, you can use `model_output_name` to find helpful features related to the new model within the Jobs section of your account on our webpage.
|
|
369
|
+
|
|
370
|
+
Once the final model is available, you should be able to see your new model under `together.Models.list()` under `model_output_name`.
|
|
342
371
|
|
|
343
372
|
Now you can download your model using `together.Finetune.download(fine_tune_id)` or start using your model on our inference engine (may take a few minutes after finetuning to become available) by first starting your new model instance:
|
|
344
373
|
|
|
345
374
|
```
|
|
346
|
-
together.Models.start(
|
|
375
|
+
together.Models.start(model_output_name)
|
|
347
376
|
```
|
|
348
377
|
|
|
349
378
|
then calling it to do completions:
|
|
@@ -351,14 +380,14 @@ then calling it to do completions:
|
|
|
351
380
|
```
|
|
352
381
|
output = together.Complete.create(
|
|
353
382
|
prompt = "Isaac Asimov's Three Laws of Robotics are:\n\n1. ",
|
|
354
|
-
model =
|
|
383
|
+
model = model_output_name,
|
|
355
384
|
)
|
|
356
385
|
```
|
|
357
386
|
|
|
358
387
|
To check whether your model is finished deploying, you can use the `Models.ready` like so:
|
|
359
388
|
|
|
360
389
|
```
|
|
361
|
-
together.Models.ready(
|
|
390
|
+
together.Models.ready(model_output_name)
|
|
362
391
|
```
|
|
363
392
|
|
|
364
393
|
```
|
|
@@ -424,6 +453,16 @@ print(output_text)
|
|
|
424
453
|
Space Robots are a great way to get your kids interested in science. After all, they are the future!
|
|
425
454
|
```
|
|
426
455
|
|
|
456
|
+
## Embeddings API
|
|
457
|
+
|
|
458
|
+
Embeddings are vector representations of sequences. You can use these vectors for measuring the overall similarity between texts. Embeddings are useful for tasks such as search and retrieval.
|
|
459
|
+
|
|
460
|
+
```python
|
|
461
|
+
resp = together.Embeddings.create("embed this sentence into a single vector", model="togethercomputer/bert-base-uncased")
|
|
462
|
+
|
|
463
|
+
print(resp['data'][0]['embedding']) # [0.06659205, 0.07896972, 0.007910785 ........]
|
|
464
|
+
```
|
|
465
|
+
|
|
427
466
|
## Colab Tutorial
|
|
428
467
|
|
|
429
468
|
Follow along in our Colab (Google Colaboratory) Notebook Tutorial [Example Finetuning Project](https://colab.research.google.com/drive/11DwtftycpDSgp3Z1vnV-Cy68zvkGZL4K?usp=sharing).
|
|
@@ -483,6 +522,9 @@ together finetune download ft-dd93c727-f35e-41c2-a370-7d55b54128fa
|
|
|
483
522
|
|
|
484
523
|
# inference using your new finetuned model (with new finetuned model name from together models list)
|
|
485
524
|
together complete "Space robots are" -m yourname/ft-dd93c727-f35e-41c2-a370-7d55b54128fa-2023-08-16-10-15-09
|
|
525
|
+
|
|
526
|
+
# create an embedding from your input sequence
|
|
527
|
+
together embeddings "embed this sentence into a single vector" -m togethercomputer/bert-base-uncased
|
|
486
528
|
```
|
|
487
529
|
|
|
488
530
|
## Contributing
|
|
@@ -1,39 +1,54 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["
|
|
3
|
-
build-backend = "
|
|
2
|
+
requires = ["poetry"]
|
|
3
|
+
build-backend = "poetry.masonry.api"
|
|
4
4
|
|
|
5
|
-
[
|
|
5
|
+
[tool.poetry]
|
|
6
6
|
name = "together"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.7"
|
|
8
8
|
authors = [
|
|
9
|
-
|
|
9
|
+
"Together AI <support@together.ai>"
|
|
10
10
|
]
|
|
11
11
|
description = "Python client for Together's Cloud Platform!"
|
|
12
12
|
readme = "README.md"
|
|
13
|
-
license =
|
|
14
|
-
requires-python = ">=3.6"
|
|
13
|
+
license = "Apache-2.0"
|
|
15
14
|
classifiers = [
|
|
16
15
|
"Programming Language :: Python :: 3",
|
|
17
16
|
"License :: OSI Approved :: Apache Software License",
|
|
18
17
|
"Operating System :: POSIX :: Linux",
|
|
19
18
|
]
|
|
19
|
+
repository = "https://github.com/togethercomputer/together"
|
|
20
|
+
homepage = "https://github.com/togethercomputer/together"
|
|
20
21
|
|
|
21
|
-
dependencies
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
[tool.poetry.dependencies]
|
|
23
|
+
python = "^3.7"
|
|
24
|
+
typer = "^0.9.0"
|
|
25
|
+
requests = "^2.31.0"
|
|
26
|
+
tqdm = "^4.66.1"
|
|
27
|
+
sseclient-py = "^1.7.2"
|
|
28
|
+
tabulate = "^0.9.0"
|
|
29
|
+
|
|
30
|
+
[tool.poetry.group.quality]
|
|
31
|
+
optional = true
|
|
32
|
+
|
|
33
|
+
[tool.poetry.group.quality.dependencies]
|
|
34
|
+
black = "^23.1"
|
|
35
|
+
ruff = "^0.0.241"
|
|
36
|
+
mypy = "^1.3.0"
|
|
37
|
+
types-requests = "^2.31.0.1"
|
|
38
|
+
types-tqdm = "^4.65.0.0"
|
|
39
|
+
types-tabulate = "^0.9.0.3"
|
|
40
|
+
|
|
41
|
+
[tool.poetry.group.tests]
|
|
42
|
+
optional = true
|
|
27
43
|
|
|
28
|
-
[
|
|
29
|
-
|
|
30
|
-
tokenize = ["transformers>=4.33.2"]
|
|
44
|
+
[tool.poetry.group.tests.dependencies]
|
|
45
|
+
pytest = "^7.4.2"
|
|
31
46
|
|
|
32
|
-
[
|
|
47
|
+
[tool.poetry.urls]
|
|
33
48
|
"Homepage" = "https://github.com/togethercomputer/together"
|
|
34
49
|
"Bug Tracker" = "https://github.com/togethercomputer/together/issues"
|
|
35
50
|
|
|
36
|
-
[
|
|
51
|
+
[tool.poetry.scripts]
|
|
37
52
|
together = "together.cli.cli:main"
|
|
38
53
|
|
|
39
54
|
[tool.black]
|
|
@@ -52,6 +67,6 @@ select = ["C", "E", "F", "I", "W"]
|
|
|
52
67
|
lines-after-imports = 2
|
|
53
68
|
known-first-party = ["together"]
|
|
54
69
|
|
|
55
|
-
[mypy]
|
|
70
|
+
[tool.mypy]
|
|
56
71
|
strict = true
|
|
57
72
|
mypy_path = "."
|
|
@@ -16,14 +16,24 @@ api_base_complete = urllib.parse.urljoin(api_base, "/api/inference")
|
|
|
16
16
|
api_base_files = urllib.parse.urljoin(api_base, "/v1/files/")
|
|
17
17
|
api_base_finetune = urllib.parse.urljoin(api_base, "/v1/fine-tunes/")
|
|
18
18
|
api_base_instances = urllib.parse.urljoin(api_base, "instances/")
|
|
19
|
+
api_base_embeddings = urllib.parse.urljoin(api_base, "api/v1/embeddings")
|
|
19
20
|
|
|
20
21
|
default_text_model = "togethercomputer/RedPajama-INCITE-7B-Chat"
|
|
21
22
|
default_image_model = "runwayml/stable-diffusion-v1-5"
|
|
23
|
+
default_embedding_model = "togethercomputer/bert-base-uncased"
|
|
22
24
|
log_level = "WARNING"
|
|
23
25
|
|
|
26
|
+
MISSING_API_KEY_MESSAGE = """TOGETHER_API_KEY not found.
|
|
27
|
+
Please set it as an environment variable or set it as together.api_key
|
|
28
|
+
Find your TOGETHER_API_KEY at https://api.together.xyz/settings/api-keys"""
|
|
29
|
+
|
|
30
|
+
MAX_CONNECTION_RETRIES = 2
|
|
31
|
+
BACKOFF_FACTOR = 0.2
|
|
32
|
+
|
|
24
33
|
min_samples = 100
|
|
25
34
|
|
|
26
35
|
from .complete import Complete
|
|
36
|
+
from .embeddings import Embeddings
|
|
27
37
|
from .error import *
|
|
28
38
|
from .files import Files
|
|
29
39
|
from .finetune import Finetune
|
|
@@ -38,12 +48,18 @@ __all__ = [
|
|
|
38
48
|
"api_base_files",
|
|
39
49
|
"api_base_finetune",
|
|
40
50
|
"api_base_instances",
|
|
51
|
+
"api_base_embeddings",
|
|
41
52
|
"default_text_model",
|
|
42
53
|
"default_image_model",
|
|
54
|
+
"default_embedding_model",
|
|
43
55
|
"Models",
|
|
44
56
|
"Complete",
|
|
45
57
|
"Files",
|
|
46
58
|
"Finetune",
|
|
47
59
|
"Image",
|
|
60
|
+
"Embeddings",
|
|
61
|
+
"MAX_CONNECTION_RETRIES",
|
|
62
|
+
"MISSING_API_KEY_MESSAGE",
|
|
63
|
+
"BACKOFF_FACTOR",
|
|
48
64
|
"min_samples",
|
|
49
65
|
]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import argparse
|
|
3
3
|
|
|
4
4
|
import together
|
|
5
|
-
from together.commands import chat, complete, files, finetune, image, models
|
|
5
|
+
from together.commands import chat, complete, embeddings, files, finetune, image, models
|
|
6
6
|
from together.utils import get_logger
|
|
7
7
|
|
|
8
8
|
|
|
@@ -49,6 +49,7 @@ def main() -> None:
|
|
|
49
49
|
image.add_parser(subparser)
|
|
50
50
|
files.add_parser(subparser)
|
|
51
51
|
finetune.add_parser(subparser)
|
|
52
|
+
embeddings.add_parser(subparser)
|
|
52
53
|
|
|
53
54
|
args = parser.parse_args()
|
|
54
55
|
|
|
@@ -6,6 +6,10 @@ import cmd
|
|
|
6
6
|
import together
|
|
7
7
|
import together.tools.conversation as convo
|
|
8
8
|
from together import Complete
|
|
9
|
+
from together.utils import get_logger
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
logger = get_logger(str(__name__))
|
|
9
13
|
|
|
10
14
|
|
|
11
15
|
def add_parser(subparsers: argparse._SubParsersAction[argparse.ArgumentParser]) -> None:
|
|
@@ -99,18 +103,22 @@ class OpenChatKitShell(cmd.Cmd):
|
|
|
99
103
|
def do_say(self, arg: str) -> None:
|
|
100
104
|
self._convo.push_human_turn(arg)
|
|
101
105
|
output = ""
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
try:
|
|
107
|
+
for token in self.infer.create_streaming(
|
|
108
|
+
prompt=self._convo.get_raw_prompt(),
|
|
109
|
+
model=self.args.model,
|
|
110
|
+
max_tokens=self.args.max_tokens,
|
|
111
|
+
stop=self.args.stop,
|
|
112
|
+
temperature=self.args.temperature,
|
|
113
|
+
top_p=self.args.top_p,
|
|
114
|
+
top_k=self.args.top_k,
|
|
115
|
+
repetition_penalty=self.args.repetition_penalty,
|
|
116
|
+
):
|
|
117
|
+
print(token, end="", flush=True)
|
|
118
|
+
output += token
|
|
119
|
+
except together.AuthenticationError:
|
|
120
|
+
logger.critical(together.MISSING_API_KEY_MESSAGE)
|
|
121
|
+
exit(0)
|
|
114
122
|
print("\n")
|
|
115
123
|
self._convo.push_model_response(output)
|
|
116
124
|
|