fix: use text_config.eos_token_id for HunyuanOCR v1.5#25514
Open
wendadawen wants to merge 1 commit into
Open
Conversation
Signed-off-by: wendadawen <wendadawen@qq.com>
bb20964 to
de8e1d5
Compare
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.
Fix incorrect eos_token_id in HunyuanOCR v1.5 conversion causing inference to never stop
Problem
HunyuanOCR v1.5 is an updated version of HunyuanOCR v1.0. After converting v1.5 with
convert_hf_to_gguf.py, the GGUFeos_token_idis incorrectly written as120020, while the model's real stop token is120007fromtext_config.eos_token_id.As a result, when llama.cpp generates
120007it is not recognized as a stop token, and the model degenerates into repetitive generation until truncated bymax_tokens(finish=length).Root cause: v1.5's
config.jsonstores the real stop token in the nestedtext_config.eos_token_id, while the top-leveleos_token_id=120020is a different token. The parent classHunYuanModel._fix_special_tokensonly reads the top-level value.Fix
Override
_fix_special_tokensinHunyuanVLTextModelto overwrite withhparams["eos_token_id"](base.py already mergestext_config.eos_token_idinto hparams) after calling the parent:Test
Tested v1.0 and v1.5 on 20 cases:
finish=length) before fix; 20/20 normal stop after fixtext_config.eos_token_id, GGUF unaffected)Model Weights