validate tokenizer components#42816
Conversation
| TIKTOKEN_VOCAB_FILE = "tokenizer.model" | ||
|
|
||
|
|
||
| def _validate_tokenizer_components(tokenizer_class, tokenizer_json_path): |
There was a problem hiding this comment.
| 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 = [] |
There was a problem hiding this comment.
| mismatches = [] | |
| mismatches = set(expected_components) - set(json_components) |
| 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}") |
There was a problem hiding this comment.
| 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}") |
There was a problem hiding this comment.
how do we check if they match?
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) |
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. |
|
View the CircleCI Test Summary for this PR: https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=42816&sha=ca3742 |
check if the tokenizer object in
tokenizer.jsonthat is being loaded is actually matching that of mapped tokenizer in TOKENIZER_MAPPINGS intokenization_auto.py