togethercomputer / together-python

The Official Python Client for Together's API
https://pypi.org/project/together/
Apache License 2.0
21 stars 4 forks source link

Add the example script for data pretokenization #101

Closed mryab closed 3 months ago

mryab commented 3 months ago

This PR provides a minimal example of how to tokenize data locally before submitting it to the Finetuning API. The script supports loss masking (for padding tokens in this case) by adding the labels field.

Running to get the dataset with just labels and the attention mask:

python examples/tokenize_data.py

Running with loss labels as well (padding tokens will have an index of -100 and will be ignored in the loss):

python examples/tokenize_data.py --add-labels --out-filename data_with_labels.parquet

I checked that both together files check and together files upload work with the outputs, the filetype is reported to be Parquet.

TODO: