-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes a bad merge in the tiktoken PR (#619)
- Loading branch information
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,7 +184,7 @@ def build_tokenizer( | |
int(1e30), | ||
) | ||
|
||
return tokenizer | ||
return tokenizer | ||
|
||
|
||
def build_icl_evaluators( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2022 MosaicML LLM Foundry authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import pytest | ||
from transformers import PreTrainedTokenizerBase | ||
|
||
from llmfoundry.tokenizers.tiktoken import TiktokenTokenizerWrapper | ||
from llmfoundry.utils.builders import build_tokenizer | ||
|
||
|
||
@pytest.mark.parametrize('tokenizer_name,tokenizer_kwargs', [ | ||
('tiktoken', { | ||
'model_name': 'gpt-4' | ||
}), | ||
('EleutherAI/gpt-neo-125M', { | ||
'model_max_length': 10 | ||
}), | ||
('mosaicml/mpt-7b', { | ||
'model_max_length': 20 | ||
}), | ||
]) | ||
def test_tokenizer_builder(tokenizer_name: str, tokenizer_kwargs: dict): | ||
tokenizer = build_tokenizer(tokenizer_name, tokenizer_kwargs) | ||
|
||
if tokenizer_name == 'tiktoken': | ||
assert isinstance(tokenizer, TiktokenTokenizerWrapper) | ||
assert tokenizer.model_name == tokenizer_kwargs['model_name'] | ||
else: | ||
assert tokenizer.model_max_length == tokenizer_kwargs[ | ||
'model_max_length'] | ||
assert isinstance(tokenizer, PreTrainedTokenizerBase) |