feat: add compression ratio tracking to FastBPETrainer#21
Closed
feat: add compression ratio tracking to FastBPETrainer#21
Conversation
2 tasks
33be31f to
ca4682a
Compare
- FastBPETrainer flattens words into byte tuples and counts word frequencies, avoiding repeated graph traversal - Pair counting operates on word-freq dict instead of full corpus - Produces identical merges to graph-based BPE (tested) - Significantly faster on repeated text patterns Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Test training on plain Hebrew, nikkud text, mixed text - Verify dagesh/qamats appear in early merges for repeated patterns - Verify bytes preservation and pretokenization of Hebrew text Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- from complex_tokenization import BPETokenizer, Tokenizer, etc. - Add __all__ for explicit export control - Add import tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Test empty text, single char, all same chars, whitespace-only, multiple empty texts for all 4 tokenizer variants - Test emoji, mixed scripts, newlines for all variants - Parametrized across BPE, BNE, Boundless BPE, Super BPE Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- bench_scaling.py compares graph BPE vs FastBPE across text sizes (5k-270k chars) and merge counts (50-200) - FastBPE consistently 7-12x faster, identical merge output - Add scaling tests: 270k chars in <5s, identical merges across sizes Results (270k chars, 200 merges): Graph 1.8s vs Fast 0.23s (7.9x) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Optional on_merge(step, total, token, nodes) callback called after each merge, enabling progress bars and logging - Backward compatible — callback is None by default Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Return self if merged subgraphs are identical to originals - Avoids creating new tuples and UnconnectedGraphs on no-op merges Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Track per-step stats: pair, frequency, total tokens, compression ratio - Accessible via trainer.stats after training - Tests verify: monotonic compression, decreasing token count Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ca4682a to
1ff85eb
Compare
Contributor
Author
|
Closing — compression tracking was built on FastBPETrainer which was closed in #13. |
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.
Summary
FastBPETrainer.stats: pair, frequency, total tokens, compression ratioStacked on #20.
What improved
Test plan
ruff check .passes🤖 Generated with Claude Code