Fast encode fixes#2142
Merged
Merged
Conversation
|
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. |
…e base Split #2129's token store in two: a legacy map-backed `VocabStore` (`crate::vocab_store`) that backs the models on this base, and the verbatim MPHF store renamed to `BucketVocabStore`. The models are unchanged — their `use crate::vocab_store::VocabStore` now resolves to the legacy twin, so the fast store can be swapped back in by the pipeline PR via a one-line alias. Restore the pre-#2129 PreTokenizedString `AddedVocabulary` as the active tokenizer AV, and park the #2129 fast path — `BucketVocabStore`, `Buckets`, and the bucket AV (renamed `bucket_added_vocabulary`) — unwired for the pipeline PR. The parked modules are not re-exported at the crate root so they don't collide with the legacy AV. This makes the base the genuine legacy Tokenizer, a fair A/B baseline against PipelineTokenizer. Models and the tk-train trainer stay byte-identical to #2129. The only #2129 code removed: its broken `extract_and_normalize` stub (replaced by a working two-pass), the `encode_special_tokens` default (true->false), and the legacy-tokenizer wiring of the new AV (reverted). BucketVocabStore is #2129 verbatim plus the on-branch PartialEq/doctest fixes, with expanded tests. tk-encode: 219 pass / 0 fail / 2 ignored, 20 doctests, clippy clean; workspace builds. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
7dc6f8c to
c57b759
Compare
…e base Split #2129's token store in two: a legacy map-backed `VocabStore` (`crate::vocab_store`) that backs the models on this base, and the verbatim MPHF store renamed to `BucketVocabStore`. The models are unchanged — their `use crate::vocab_store::VocabStore` now resolves to the legacy twin, so the fast store can be swapped back in by the pipeline PR via a one-line alias. Restore the pre-#2129 PreTokenizedString `AddedVocabulary` as the active tokenizer AV, and park the #2129 fast path — `BucketVocabStore`, `Buckets`, and the bucket AV (renamed `bucket_added_vocabulary`) — unwired for the pipeline PR. The parked modules are not re-exported at the crate root so they don't collide with the legacy AV. This makes the base the genuine legacy Tokenizer, a fair A/B baseline against PipelineTokenizer. The parked bucket path stays #2129 verbatim, minus dead/broken bits: - `BucketVocabStore` = #2129's store + on-branch PartialEq/doctest fixes, with expanded unit tests. - the bucket AV's `extract_and_normalize` (and its stub-only tests) is dropped — the PipelineTokenizer drives the AV solely through `extract_next` (the `PipelinePatternMatcher` trait); `extract_and_normalize` is only the legacy TokenizerImpl's entry point and uses the legacy AV. - `extract_next` had an inverted vocab selection (#2129 used `self.vocab` for normalized text); fixed to search `normalized_vocab` when normalized and `vocab` otherwise, and covered with tests (routing, offsets, lstrip/rstrip, single_word). Models and the tk-train trainer stay byte-identical to #2129. The only other #2129 code removed is the legacy-tokenizer wiring of the new AV, reverted so the legacy AV is active again. tk-encode: 216 pass / 0 fail / 1 ignored, 20 doctests, clippy + fmt clean; workspace builds. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
c57b759 to
07ab513
Compare
ArthurZucker
reviewed
Jul 3, 2026
| let vocab = if normalized { | ||
| &self.vocab | ||
| } else { | ||
| &self.normalized_vocab |
| Ok(total - ignored) | ||
| } | ||
|
|
||
| pub fn extract_and_normalize<N: Normalizer>( |
| AddedToken::from("ask>", false), | ||
| AddedToken::from("<pad>", true), | ||
| ], | ||
| .add_special_tokens( |
Collaborator
There was a problem hiding this comment.
he removed a bit too much here! As I think I made a mistake maybe no? (the while xx loop) ?
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.
No description provided.