Flair: Error while loading the ner model

Created on 18 Jan 2020  路  4Comments  路  Source: flairNLP/flair

I am trying to run flair in my Mac. I have installed python and other related stuff as per your documentation. The problem I am facing is while loading the ner model .

Below is the stack trace. I have tried both python 3.6 and 3.7.

tagger = SequenceTagger.load('ner')
2020-01-18 00:16:34,804 https://s3.eu-central-1.amazonaws.com/alan-nlp/resources/models-v0.4/NER-conll03-english/en-ner-conll03-v0.4.pt not found in cache, downloading to /var/folders/r9/wtxzwffs70bcqh_mkfy99kxw0000gp/T/tmpktexcmjd
100%|鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻坾 432197603/432197603 [02:50<00:00, 2539653.20B/s]
2020-01-18 00:19:25,565 copying /var/folders/r9/wtxzwffs70bcqh_mkfy99kxw0000gp/T/tmpktexcmjd to cache at /Users/u0095963/.flair/models/en-ner-conll03-v0.4.pt
2020-01-18 00:19:26,086 removing temp file /var/folders/r9/wtxzwffs70bcqh_mkfy99kxw0000gp/T/tmpktexcmjd
2020-01-18 00:19:26,115 loading file /Users/u0095963/.flair/models/en-ner-conll03-v0.4.pt
Traceback (most recent call last):
File "", line 1, in
File "/Users/u0095963/opt/anaconda3/envs/mypython3.6/lib/python3.6/site-packages/flair/nn.py", line 86, in load
model = cls._init_model_with_state_dict(state)
File "/Users/u0095963/opt/anaconda3/envs/mypython3.6/lib/python3.6/site-packages/flair/models/sequence_tagger_model.py", line 250, in _init_model_with_state_dict
rnn_type=rnn_type,
File "/Users/u0095963/opt/anaconda3/envs/mypython3.6/lib/python3.6/site-packages/flair/models/sequence_tagger_model.py", line 201, in __init__
self.to(flair.device)
File "/Users/u0095963/opt/anaconda3/envs/mypython3.6/lib/python3.6/site-packages/torch/nn/modules/module.py", line 425, in to
return self._apply(convert)
File "/Users/u0095963/opt/anaconda3/envs/mypython3.6/lib/python3.6/site-packages/torch/nn/modules/module.py", line 201, in _apply
module._apply(fn)
File "/Users/u0095963/opt/anaconda3/envs/mypython3.6/lib/python3.6/site-packages/torch/nn/modules/module.py", line 201, in _apply
module._apply(fn)
File "/Users/u0095963/opt/anaconda3/envs/mypython3.6/lib/python3.6/site-packages/torch/nn/modules/module.py", line 201, in _apply
module._apply(fn)
[Previous line repeated 1 more time]
File "/Users/u0095963/opt/anaconda3/envs/mypython3.6/lib/python3.6/site-packages/torch/nn/modules/rnn.py", line 137, in _apply
self._flat_weights = [getattr(self, weight) for weight in self._flat_weights_names]
File "/Users/u0095963/opt/anaconda3/envs/mypython3.6/lib/python3.6/site-packages/torch/nn/modules/module.py", line 576, in __getattr__
type(self).__name__, name))
AttributeError: 'LSTM' object has no attribute '_flat_weights_names'

question

Most helpful comment

We just released a new flair version that fixes this!

All 4 comments

I get the same error when I try loading the nl-ner model.

@jvdzwaan Solution is mentioned above.

2020-01-21 12:35:26,334 loading file C:\Users\1025289.flair\models\en-pos-ontonotes-v0.4.pt
Traceback (most recent call last):
File ".\stest.py", line 3, in
File "C:\Users\1025289\AppData\Local\Programs\Python\Python37lib\site-packages\torch\nn\modules\module.py", line 201, in _apply
module._apply(fn)
File "C:\Users\1025289\AppData\Local\Programs\Python\Python37lib\site-packages\torch\nn\modules\module.py", line 201, in _apply
module._apply(fn)
File "C:\Users\1025289\AppData\Local\Programs\Python\Python37lib\site-packages\torch\nn\modules\module.py", line 201, in _apply
module._apply(fn)
[Previous line repeated 1 more time]
File "C:\Users\1025289\AppData\Local\Programs\Python\Python37lib\site-packages\torch\nn\modules\rnn.py", line 137, in _apply
self._flat_weights = [getattr(self, weight) for weight in self._flat_weights_names]
File "C:\Users\1025289\AppData\Local\Programs\Python\Python37lib\site-packages\torch\nn\modules\module.py", line 576, in __getattr__
type(self).__name__, name))
AttributeError: 'LSTM' object has no attribute '_flat_weights_names'

Error: started when updated the torch to latest version.
Environment:
PyTorch Version (e.g., 1.0): 1.4.0
OS (e.g., Linux): Windows 10
How you installed PyTorch (conda, pip, source): pip
Build command you used (if compiling from source):
Python version: 3.76
GPU models and configuration:
Any other relevant information:

We just released a new flair version that fixes this!

Was this page helpful?
0 / 5 - 0 ratings