Tokenizer refactor #10
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors the tokenizer module into smaller, focused submodules (base, serialization, truncation, auto, hf) and adopts deterministic msgpack-based persistence with SHA-256 fingerprints. Also introduces a TokenizerTrainingParams container and orchestration helpers used by model/auto.py.
Changes:
- Split
tokenizer.pyintobase.py,serialization.py,truncation.py,hf.py, andauto.pymodules. - Replace pickle-based vocab persistence with deterministic msgpack + fingerprint and a JSON descriptor; keep legacy pickle read path.
- Add
TokenizerTrainingParamsand reroute orchestration inmodel/auto.pythroughtokenizer.auto.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 18 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_tokenizer.py | Adds tests for serialization, truncation, hf wrapper, and auto helpers. |
| src/gpt_lab/utils/schemas.py | Adds TokenizerTrainingParams and syncs legacy fields into it. |
| src/gpt_lab/utils/logging.py | Makes log_all raise RuntimeError for ERROR-and-above levels. |
| src/gpt_lab/tokenizer/truncation.py | New module with parse_truncated_name and truncated_from_pretrained. |
| src/gpt_lab/tokenizer/tokenizer.py | Slimmed: delegates HF/truncation to new modules; adds msgpack save/load. |
| src/gpt_lab/tokenizer/serialization.py | New deterministic msgpack save/load + validation utilities. |
| src/gpt_lab/tokenizer/hf.py | New HF wrapper and training function with optional tokenizers import. |
| src/gpt_lab/tokenizer/corpus.py | Inlines load_datasets, comments out zstd import. |
| src/gpt_lab/tokenizer/bpe.py | Uses training_params.max_chars when available. |
| src/gpt_lab/tokenizer/base.py | New _BaseTokenizer extracted from tokenizer.py. |
| src/gpt_lab/tokenizer/auto.py | New orchestration helpers for vocab sizing and tokenizer build/load. |
| src/gpt_lab/model/auto.py | Delegates tokenizer build/resolve/compute to tokenizer.auto. |
| pyproject.toml | Adds msgpack>=1.1.2 dependency. |
| README.md | Adds commented-out documentation describing the new tokenizer layout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… move to benchmark folder
…e for reproducity
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.
EDIT: refactor + adding options (thats why addition > soustractions)