安装环境
- CentOS7
- 内存至少16G以上
- python3.6
安装步骤
- 安装搭建Anaconda3
conda install pytorchvision cuda90 -c pytorch
git clone https://github.com/facebookresearch/DrQA.git
cd DrQA
pip install -r requirements.txt
python setup.py develop
- ./install_corenlp.sh # 如果不能执行*.sh 需要执行:chmod u+x *.sh
- 将下载的jar文件引入classpath环境变量或在调用的程序代码
- 环境变量(推荐): vim /etc/profile 添加 export CLASSPATH=$CLASSPATH:/home/tgm/DrQA/data/corenlp/*
- 修改程序(不推荐):pipeline中的interactive中加入如下代码
- import drqa.tokenizers
- drqa.tokenizers.set_default(‘corenlp_classpath’, ‘/your/corenlp/classpath/*’)
- 环境变量(推荐): vim /etc/profile 添加 export CLASSPATH=$CLASSPATH:/home/tgm/DrQA/data/corenlp/*
- 安装完成后测试(应该在DrQA目录下,进入python交互环境)
from drqa.tokenizers import CoreNLPTokenizer
tok = CoreNLPTokenizer()
tok.tokenize('hello world').words() # Should complete immediately
- 显示 [‘hello’, ‘world’] 正常
- 下载提供的训练模型和数据,大小7.5G,速度会很慢,解压后,大小25G
- ./download.sh
- 这样就安装完成了
- 运行:
python scripts/pipeline/interactive.py
- 可能会报内存错误,至少需要16G的内存才能正常运行
- 交互运行:process(“What is question answering?”)
- process(“What is the answer to life, the universe, and everything?”)
- process(“Who was the winning pitcher in the 1956 World Series?”)
- 数据处理
- 训练并生成模型
- 利用模型进行交互
参考博客