Closed achang97 closed 3 years ago
@achang97 we're currently looking into this. at first sight code looks fine, could be due to the fact that our model has been trained on an older transformer version. we'll check and keep you updated.
Thanks, please let me know!
@achang97 The error throws in a lib we're using for Transformer models - I was not sure how this error came up but it might be due to a new release from their side. Thus we trained some new models (thought that might fix the issue of loading the model correctly) - unfortunately i get new errors, similar to the one above but a different one. So update on this here: we're still investigating.
I got the same error with flair 0.6
. Downgrading transformers to 2.11.0
seems to fix it.
We found this error only occurs if training with torch 1.5.1 - is this the same for you?
Actually, no. I didn't get any issue with torch 1.5.1
:
import torch
import transformers
from flair.data import Sentence
from flair.models import SequenceTagger
print(f"Torch's version: {torch.__version__}")
print(f"Transformers' version: {transformers.__version__}")
print("Loading keyphrase model ...")
keyphrase_model = SequenceTagger.load("keyphrase")
text = 'Wisconsin residents receiving an extra $300 in weekly unemployment benefits are being asked to pay back the money if Congress enacts new legislation to replace the jobless aid created by President Trump\'s executive action last month.'
sentence = Sentence(text)
keyphrase_model.predict(sentence)
print(sentence)
for kp in sentence.get_spans():
print(kp)
Torch's version: 1.5.1
Transformers' version: 2.11.0
Loading keyphrase model ...
2020-09-21 12:30:16,885 loading file /Users/khuc/.flair/models/keyphrase-en-scibert.pt
Sentence: "Wisconsin residents receiving an extra $ 300 in weekly unemployment benefits are being asked to pay back the money if Congress enacts new legislation to replace the jobless aid created by President Trump 's executive action last month ." [− Tokens: 39 − Token-Labels: "Wisconsin <B-Material> residents <E-Material> receiving an extra $ 300 in weekly unemployment benefits are being asked to pay <B-Process> back <I-Process> the <I-Process> money <E-Process> if Congress enacts new legislation to replace the jobless aid created by President Trump 's executive action last month ."]
Span [1,2]: "Wisconsin residents" [− Labels: Material (0.8445)]
Span [16,17,18,19]: "pay back the money" [− Labels: Process (0.6335)]
Ah ok thanks for the info! I think we need to re-train the model with torch 1.6.0 to work across all transformer versions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
pip install transformers==3.4.0
新版本不支持,安装旧版本就解决了这个问题
Describe the bug When attempting to use
Sequence Tagger
withkeyphrase
as the argument, I get the following error:To Reproduce
Expected behavior I expect no error and for the key phrases to be detected. I followed the example in the release notes:
Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
Additional context Add any other context about the problem here.