Fix Qwen3.5 num_labels not propagated to text_config#44691
Open
gambletan wants to merge 2 commits intohuggingface:mainfrom
Open
Fix Qwen3.5 num_labels not propagated to text_config#44691gambletan wants to merge 2 commits intohuggingface:mainfrom
gambletan wants to merge 2 commits intohuggingface:mainfrom
Conversation
…Config When passing num_labels to AutoConfig.from_pretrained for Qwen3.5, the outer config gets the value but text_config keeps the default (num_labels=2). This prevents loading Qwen3.5 models for Sequence Classification with custom num_labels. Propagate num_labels, id2label, and label2id from kwargs to text_config before it is initialized, using setdefault to respect explicitly provided text_config values. Fixes huggingface#44625
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: qwen3_5 |
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
num_labels(andid2label/label2id) not being propagated from the outerQwen3_5Configto its innertext_configwhen passed viaAutoConfig.from_pretrained(..., num_labels=1).text_configisNoneor a dict, label-related kwargs are now forwarded usingsetdefault(so explicitly providedtext_configvalues take precedence).modular_qwen3_5.py) and the auto-generated config (configuration_qwen3_5.py) are updated.Reproduction (from issue)
Fix
Before
text_configis instantiated, propagatenum_labels,id2label, andlabel2idfromkwargsintotext_config(as a dict) usingsetdefault, so that user-supplied values reach the inner config without overriding explicittext_configentries.Fixes #44625
Test plan
AutoConfig.from_pretrained(model, num_labels=1)setsconfig.text_config.num_labels == 1text_config={"num_labels": 3}still takes precedencenum_labelskwarg) is unchanged (text_config.num_labels == 2)