首先按照Github提示创环境
cd CronKGQA
conda create --prefix ./cronkgqa_env python=3.8
conda activate ./cronkgqa_env
版本不匹配 重新装1.7.1的pytorch:
conda install pytorch==1.7.1 torchvision==0.8.2 cudatoolkit=11.0 -c pytorch
cronkgqa_testing.ipynb
可以用来测试模型对任何文本问题的响应。(问题中也给出了实体和时间的列表)
1. RuntimeError: Error(s) in loading state_dict for Model: Missing key(s) in state_dict
修改:
qa_model.load_state_dict(torch.load(filename), False)
load_state_dict方法参数的官方说明 strict 参数默认是true,他的含义是 是否严格要求state_dict中的键与该模块的键返回的键匹配。strict 置为false那么就可以忽略掉报错,请注意是忽略。
参考:blog
2. Output exceeds the size limit. Open the full output data in a text editor
Note
采用warnings模块忽略warning
import warnings
warnings.filterwarnings("ignore")#程序中
python -W ignore xx.py # 命令行