TypeError: Module.load_state_dict() got an unexpected keyword argument 'assign'

#3
by rociortizb - opened

When trying to load the urchade/gliner_multiv2.1 to a local jupyter notebook I get the error below, since the "assign" argument is used by GLiNER but it seems like it's been removed from huggingface_hub/hub_mixin.py

My question is, which version of the huggingface_hub is this module compatible with? Any other alternatives to solve this would also be appreciated
```

TypeError Traceback (most recent call last)
Cell In[46], line 1
----> 1 model = GLiNER.from_pretrained("urchade/gliner_multiv2.1")

File /opt/homebrew/anaconda3/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:118, in validate_hf_hub_args.._inner_fn(*args, **kwargs)
115 if check_use_auth_token:
116 kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.name, has_token=has_token, kwargs=kwargs)
--> 118 return fn(*args, **kwargs)

File /opt/homebrew/anaconda3/lib/python3.10/site-packages/huggingface_hub/hub_mixin.py:277, in ModelHubMixin.from_pretrained(cls, pretrained_model_name_or_path, force_download, resume_download, proxies, token, cache_dir, local_files_only, revision, **model_kwargs)
273 elif any(param.kind == inspect.Parameter.VAR_KEYWORD for param in init_parameters.values()):
274 # If init accepts **kwargs, let's forward the config as well (as a dict)
275 model_kwargs["config"] = config
--> 277 instance = cls._from_pretrained(
278 model_id=str(model_id),
279 revision=revision,
280 cache_dir=cache_dir,
281 force_download=force_download,
282 proxies=proxies,
283 resume_download=resume_download,
284 local_files_only=local_files_only,
285 token=token,
286 **model_kwargs,
287 )
...
--> 421 model.load_state_dict(state_dict, strict=strict, assign=True)
422 model.to(map_location)
423 return model

TypeError: Module.load_state_dict() got an unexpected keyword argument 'assign'
```

Owner

Hi @rociortizb

Have you solve this problem ? You can try installing a recent version of pytorch 2.1+

That solved the issue! Thank you

Sign up or log in to comment