我们正在尝试使用 allennlp 在页面https://docs.allennlp.org/models/main/#pre-trained-models 中使用下面的 colab 代码提供的评估 rc-lerc 预训练模型
!pip install allennlp==1.0.0 allennlp-models==1.0.0
!pip install --pre allennlp-models
!pip install -U nltk
from allennlp.predictors.predictor import Predictor
import allennlp_models
# The instance we want to get LERC score for in a JSON format
input_json = {
'context': 'context string',
'question': 'question string',
'reference': 'reference string',
'candidate': 'candidate string'
}
# evaluate_rc-lerc - A BERT model that scores candidate answers from 0 to 1.
# Loads an AllenNLP Predictor that wraps our trained model
predictor = Predictor.from_path(
archive_path='https://storage.googleapis.com/allennlp-public-models/lerc-2020-11-18.tar.gz',
predictor_name='lerc',
cuda_device=0
)
output_dict = predictor.predict_json(input_json)
print('Predicted LERC Score:', output_dict['pred_score'])
错误:ConfigurationError:lerc 不是模型的注册名称。您可能需要使用 --include-package 标志来加载您的自定义代码。或者,您可以使用完全限定的路径指定您的选择,例如 {"model": "my_module.models.MyModel"} 在这种情况下它们将被自动正确导入。
即使在使用 pip install allennlp-models==2.2.0 的最新软件包之后
得到同样的错误。'evaluate_rc-lerc' 的任何工作代码片段将不胜感激,直接使用保存的存档来避免训练/微调