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

Support for using tiktoken tokenizers #610

Merged
merged 66 commits into from
Sep 21, 2023
Merged

Conversation

dakinggg
Copy link
Collaborator

@dakinggg dakinggg commented Sep 19, 2023

This PR adds support for tiktoken tokenizers via a huggingface compatible wrapper. It is possible that there are pieces of the wrapped implementation that are not perfect, but the unit test coverage should cover the main scenarios that we use.

The tokenizer can be loaded in a yaml via

tokenizer:
    name:
    kwargs:
        model_name: gpt-4
  • merge implementation with jeremy's previous PR

@dakinggg dakinggg marked this pull request as ready for review September 20, 2023 02:35
@mvpatel2000 mvpatel2000 self-requested a review September 20, 2023 20:52
llmfoundry/tokenizers/tiktoken.py Show resolved Hide resolved
llmfoundry/tokenizers/tiktoken.py Show resolved Hide resolved
llmfoundry/tokenizers/tiktoken.py Show resolved Hide resolved
llmfoundry/tokenizers/tiktoken.py Show resolved Hide resolved
@dakinggg
Copy link
Collaborator Author

wait for #616 before merging this

Copy link
Contributor

@irenedea irenedea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, pending minor comments + pyright.import_or_skip() is skipping the tests on CI.

feel free to address in a follow up PR

llmfoundry/tokenizers/tiktoken.py Show resolved Hide resolved
llmfoundry/tokenizers/tiktoken.py Show resolved Hide resolved
tests/test_tiktoken.py Show resolved Hide resolved
scripts/data_prep/convert_dataset_hf.py Outdated Show resolved Hide resolved
llmfoundry/utils/builders.py Show resolved Hide resolved
Copy link
Member

@abhi-mosaic abhi-mosaic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the tests carefully, and added some comments.

Also, do we need to add tiktoken as a dependency in setup.py?

tests/test_tiktoken.py Outdated Show resolved Hide resolved
tests/test_tiktoken.py Outdated Show resolved Hide resolved
@dakinggg
Copy link
Collaborator Author

@abhi-mosaic tiktoken is added as an optional dep group already

llmfoundry/tokenizers/tiktoken.py Show resolved Hide resolved
tests/test_tiktoken.py Outdated Show resolved Hide resolved
@dakinggg dakinggg enabled auto-merge (squash) September 20, 2023 23:57
@dakinggg dakinggg merged commit a8e8783 into mosaicml:main Sep 21, 2023
9 checks passed
@dakinggg dakinggg deleted the tiktoken branch October 11, 2023 23:05
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.

None yet

6 participants