Fail to load model (unexpected missing_keys error)

#1
by jcaudecea - opened

Hi,

I try to run the quickstart toy code you provide (same error with the 650M model) but model loading failed (on two different computer setup). Any idea about what is going wrong here ?

Thx,
jC

❯ python3 quickstart.py
config.json: 100% ..
tokenizer_config.json: 100% ..
vocab.json: 100% ..
special_tokens_map.json: 100% ..
model.safetensors: 100% ...
Loading weights: 100% ..
Traceback (most recent call last):
  File "NTv3/quickstart.py", line 5, in <module>
    model = AutoModelForMaskedLM.from_pretrained(repo, trust_remote_code=True)
  File "NTv3/.env/lib/python3.14/site-packages/transformers/models/auto/auto_factory.py", line 365, in from_pretrained
    return model_class.from_pretrained(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        pretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, **kwargs
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "NTv3/.env/lib/python3.14/site-packages/transformers/modeling_utils.py", line 4110, in from_pretrained
    load_info = cls._finalize_load_state_dict(model, load_config, load_info)
  File "NTv3/.env/lib/python3.14/site-packages/transformers/modeling_utils.py", line 4277, in _finalize_load_state_dict
    model.tie_weights(missing_keys=load_info.missing_keys, recompute_mapping=False)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: NTv3PreTrained.tie_weights() got an unexpected keyword argument 'missing_keys'

Got it, it's related to the transformers library I was using (5.0.0) .. Maybe you can update the readme section accordingly.

Regards,
jC

jcaudecea changed discussion status to closed

Sign up or log in to comment