fix(paddleocr_vl): make repetition truncation catch multi-line and cap-truncated output - #5170
Open
subin9 wants to merge 1 commit into
Open
Conversation
…p-truncated output truncate_repetitive_content() misses two common shapes of degenerate output: 1. Repetition inside a multi-line block. The phrase-level check runs only when the content has no newline, and the line-level check needs line_threshold near-identical lines. A block that decodes a few valid lines and then loops on the last one passes every check. 2. A generation stopped at max_new_tokens can be cut in the middle of a character, and decoding leaves U+FFFD at the end. find_repeating_suffix() anchors on the exact suffix, so that single character stops every candidate unit from matching and the check returns the text unchanged. Run the phrase-level check per line and drop the trailing replacement character before anchoring.
|
Thanks for your contribution! |
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.
PaddleOCR-VL decodes greedily with no repetition penalty (the local predictor ignores
repetition_penalty/temperature/top_p, andgeneration_config.jsonsets none), sotruncate_repetitive_content()is the only thing that stops a degenerate block from reaching the document. It misses two common shapes.1. Repetition inside a multi-line block
The phrase-level check runs only when the content has no newline, and the line-level check needs
line_threshold(10) near-identical lines. A block that decodes a few valid lines and then loops on the last one passes every check.2. Output cut in the middle of a character
A generation stopped at
max_new_tokenscan be cut mid-character; decoding leaves U+FFFD at the end.find_repeating_suffix()anchors on the exact suffix (s.endswith(unit * min_repeats)), so that single character stops every candidate unit from matching. The check silently returns the degenerate text unchanged — on exactly the output it exists for.Reproduction
No model needed:
min_count=50is whatpipeline.pypasses for non-table blocks.Fix
Run the phrase-level check per line instead of only for single-line content, and drop a trailing replacement character before anchoring. Priority 2 and 3 are unchanged.
Impact
Checked against the recognition output of a full 1649-page OmniDocBench run (78,710 blocks,
min_count=50,5000for tables):-10 -10 -10 …,CH2-CH2-CH2 …, a text block looping on the same formula for 5,134 characters. Every one has a newline, so the current code leaves all of them intact.Related user reports of the symptom: #17288, #17828, #17903 (PaddleOCR).