Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add use_tokenizer_eos option to convert text to mds script #843

Merged
merged 3 commits into from
Jan 8, 2024

Conversation

irenedea
Copy link
Contributor

@irenedea irenedea commented Jan 8, 2024

Manual Test

(1) Make some test files

import os
os.mkdir('in')
for i in range(5):
    with open(f'in/file{i}.txt', 'w') as f:
        f.write(f' HELLO{i} ' * 250)

(2) Run conversion with --use_tokenizer_eos

`python convert_text_to_mds.py --input_folder in --output_folder out --concat_tokens 2048 --tokenizer mosaicml/mpt-7b --use_tokenizer_eos --processes 1`

(3) Print out 0th sample to see the <|endoftext|> token between text sequences

    tokenizer = AutoTokenizer.from_pretrained('mosaicml/mpt-7b')
    dataset = StreamingDataset(local='out', num_canonical_nodes=1)
    sample = dataset[0]
    tokens = np.frombuffer(sample['tokens'], dtype=int)
    decoded = tokenizer.decode(tokens)
    print(decoded)

@irenedea irenedea requested a review from dakinggg January 8, 2024 03:25
scripts/data_prep/convert_text_to_mds.py Show resolved Hide resolved
scripts/data_prep/convert_text_to_mds.py Outdated Show resolved Hide resolved
@irenedea irenedea enabled auto-merge (squash) January 8, 2024 21:32
@irenedea irenedea merged commit c03ca1a into mosaicml:main Jan 8, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants