Skip to content

[model] support hy3 model#10630

Open
isLinXu wants to merge 1 commit into
hiyouga:mainfrom
isLinXu:hy3
Open

[model] support hy3 model#10630
isLinXu wants to merge 1 commit into
hiyouga:mainfrom
isLinXu:hy3

Conversation

@isLinXu

@isLinXu isLinXu commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds the "Hy3" model group mapping to tencent/Hy3 and updates the hy3 template's thought words to use <think:opensource> and </think:opensource>. However, the changes to format_user and format_assistant introduce a critical issue: moving the <|hy_Assistant|> tag to format_assistant breaks the ReasoningTemplate thought block placement and prevents the assistant start tag from being appended during inference. It is recommended to revert these format changes as suggested.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/llamafactory/data/template.py Outdated
Comment on lines +840 to +841
format_user=StringFormatter(slots=["<|hy_User|>{{content}}"]),
format_assistant=StringFormatter(slots=["<|hy_Assistant|>{{content}}<|hy_eos|>"]),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Incorrect Chat Template Format for Reasoning Models

Changing format_user to exclude <|hy_Assistant|> and putting it at the start of format_assistant introduces two major issues:

  1. Incorrect Thought Block Placement in ReasoningTemplate:
    Because hy3 uses ReasoningTemplate, during training/inference, the thought block is prepended to the assistant's response (response_ids) via self.get_thought_word_ids(tokenizer) + response_ids.
    If format_assistant starts with <|hy_Assistant|>, the thought block (<think:opensource>...</think:opensource>) will be prepended before <|hy_Assistant|>, resulting in:
    ... <|hy_User|>query <think:opensource>...thinking...</think:opensource> <|hy_Assistant|> response
    The correct format for Hunyuan3 is to have the thought block after the assistant start tag:
    ... <|hy_User|>query <|hy_Assistant|> <think:opensource>...thinking...</think:opensource> response

  2. Broken Inference / Generation Prompt:
    During inference, the prompt fed to the model is constructed from the user's turn. If format_user does not end with <|hy_Assistant|>, the prompt will end with the user's content (e.g., "<|hy_User|>query"), and the model will not receive the assistant start tag <|hy_Assistant|> to begin its generation.

Solution:

Revert format_user and format_assistant to their original definitions where <|hy_Assistant|> is placed at the end of format_user.

Suggested change
format_user=StringFormatter(slots=["<|hy_User|>{{content}}"]),
format_assistant=StringFormatter(slots=["<|hy_Assistant|>{{content}}<|hy_eos|>"]),
format_user=StringFormatter(slots=["<|hy_User|>{{content}}<|hy_Assistant|>"]),
format_assistant=StringFormatter(slots=["{{content}}<|hy_eos|>"]),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants