You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code given above is part of the following example, taken from the model card of the model. The full code is given below.
fromflair.dataimportSentencefromflair.modelsimportSequenceTagger# load taggertagger=SequenceTagger.load("flair/ner-multi-fast")
# make example sentence in any of the four languagessentence=Sentence("George Washington ging nach Washington")
# predict NER tagstagger.predict(sentence)
# print sentenceprint(sentence)
# print predicted NER spansprint('The following NER tags are found:')
# iterate over entities and printforentityinsentence.get_spans('ner'):
print(entity)
It is stated that this should yield the following output:
Span [1,2]: "George Washington" [− Labels: PER (0.9977)]
Span [5]: "Washington" [− Labels: LOC (0.9895)]
however, instead, we get an error when loading the model.
Logs and Stack traces
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/dev/app/.venv/lib/python3.9/site-packages/flair/models/sequence_tagger_model.py", line 925, in load
return cast("SequenceTagger", super().load(model_path=model_path))
File "/home/user/dev/app/.venv/lib/python3.9/site-packages/flair/nn/model.py", line 564, in load
return cast("Classifier", super().load(model_path=model_path))
File "/home/user/dev/app/.venv/lib/python3.9/site-packages/flair/nn/model.py", line 190, in load
state = load_torch_state(model_file)
File "/home/user/dev/app/.venv/lib/python3.9/site-packages/flair/file_utils.py", line 384, in load_torch_state
return torch.load(f, map_location="cpu")
File "/home/user/dev/app/.venv/lib/python3.9/site-packages/torch/serialization.py", line 1040, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/home/user/dev/app/.venv/lib/python3.9/site-packages/torch/serialization.py", line 1272, in _legacy_load
result = unpickler.load()
File "/home/user/dev/app/.venv/lib/python3.9/site-packages/torch/nn/modules/rnn.py", line 353, in __setstate__
for w in self._flat_weights]
File "/home/user/dev/app/.venv/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1709, in __getattr__
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'LSTM' object has no attribute '_flat_weights'
Screenshots
No response
Additional Context
The code snippet is run on WSL2 Ubuntu 22.04 (Windows 11). The environment is created using uv.
Environment
Versions:
Flair
0.14.0
Pytorch
2.3.1+cpu
Transformers
4.46.3
GPU
False
The text was updated successfully, but these errors were encountered:
Describe the bug
Trying to load the
flair/ner-multi-fast
model raises the following error:To Reproduce
Expected behavior
The code given above is part of the following example, taken from the model card of the model. The full code is given below.
It is stated that this should yield the following output:
however, instead, we get an error when loading the model.
Logs and Stack traces
Screenshots
No response
Additional Context
The code snippet is run on WSL2 Ubuntu 22.04 (Windows 11). The environment is created using
uv
.Environment
Versions:
Flair
0.14.0
Pytorch
2.3.1+cpu
Transformers
4.46.3
GPU
False
The text was updated successfully, but these errors were encountered: