Repository navigation
Use i64 pair counts and add optional min_freq pruning - #8
Open
1023097618 wants to merge 1 commit into
Open
1023097618 wants to merge 1 commit into
1023097618 wants to merge 1 commit into
Conversation
- Pair counts and chunk counts are now i64, so large corpora no longer overflow i32 during training. - train_from_iterator gains an optional min_freq argument (default 1, i.e. no change in behavior). Chunks seen fewer than min_freq times are dropped before training, which greatly reduces memory on large corpora, especially CJK text where most long chunks are singletons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1023097618
added a commit
to 1023097618/train_llm
that referenced
this pull request
Oct 13, 2026
- environment.yml: Python 3.11 and the project's pip dependencies - setup_env.sh: creates/updates the env, installs PyTorch (CUDA build selectable), builds the modified rustbpe from the fork (karpathy/rustbpe#8), registers a Jupyter kernel and runs a sanity check - train_token.py: pass min_freq=2 explicitly, since the fork defaults to 1 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Two changes to
train_from_iteratorthat came up while training a tokenizer on a large Chinese corpus:i64 counts. Chunk counts and pair counts were
i32. On large corpora theaggregated pair counts can exceed
i32::MAXand overflow. They are nowi64(
count_pairs_parallel,train_core_incremental, merge delta updates).Optional
min_freqargument (default1, so existing behavior is unchanged).Chunks seen fewer than
min_freqtimes are dropped before training. On CJK text,where the regex split produces many long one-off chunks,
min_freq=2cutsmemory a lot. The number of kept/dropped chunks is logged.
Testing
cargo test,cargo fmt --checkandcargo clippy -D warningspasstest_min_freq; the existing quick Python tests pass🤖 Generated with Claude Code