首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Allennlp ConfigurationError:位置"matrix_attention“需要键”matrix_attention“。

Allennlp ConfigurationError:位置"matrix_attention“需要键”matrix_attention“。
EN

Stack Overflow用户
提问于 2020-07-08 19:01:27
回答 1查看 179关注 0票数 3

我是艾伦普的新手,这是我第一次尝试。我已经安装了所有必需的库!pip install allennlp !pip install --pre allennlp-models,我的代码也应该很好,但是我仍然收到这样的错误消息:ConfigurationError: key "matrix_attention" is required at location "model.",这是我的代码:

代码语言:javascript
运行
复制
import sys

from allennlp.predictors.predictor import Predictor
import allennlp_models

predictor = Predictor.from_path(
"https://storage.googleapis.com/allennlp-public-models/bidaf-elmo-model-2018.11.30-charpad.tar.gz"
)

prediction = predictor.predict(
passage="Life expectancy in Asia is at 68 years", question="What is the life expectancy in Asia"
)
print(prediction["best_span_str"])

你知道如何修复这个错误吗?我使用的是macOS Catalina和Python3.6。我现在真的不知道该怎么办,所以我真的需要你的帮助。提前感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-09 09:58:45

问题解决了:我的代码似乎过时了,所以我更新了它。首先,我需要安装以下依赖项:

代码语言:javascript
运行
复制
!pip install allennlp
!pip install --pre allennlp-models

这是我的密码:

代码语言:javascript
运行
复制
from allennlp.predictors.predictor import Predictor
import allennlp_models.rc
predictor = Predictor.from_path("https://storage.googleapis.com/allennlp-public-models/bidaf-elmo-model-2020.03.19.tar.gz")
result = predictor.predict(
  passage="Apple was founded by Steve Jobs, Steve Wozniak, and Ronald Wayne in April 1976 to develop and sell Wozniak\'s Apple I personal computer, though Wayne sold his share back within 12 days. It was incorporated as Apple Computer, Inc., in January 1977, and sales of its computers, including the Apple II, grew quickly.",
  question="Who founded Apple?"
)
result['best_span_str']

而且,如果有人感兴趣的话,我在Google上使用了这段代码,尽管这在其他地方也很好。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62801889

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档