法研杯(CAIL 2019)相似案例匹配任务问题汇总
参考资料:https://github.com/padeoe/cail2019,在大佬的方案基础上,自己独自实现的过程中遇到的问题梳理如下:
- docker: Error response from daemon: Unknown runtime specified nvidia.
See ‘docker run --help’.
首先确保安装nvidia-docker
yum install nvidia-docker2
或者
sudo apt install nvidia-docker2
然后/etc/docker/daemon.json修改如下:
{
"registry-mirrors": ["https://f1z25q5p.mirror.aliyuncs.com"],
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
}
}
最后重启
sudo systemctl daemon-reload
sudo systemctl retstart docker
-
docker pull 拉取镜像 unauthorized: authentication required
解决方案:
-
docker login
-
同步时间
yum install ntp ntpdate pool.ntp.org
- Jupyter notebook 配置
- ModuleNotFoundError: No module named ‘transformers’
这种情况出现的原因可能就是指定安装的transformers的版本太低,现在一般使用3.4版本的较多,可以尝试一:将自己安装的低版本进行升级为版本较高的transformers,即 pip install transformers==3.4。如果以上的方式仍然不能成功,我自己尝试的方式是安装transformers的时候不指定具体的版本,让机器自己安装对应的版本的transformers ,
pip install transformers
socket.timeout: The read operation timed out解决方案
pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple/
- IndentationError: unexpected indent
indentation是缩进,缩排的意思。unexpected indent 就是说“a”是一个“意外的”缩进。通过查看源代码找到缩进的字符位。
把这句话的缩进取消,也就是顶格写,就可以正常运行了
- Running as root is not recommended. Use --allow-root to bypass
gedit /root/.jupyter/jupyter_notebook_config.py
修改以下内容
#c.NotebookApp.allow_root = False
为
c.NotebookApp.allow_root = True
保存,重新运行程序
jupyter notebook
- TypeError: init() got an unexpected keyword argument ‘encoding’
原因是python2和python3的差别,如示例,可删掉其中的encoding=‘utf-8’
- Model name ‘pretrained\chinese_L-12_H-768_A-12’ was not found in model name list (bert-base-uncased, bert-large-uncased, bert-base-cased, bert-large-cased, bert-base-multilingual-uncased, bert-base-multilingual-cased, bert-base-chinese). We assumed ‘pretrained\chinese_L-12_H-768_A-12\vocab.txt’ was a path or url but couldn’t find any file associated to this path or url.
解决方案:
下载地址:https://storage.googleapis.com/bert_models/2018_11_03/chinese_L-12_H-768_A-12.zip
然后下载的文件中解压有vocab.txt文件,放到pretrained\chinese_L-12_H-768_A-12
就可以了
缺少 config.json,修改bert_config.json文件为config.json
9. [OSError: Error no file named [‘pytorch_model.bin’, ‘tf_model.h5’, ‘model.ckpt.index’]
解决方案:https://huggingface.co/gsarti/biobert-nli/tree/main
下载
10. RuntimeError: Error(s) in loading state_dict for BertForSimMatchModel: size mismatch for embeddings.word_embeddings.weight: copying a param with shape torch.Size([28996, 768]) from checkpoint, the shape in current model is torch.Size([21128, 768])
原因:加载的模型的word_embedding层参数和当前model输入的参数不匹配。
解决:word2id、tag2id的长度要一致。