Skip to content

Commit 9bce62f

Browse files
alexander-soareWauplin
authored andcommitted
Don't override 'config' in model_kwargs (#2274)
1 parent adf5672 commit 9bce62f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/huggingface_hub/hub_mixin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def from_pretrained(
530530
model_kwargs[param.name] = config[param.name]
531531

532532
# Check if `config` argument was passed at init
533-
if "config" in cls._hub_mixin_init_parameters:
533+
if "config" in cls._hub_mixin_init_parameters and "config" not in model_kwargs:
534534
# Check if `config` argument is a dataclass
535535
config_annotation = cls._hub_mixin_init_parameters["config"].annotation
536536
if config_annotation is inspect.Parameter.empty:
@@ -558,7 +558,7 @@ def from_pretrained(
558558
model_kwargs[key] = value
559559

560560
# Finally, also inject if `_from_pretrained` expects it
561-
if cls._hub_mixin_inject_config:
561+
if cls._hub_mixin_inject_config and "config" not in model_kwargs:
562562
model_kwargs["config"] = config
563563

564564
instance = cls._from_pretrained(

0 commit comments

Comments
 (0)