语言如何设置(怎么调语言设置)
780
2022-05-30
相关链接
官方源码:https://github.com/deepmipt/DeepPavlov
官方文档:http://docs.deeppavlov.ai/en/master/features/models/kbqa.html
介绍博客:https://www.jiqizhixin.com/articles/2018-02-27-6
安装
conda create -n deeppavlov python=3.7 conda activate deeppavlov python -m pip install deeppavlov python -m pip install tensorflow-gpu==1.15.2
CUDA 10.0
环境变量
vim ~/.bashrc
export CUDA_HOME=/usr/local/cuda-10.0/bin export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64 export PATH=/usr/local/cuda-10.0/bin:$PATH
查看版本
nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2018 NVIDIA Corporation Built on Sat_Aug_25_21:08:01_CDT_2018 Cuda compilation tools, release 10.0, V10.0.130
下载模型和数据
配置文件:https://github.com/deepmipt/DeepPavlov/blob/master/deeppavlov/configs/kbqa/kbqa_cq.json
"download" 关键字段里有10个文件,下载好后放到对应的目录:`~/.deeppavlov/models` 和 `~/.deeppavlov/downloads`
`wget url`,部分压缩文件解压如下:
unzip cased_L-12_H-768_A-12.zip -d ./bert_models tar -zxvf ner_lcquad.tar.gz -C ./ner_lcquad_ent_and_type tar -zxvf rel_ranking.tar.gz -C ./rel_ranking tar -zxvf rel_ranking_bert.tar.gz -C ./rel_ranking_bert tar -zxvf wiki_eng_files.tar.gz -C ../downloads/wikidata_eng tar -zxvf query_prediction.tar.gz -C ./query_prediction
NLTK 设置代理
import nltk nltk.set_proxy("xxx:xxx@proxy.xxx.com:8080") nltk.download('stopwords') nltk.download("punkt")
执行代码
vim test.py
import os from deeppavlov import configs, build_model import warnings import tensorflow as tf import nltk nltk.set_proxy("xxx:xxx@proxy.xxx.com:8080") os.environ['CUDA_VISIBLE_DEVICES'] = '0' warnings.filterwarnings('ignore') os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3" tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR) config_path = "DeepPavlov-master/deeppavlov/configs/kbqa/kbqa_cq.json" kbqa_model = build_model(config_path, download=False) x = kbqa_model(['What is in the village of Negev that has diplomatic relations with the Czech Republic?']) print(x) y = kbqa_model(['Magnus Carlsen is a part of what sport?']) print(y) z = kbqa_model(['How many sponsors are for Juventus F.C.?']) print(z)
结果:python test.py
["Israel"] ["chess"] [4]
知识图谱
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。