Error while using SequenceTagger()
Hi I'm currently getting this error with latest Flair model:
Traceback (most recent call last):
File "/app/download_flair_models.py", line 9, in
tagger = SequenceTagger.load('flair/ner-english-ontonotes-fast')
File "/usr/local/lib/python3.9/site-packages/flair/nn/model.py", line 135, in load
model = cls._init_model_with_state_dict(state)
File "/usr/local/lib/python3.9/site-packages/flair/models/sequence_tagger_model.py", line 271, in _init_model_with_state_dict
model = SequenceTagger(
File "/usr/local/lib/python3.9/site-packages/flair/models/sequence_tagger_model.py", line 160, in init
embedding_dim: int = self.embeddings.embedding_length
AttributeError: 'dict' object has no attribute 'embedding_length'
Please help me resolve this, it's a fresh issue, earlier there wasn't any error.
I'm using:
transformers==4.17.0
torch==2.0
torchvision==0.12.0
flair==0.10
Can you try updating to a newer version of Flair?
I tried updating to 0.11, 0.12 and so on. Was getting different error with transformers then. Is there any way to use the old image ?
Hi,
Can you please specify how to use the earlier image?
Hello @Aman50 , you can load the old model like this:
# load tagger
tagger = SequenceTagger.load("flair/ner-english-ontonotes-fast@38a8eb6")
# make example sentence
sentence = Sentence("On September 1st George Washington won 1 dollar.")
# predict NER tags
tagger.predict(sentence)
Note that this model will not work with torch 2.0.
Hi, just wanted to inform that the current version hosted on the Inference API also throws this error, so the current version is (in my opinion) broken.
We updated the Flair version on the Model Hub here, and the widget is again working :)