Repository navigation
Conversation
4 of 8 tasks
Contributor
|
Thank you for your contribution 🤗! CI Security Gate — waiting for maintainer approvalCI is approved automatically only for authors who already have a contribution merged in this repository. A maintainer will review this PR and approve CI to run on it. |
This branch has not been deployed
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.
What does this PR do?
prepare_inputschecksMARK not in tokenizer.get_vocab()on every call, andget_vocab()builds the whole vocabulary fortokenizers-backed tokenizers. The decision pipeline calls it once per request, so/v1/systemonepays it every time. This looks the sentinels up withconvert_tokens_to_idsinstead (a missing token isNone, or the unknown token) and adds only the missing ones. For 8 tokenizers (Qwen3.5, Qwen2.5, Llama fast and sentencepiece, T5, TinyLlama, Phi-3, SmolLM2) starting with no sentinels, both, or only<|split|>, 2,640 prompts from the default template and custom ones with marks, splits and control tokens in the request are token-identical tomain, with the same sentinel ids. A tokenizer that already has<|mark|>but not<|split|>now gets<|split|>added too:mainleft it unknown.Qwen/Qwen3.5-4B, bf16, decision pipeline on the causal LM (as
transformers serveloads it), 200 typed-decisions requests of 5 questions, median, on an HF Jobs RTX PRO 6000 Blackwell (preprocessing runs on its CPU):mainpreprocessTokenizing 40k training prompts with
prepare_inputs(as in TRL's decision model example, huggingface/trl#7784): about 70 min onmain(extrapolated from 2,000 prompts in 210 s), 60 s measured with this PR.The test makes
get_vocabraise, so it fails onmain, and checks that both sentinels map back to themselves for a tokenizer with an unknown token (Llama) and one without (Qwen).Who can review?
@ArthurZucker