Open
Conversation
| TIKTOKEN_VOCAB_FILE = "tokenizer.model" | ||
|
|
||
|
|
||
| def _validate_tokenizer_components(tokenizer_class, tokenizer_json_path): |
Collaborator
There was a problem hiding this comment.
Suggested change
| def _validate_tokenizer_components(tokenizer_class, tokenizer_json_path): | |
| def _validate_tokenizer_components(tokenizer_instance tokenizer_json_path): |
will do ourselves a favor IMO to have an instance
| } | ||
|
|
||
| # Compare and warn on mismatches | ||
| mismatches = [] |
Collaborator
There was a problem hiding this comment.
Suggested change
| mismatches = [] | |
| mismatches = set(expected_components) - set(json_components) |
Comment on lines
+109
to
+113
| for name in ["normalizer", "pre_tokenizer", "decoder", "model"]: | ||
| json_val = json_components[name] | ||
| expected_val = expected_components[name] | ||
| if json_val != expected_val: | ||
| mismatches.append(f"{name}: expected {expected_val}, found {json_val}") |
Collaborator
There was a problem hiding this comment.
Suggested change
| for name in ["normalizer", "pre_tokenizer", "decoder", "model"]: | |
| json_val = json_components[name] | |
| expected_val = expected_components[name] | |
| if json_val != expected_val: | |
| mismatches.append(f"{name}: expected {expected_val}, found {json_val}") |
Collaborator
Author
There was a problem hiding this comment.
how do we check if they match?
Collaborator
There was a problem hiding this comment.
with m y above:
set(expected_components) - set(json_components)| if tokenizer_object is not None: | ||
| fast_tokenizer = copy.deepcopy(tokenizer_object) | ||
| elif fast_tokenizer_file is not None and os.path.isfile(fast_tokenizer_file): | ||
| _validate_tokenizer_components(self.__class__, fast_tokenizer_file) |
Collaborator
There was a problem hiding this comment.
No validate should go after INIT, most probably in the convert_to_native_format function
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Contributor
|
View the CircleCI Test Summary for this PR: https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=42816&sha=ca3742 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
check if the tokenizer object in
tokenizer.jsonthat is being loaded is actually matching that of mapped tokenizer in TOKENIZER_MAPPINGS intokenization_auto.py