Repository navigation
fix(tokenizer): ignore empty non-linguistic symbols to avoid a hang - #3852
Merged
LauraGPT merged 1 commit intoNov 7, 2026
Merged
Conversation
CharTokenizer and PhonemeTokenizer load non_linguistic_symbols with
line.rstrip(), so a blank line in the symbol file (or an "" entry in a
list) adds the empty string to the set. line.startswith("") is true at
every position without consuming any input, so text2tokens never
terminates (and keeps appending "" tokens when symbols are kept).
Drop the empty string after the symbols are loaded and add a regression
test covering a file with a blank line and an iterable with "".
LauraGPT
added a commit
that referenced
this pull request
Nov 7, 2026
Preserve the original PR #3852 commit and add only missing trigger paths and regression selection. Signed-off-by: LauraGPT <zhifu.gzf@alibaba-inc.com>
LauraGPT
added a commit
that referenced
this pull request
Nov 7, 2026
Preserve the original contributor commit and add maintained regression coverage. No administrator bypass. Signed-off-by: LauraGPT <zhifu.gzf@alibaba-inc.com>
Merged
LauraGPT
added a commit
that referenced
this pull request
Nov 8, 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.
Summary
CharTokenizerandPhonemeTokenizerreadnon_linguistic_symbolswithset(line.rstrip() for line in f). A blank line in the symbol file (or an""entry when a list is passed) adds the empty string to the set. Intext2tokens,line.startswith("")is true at every position but consumes no input, so thewhile len(line) != 0loop never ends; when symbols are kept it also keeps appending""tokens until memory runs out.This drops the empty string after the symbols are loaded, in both tokenizers.
Reproduction:
Before: never returns (killed by
timeout 15, exit 124). The same happens with a symbol file such as"<noise>\n\n".After:
['a', 'b'];"你<noise>好"gives['你', '<noise>', '好'].Type of change
Validation
python -m pytest tests/test_char_tokenizer_non_linguistic_symbols.py: 3 passed (all 3 fail without the fix).python -m compileall funasr examples tests(rancompileallonfunasr/tokenizerand the new test file only)User impact
Anyone training or fine-tuning with a
non_linguistic_symbolsfile that ends with a blank line; data loading currently hangs without an error.Notes for reviewers
The change is limited to dropping
""; all non-empty symbols behave as before.