Repository navigation
feat: Pass tokenizer_kwargs to AutoTokenizer.from_pretrained - #3798
Conversation
Adds the option to pass additional arguments to the pretrained tokenizer. Signed-off-by: Peter St. John <[email protected]>
c6265b3 to
1bab67f
Compare
|
Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
terrykong
left a comment
There was a problem hiding this comment.
Reviewed with a team of specialised agents plus an adversarial pass. The core change is sound and worth having: fix_mistral_regex is a real transformers kwarg with no other route through get_tokenizer today, and threading it through config rather than a monkeypatch is the right call, especially for DTensor-v2 workers that rebuild the tokenizer locally from config.
Four comments below: one that blocks (the new test cannot pass on any pinned transformers version), one coverage gap (the processor branch, which is the half of the VLM/multimodal flow the change misses), one convention item, and one optional follow-up.
Generated by Claude Code
Signed-off-by: Peter St. John <[email protected]>
|
/ok to test 140bdcb |
Adds
tokenizer_kwargstoTokenizerConfigget_tokenizer()currently constructs tokenizers with only the model name andtrust_remote_code=True:There is no config route for passing additional
from_pretrainedkwargs — for examplefix_mistral_regex=Falsefor tokenizer artifacts that already carry a corrected Mistral regex pretokenizer. A caller that needs this must monkeypatchAutoTokenizer.from_pretrainedin every process, including inside isolated Ray workers where tokenizers are constructed after the actor has started.This PR adds
tokenizer_kwargstoTokenizerConfigand threads it through bothget_tokenizer()implementations. Whentokenizer_kwargsis absent orNone, behaviour is unchanged:.get("tokenizer_kwargs") or {}produces an empty unpacking.