• Stars
    star
    482
  • Rank 91,212 (Top 2 %)
  • Language
    Python
  • Created almost 7 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Chinese task oriented chatbot in IVR(Interactive Voice Response) domain, implement by rasa. This is a demo with toy dataset, more data should be added for performance.

note:

项目已跟进到rasa新版本,一些新特性后面尝试后补充。rasa 版本更新太快,本项目滞后最新版本较大,仅供参考,建议根据需要阅读最新rasa文档。

rasa_chatbot

A Chinese task oriented chatbot in IVR(Interactive Voice Response) domain, Implement by rasa nlu and rasa core. This is a demo with toy dataset.

install dependency:

python3

install or update to python 3

install rasa_core, this will install rasa nlu too, and now support chinese.

pip install rasa_core==0.9.0

this command will install rasa nlu too.

install sklearn and MITIE

pip install -U scikit-learn sklearn-crfsuite
pip install git+https://github.com/mit-nlp/MITIE.git

dir tree

_rasa_chatbot/
├── bot.py
├── chat_detection
├── data
│   ├── mobile_nlu_data.json # train data json format
│   ├── mobile_raw_data.txt # train data raw
│   ├── mobile_story.md # toy dialogue train data 
│   └── total_word_feature_extractor.dat # pretrained mitie word vector
├── httpserver.py # rasa nlu httpserver
├── __init__.py
├── INSTALL.md
├── ivr_chatbot.yml # rasa nlu config file
├── mobile_domain.yml # rasa core config file
├── projects # pretrained models
│   ├── dialogue
│   └── ivr_nlu
├── README.md
├── tools # tools of data process
└── train.sh # train script of rasa nlu

train nlu model

sh train.sh

命令运行耗时较长,模型训练完毕生成:

projects/
└── ivr_nlu
    └── demo
        ├── entity_extractor.dat
        ├── entity_synonyms.json
        ├── intent_classifier_sklearn.pkl
        ├── metadata.json
        └── training_data.json

test rasa nlu

$ python httpserver.py
$ curl -X POST localhost:1235/parse -d '{"q":"我的流量还剩多少"}' | python -m json.tool
{
    'q': '我的流量还剩多少', 
    'intent': 'request_search', 
    'entities': {
        'item': '流量'
    }
}

train dialogue

python bot.py train-dialogue

模型训练完毕生成:

projects
├── dialogue
│   ├── domain.json
│   ├── domain.yml
│   ├── policy_0_MemoizationPolicy
│   │   ├── featurizer.json
│   │   └── memorized_turns.json
│   ├── policy_1_KerasPolicy
│   │   ├── featurizer.json
│   │   ├── keras_arch.json
│   │   ├── keras_policy.json
│   │   └── keras_weights.h5
│   ├── policy_metadata.json
│   └── stories.md
└── ivr_nlu

train dialogue in online mode

python bot.py online_train

test

Run command below:

python bot.py run

Example1:

Bot loaded. Type a message and press enter : 
YOU:你是谁
BOT:您好!,我是机器人小热,很高兴为您服务。
YOU:我想看一下消费情况
BOT:您想查询哪个月的消费?
YOU:十月份的
BOT:好,请稍等
BOT:您好,您十月份共消费二十八元。
YOU:好谢谢
BOT:您开心我就开心
BOT:您还想干什么
YOU:没什么了
BOT:Bye, 下次再见

Example2:

Bot loaded. Type a message and press enter : 
YOU:给我看看我上月用了多少话费
BOT:好,请稍等
BOT:您好,您上月共消费二十八元。
BOT:您还想干什么

train word vector

You can train your own MITIE model using following method:

$ git clone https://github.com/mit-nlp/MITIE.git
$ cd MITIE/tools/wordrep
$ mkdir build
$ cd build
$ cmake ..
$ cmake --build . --config Release
$ ./wordrep -e /path/to/your/folder_of_cutted_text_files

/path/to/your/folder_of_cutted_text_files above is a directory path in which has word cutted data files to train. This process may cost one or two days.

More Repositories

1

semanaly

semantic analysis using word2vector, doc2vector,lstm and other method. mainly for text similarity analysis.
Python
152
star
2

short_text_cnn_cluster

Implement of paper Self-Taught Convolutional Neural Networks for Short Text Clustering using Keras.
Python
46
star
3

Flink-docker-HA

Dockerfiles and docker-compose of Flink for HA mode deploy
Shell
35
star
4

ner_elmo

NER with Deep contextualized word representations (Elmo)
Python
24
star
5

textclasser

a project for text classification using tensorflow.
Python
18
star
6

ServerOfMeteringSys

电表计量系统的服务器通信模块,对采集系统传上来的数据进行分析,并将数据插入到数据库中。服务器通信软件采用C#语言编写,服务器通信软件与数据网关通信采用UDP方式,数据库采用Oracle。
C#
9
star
7

textNN

mobile speech text classify using CNN and LSTM with pytorch.
Python
8
star
8

Scrapy

Scrapy get book info from amazon , and save it to mysql
Python
7
star
9

semi-supervised-text-classification

semi-supervised for text classification
Python
7
star
10

smallpy

Small Python implement with C++, including simple Python object, add, print methods.
C++
7
star
11

WSN_NodeDriver

C语言实现无线传感网节点软件程序。实现STM8处理器,通过SPI协议驱动SI4432无线芯片,利用超声波传感器采集车位是否被占用,并无线发送到汇聚节点。该代码通过简单修改,可作为汇聚节点接收数据。
C
6
star
12

UserLogin

User login in and regester using Springmvc+MyBatis.
Java
3
star
13

nlu_tools

NLU task (sentence semantics matching and classification) in tensorflow with simple software architecture.
Python
3
star
14

zqhZY.github.io

my blog
HTML
1
star
15

Spider

Crawling orders of people who tend to buy the same book
Python
1
star
16

myblog

A website by Flask
Python
1
star
17

PortScan

Multithread Port scan using Python. Show UI by Tkinter
Python
1
star