项目作者: L-M-Sherlock

项目描述 :
招生咨询信息问答系统
高级语言: Python
项目地址: git://github.com/L-M-Sherlock/HITszQAbot.git
创建时间: 2020-01-08T09:24:21Z
项目社区:https://github.com/L-M-Sherlock/HITszQAbot

开源协议:

下载


HITszQAbot

简介

HITszQAbot 是基于深度学习文本分类算法,面向招生信息咨询的 QQ 问答机器人。

项目结构

  1. ├── nlp_module # 文本分类网络
  2. ├── pytorch_pretrained
  3. ├── ERNIE_pretrain
  4. ├── models
  5. └── bert.py # 模型
  6. ├── RequestHandler.py # 调用模型
  7. ├── run.py # 训练模型
  8. ├── train_eval.py # 训练过程
  9. ├── utils.py # 原数据处理
  10. └── utils_new.py # 数据处理工具
  11. ├── src # nonebot 框架
  12. └── plugins
  13. ├── faq
  14. └── __init__.py # 群问答插件
  15. └── txt_tools.py # 文本处理工具
  16. ├── .env # 环境配置
  17. ├── bot.py # 启动
  18. └── config.py # 配置文件

环境

python 3.7 及以上

nlp_module/bert_pretrain 下的 pytorch_model.bin 请自行下载,详情见 bert_pretrain/README.md

本项目没有上传训练好的模型,请自行训练

数据

数据文件:./nlp_module/HITSZQA/data/train.txt

数据格式:question+'\t'+'\_label\_'+label

将处理好的数据放入 ./nlp_module/HITSZQA/data/ 中替换 train.txt

训练

请移步至此项目:

https://github.com/L-M-Sherlock/Bert-Chinese-Text-Classification-Pytorch

预测

预测 label:python .nlp_module/RequestHandler.py

将需要分类的 question 放入 rh_sub.get_result('分类句子') 中运行,得到分类结果

部署

以 Ubuntu 18.04 为例

go-cqhttp

首先,要安装 go-cqhttp,请执行以下命令:

```shell script
wget https://github.com/Mrs4s/go-cqhttp/releases/download/v1.0.0-beta2/go-cqhttp_1.0.0-beta2_linux_amd64.deb
dpkg -i go-cqhttp_1.0.0-beta2_linux_amd64.deb

  1. 默认情况下,go-cqhttp 已经安装到 `/usr/local/bin` 之下了。接下来我们要配置 go-cqhttp,请执行以下命令:
  2. ```shell script
  3. cd /usr/local/bin
  4. ./go-cqhttp

初次运行 go-cqhttp 会自动生成配置文件。退出 go-cqhttp 后,请自行修改 config.yml

除了必填的账号和密码外,考虑到之后 NoneBot 需要通过 ws 与 go-cqhttp 通信,请将 config.yml 中的 ws-reverse 一项修改成:

  1. - ws-reverse:
  2. # 是否禁用当前反向WS服务
  3. disabled: false # 开启
  4. # 反向WS Universal 地址
  5. # 注意 设置了此项地址后下面两项将会被忽略
  6. universal: ws://127.0.0.1:8080/cqhttp/ws # 端口号需要与NoneBot的PORT一致

以上就是 go-cqhttp 的具体配置。

NoneBot

首先,要 clone 本项目的代码,地址任意。

然后请创建虚拟环境,再执行以下命令安装依赖包:

```shell script
pip install -r requirements.txt

  1. 注意:本项目由于是在 window 上测试的,所以 requirements.txt 中的 pytorch cpu 版本,服务器部署若需要使用显卡,请自行修改。
  2. 待依赖安装完毕后,运行以下命令即可开启 NoneBot
  3. ```shell script
  4. python bot.py

另外,为了让 go-cqhttp 和 nonebot 通信,请在 bot.py 同级目录下建立 .env,并完善以下配置:

  1. HOST=127.0.0.1
  2. PORT=8080
  3. DEBUG=true
  4. SUPERUSERS=["<管理员QQ号>"]
  5. NICKNAME=["<BOT的昵称>"]
  6. COMMAND_START=["/", ""]

上述内容仅为示例,请按需配置。