We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When I try to do TARSClassifier.load('tars-base') I catch RuntimeError
from flair.models import TARSClassifier classifier = TARSClassifier.load('tars-base')
Import model without any errors
/usr/local/lib/python3.10/dist-packages/flair/models/tars_model.py in load(cls, model_path) 926 from typing import cast 927 --> 928 return cast("TARSClassifier", super().load(model_path=model_path)) /usr/local/lib/python3.10/dist-packages/flair/models/tars_model.py in load(cls, model_path) 321 from typing import cast 322 --> 323 return cast("FewshotClassifier", super().load(model_path=model_path)) 324 325 /usr/local/lib/python3.10/dist-packages/flair/nn/model.py in load(cls, model_path) 557 from typing import cast 558 --> 559 return cast("Classifier", super().load(model_path=model_path)) 560 561 /usr/local/lib/python3.10/dist-packages/flair/nn/model.py in load(cls, model_path) 189 if not isinstance(model_path, dict): 190 model_file = cls._fetch_model(str(model_path)) --> 191 state = load_torch_state(model_file) 192 else: 193 state = model_path /usr/local/lib/python3.10/dist-packages/flair/file_utils.py in load_torch_state(model_file) 357 # see https://github.com/zalandoresearch/flair/issues/351 358 f = load_big_file(model_file) --> 359 return torch.load(f, map_location="cpu") /usr/local/lib/python3.10/dist-packages/torch/serialization.py in load(f, map_location, pickle_module, weights_only, mmap, **pickle_load_args) 1012 except RuntimeError as e: 1013 raise pickle.UnpicklingError(UNSAFE_MESSAGE + str(e)) from None -> 1014 return _load(opened_zipfile, 1015 map_location, 1016 pickle_module, /usr/local/lib/python3.10/dist-packages/torch/serialization.py in _load(zip_file, map_location, pickle_module, pickle_file, overall_storage, **pickle_load_args) 1420 unpickler = UnpicklerWrapper(data_file, **pickle_load_args) 1421 unpickler.persistent_load = persistent_load -> 1422 result = unpickler.load() 1423 1424 torch._utils._validate_loaded_sparse_tensors() /usr/local/lib/python3.10/dist-packages/flair/embeddings/transformer.py in __setstate__(self, state) 1167 1168 if model_state_dict: -> 1169 self.model.load_state_dict(model_state_dict) 1170 1171 @classmethod /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py in load_state_dict(self, state_dict, strict, assign) 2150 2151 if len(error_msgs) > 0: -> 2152 raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( 2153 self.__class__.__name__, "\n\t".join(error_msgs))) 2154 return _IncompatibleKeys(missing_keys, unexpected_keys) RuntimeError: Error(s) in loading state_dict for BertModel: Unexpected key(s) in state_dict: "embeddings.position_ids".
No response
0.12.2
2.1.0+cu118
4.34.1
False
The text was updated successfully, but these errors were encountered:
@Anya-wUw ,
Looks like you are getting the same error I did.
I just closed my ticket (#3305), but it explains the assorted fixes for that Tutorial thanks to @helpmefindaname .
Sorry, something went wrong.
@None-Such Thank you so much! You saved my last nerve cells!!
How to solve: !pip install transformers==4.29.2 !pip install huggingface_hub==0.14.1
!pip install transformers==4.29.2
!pip install huggingface_hub==0.14.1
No branches or pull requests
Describe the bug
When I try to do TARSClassifier.load('tars-base') I catch RuntimeError
To Reproduce
Expected behavior
Import model without any errors
Logs and Stack traces
Screenshots
Additional Context
No response
Environment
Versions:
Flair
0.12.2
Pytorch
2.1.0+cu118
Transformers
4.34.1
GPU
False
The text was updated successfully, but these errors were encountered: