1. Chatbot_RASA is a multi-round task-based dialogue system based on RASA. The project supports quick access to task-based dialogue in different scenarios, has good generalization ability, and has the characteristics of high multi-round dialogue quality. Now the new version of RASA has supported knowledge-based dialogue. Q&A on knowledge base and Q&A on retrieve. I did some secondary development on the basis of RASA, such as introducing bert in the nlu stage, introducing reinforcement learning in the policy, etc.
2. This project will gradually provide dialogues for checking weather, checking express delivery, checking air tickets, chatting, etc. At the same time, you can also use this project to quickly verify the application of algorithm models in dialogue systems.
1. RASA overall architecture:
2. Execution process:
1. After receiving the user information, rasa will send it to the Interpreter. The data format sent to the interpreter is a dictionary, which contains: original text, recognized Intent, Slot, Sentiment, etc.
2. The Interpreter will transmit the data to the Tracker. The role of the Tracker is to record the conversation status and track the progress of the conversation.
3. Policy will obtain the current conversation status from Tracker and determine an optimal Action
4. The robot determines a response and sends it to the user based on the Action, and then feeds back the current status to the Tracker, updates the conversation status, and repeats the cycle until the conversation ends.
3. Intent
4. Slot
Currently, slot provides eleven tags:
1. Address: No. ** Street **, ** Road, ** Street, ** Village, ** District, ** City, ** Province, etc. (mark it if it appears alone). Note: The address needs to be marked completely. Mark to the smallest detail. 2. Book title: novel, magazine, exercise collection, textbook, teaching aid, atlas, cookbook, a type of book that can be purchased in a bookstore, including e-books. 3. Company: ** Company, ** Group, ** Bank (except the Central Bank and the People's Bank of China, both of which are government agencies), such as: New Oriental, including Xinhuanet/China Military Network, etc. 4. Games: common games. Note that there are some games adapted from novels and TV series. It is necessary to analyze whether the specific scenes are games. 5. Government: including central administrative agencies and local administrative agencies. The central administrative organs include the State Council, its constituent departments (including ministries, committees, the People's Bank of China and the Audit Office), agencies directly under the State Council (such as customs, taxation, industry and commerce, and the State Environmental Protection Administration, etc.), the military, etc. 6. Movies: Movies, including some documentaries shot in theaters. If it is adapted into a movie based on the title of a book, it is necessary to distinguish whether it is the title of the movie or the title of the book based on the context of the scene. 7. Name: generally refers to a person's name, including characters in novels, such as Song Jiang, Wu Song, and Guo Jing. Nicknames of characters in novels: Timely Rain, Flower Monk, nicknames of famous characters, through which nicknames can correspond to a specific character. 8. Organization: basketball team, football team, orchestra, club, etc., including gangs in the novel such as: Shaolin Temple, Beggar Gang, Iron Palm Gang, Wudang, Emei, etc. 9. Position: Professional titles in ancient times: governor, magistrate, state division, etc. Modern general managers, journalists, presidents, artists, collectors, etc. 10. Scene: Common tourist attractions such as: Changsha Park, Shenzhen Zoo, Oceanarium, Botanical Garden, Yellow River, Yangtze River, etc. 11. Time: time-related information mentioned during the conversation, such as: today, tomorrow, next week, tomorrow morning, etc.
At the same time, the slot can be added or deleted according to different scenarios.
1. Before successfully running the project, you need to install some external pip packages:
pip install chatbot_nlu
pip install chatbot_dm
2. Install bert-as-service
3. Data verification
rasa data validate --domain domain/cuishou_domain.yml
4. Train NLU & Core
rasa train --domain domain/domain.yml --data data --config config/config_with_components.yml --out models
5.Evaluating Models
6. Start Action
python -m rasa_sdk.endpoint --actions actions
7. Start the conversation service
1. Interactive Learning: # --skip-visualization
rasa run actions --actions actions&
rasa interactive -m models/20200107-105951.tar.gz --endpoints endpoints.yml
2. Debug mode
rasa run --endpoints config/endpoints.yml --enable-api --m models/20200113-162316.tar.gz --log-file bot.out.log --debug3. shell mode
rasa shell --debug
For specific instructions, please refer to RASA’s official documentation.
1. After activating the Action and dialogue models, RASA can provide services in REST form, call them for projects, or access WeChat public accounts, DingTalk groups, etc. Here I would like to introduce another project of mine:
Chatbot_Help
This project can easily connect your robot to a third-party platform and realize interaction easily and quickly.
2. After the service is started, you can test the service in postman:
Interface list:
/ conversations / < conversation_id > / messages POST add_message
/ conversations / < conversation_id > / tracker / events POST append_events
/ webhooks / rest GET custom_webhook_RestInput . health
/ webhooks / rest / webhook POST custom_webhook_RestInput . receive
/ model / test / intents POST evaluate_intents
/ model / test / stories POST evaluate_stories
/ conversations / < conversation_id > / execute POST execute_action
/ domain GET get_domain
/ socket . io GET handle_request
/ GET hello
/ model PUT load_model
/ model / parse POST parse
/ conversations / < conversation_id > / predict POST predict
/ conversations / < conversation_id > / tracker / events PUT replace_events
/ conversations / < conversation_id > / story GET retrieve_story
/ conversations / < conversation_id > / tracker GET retrieve_tracker
/ webhooks / socketio GET socketio_webhook . health
/ status GET status
/ model / predict POST tracker_predict
/ model / train POST train
/ model DELETE unload_model
/ version GET version
Interface description
a 、获取版本接口 GET方法
url : http : // 172.18 . 103.43 : 5005 / version
b 、获取服务的状态 GET方法
url : http : // 172.18 . 103.43 : 5005 / status
{
"model_file" : "models/20200109-103803.tar.gz" ,
"fingerprint" : {
"config" : "99914b932bd37a50b983c5e7c90ae93b" ,
"core-config" : "506804ad89d3db9175b94c8752ca7537" ,
"nlu-config" : "45f827a042c25a6605b8a868d95d2299" ,
"domain" : 2088252815302883506 ,
"messages" : 2270465547977701800 ,
"stories" : 1278721284179639569 ,
"trained_at" : 1578537378.2885341644 ,
"version" : "1.4.1"
},
"num_active_training_jobs" : 0
}
c 、会话接口 POST方法
url : http : // 172.18 . 103.43 : 5005 / webhooks / rest / webhook
参数:{
"sender" : "000001" ,
"message" : "你好"
}
返回参数:
[
{
"recipient_id" : "202005210002" ,
"text" : "您好,我是智能助手小笨,有什么可以帮您的?"
}
]
d 、 button接口
e 、检索story
f 、 story (话术)可视化
- 2020.1.7 Access to DingTalk group, supporting active push messages and outgoing interactions
- 2020.1.9 Access WeChat
- 2020.5.1 Solve the cross-domain request problem of rasa
- 2020.6 Introducing botfront