Repository navigation
Fix #164: meta tokenization in block dataset building - #177
Merged
Merged
Conversation
- encode_meta: wrap word_counts in Counter() before passing to build_vocab()
to avoid AttributeError ('dict' object has no attribute 'most_common')
- update_vocab: allocate new-word IDs from max(vocab.values())+1 (not
based on __OOV__) so IDs stay contiguous across blocks; sort new words
for deterministic, reproducible vocab ordering
- add 3 regression tests in tests/unit_tests/preprocess/test_tokenizer.py
Closes #164
|
您好,您的邮件我已收到。如有需要,我会尽快给您回复。
|
zhujiem
pushed a commit
that referenced
this pull request
Aug 22, 2026
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 this PR does / why we need it
Fixes two bugs in meta-type feature tokenization reported in #164:
Bug 1:
encode_metacrashes on first callAttributeError: 'dict' object has no attribute 'most_common'encode_metapasses a plaindicttobuild_vocab(), which calls.most_common()— aCountermethod not available ondict.Fix: Wrap with
Counter(word_counts)before passing tobuild_vocab().Bug 2: Inconsistent token-to-ID mapping across blocks
update_vocaballocates new-word IDs based on__OOV__value, which is the last index after frequency-sorted vocabulary. This causes new-word IDs to collide with or overlap existing IDs when blocks are processed independently.Fix: Allocate new-word IDs from
max(vocab.values()) + 1(the true next available ID), and sort new words alphabetically to guarantee deterministic, reproducible vocab ordering.How was this patch tested?
3 regression tests added in
tests/unit_tests/preprocess/test_tokenizer.py:test_encode_meta_builds_vocab_on_first_call— verifies no crash, correct vocab structuretest_encode_meta_new_words_get_contiguous_ids— verifies cross-block ID consistency and determinismtest_encode_meta_new_words_added_to_vocab— verifies incremental vocab update behaviorAll tests pass under Python 3.12 / pandas 3.0.5.
Closes #164