当前位置:网站首页>Rasa Chat Robot Tutorial (translation) (1)
Rasa Chat Robot Tutorial (translation) (1)
2022-07-05 12:39:00 【NLP journey】
brief introduction
rasa Is an open source dialogue robot . Mainly for task-based dialogue robots , Open source code :
Tutorial address :https://rasa.com/docs/rasa/
github Address :https://github.com/RasaHQ/rasa
An example
The tutorial provides an interactive example of getting started rasa Basic concepts of .
Create assistant
This example creates a chat assistant that helps users subscribe to news , Follow these steps to learn how a simple helper is created :
- NLU data
No matter how the user expresses , In order for the machine to understand what the user said , Some message samples that the machine can learn must be provided . Group these samples according to the intention of the message . In the following example , Added “greet" The intent of the , The messages included in this intention are :“hi",“Hey”,"good morning" etc. .
nlu:
- intent: great
examples:|
- Hi
- Hey!
- Hallo
- Good day
- Good morning
- intent: subscribe
example:|
- I want to get the newsletter
- can you send me the newsletter?
- can you sign me up for the newsletter?
- intent: inform
example:|
-My email is [email protected]
[email protected]
- please send it to [email protected]
Intentions and their examples are used as training data for robot language understanding module .
- Response
Through the language understanding part , The machine understands the purpose of user expression . Then it needs to reply to the user . Here are some examples of responses , If a reply corresponds to multiple texts , These texts will be randomly selected as reply content .
responses:
utter_greet:
- text: |
Hello! How can I help you?
- text: |
Hi!
utter_ask_email:
- text: |
What is your email address?
utter_subscribed:
- text: |
Check your inbox at {email} in order to finish subscribing to the newsletter!
- text: |
You're all set! Check your inbox at {email} to confirm your subscription.
stories
stories Is an example of a conversation , It is used to train robots to make corresponding replies based on the user's dialog content . Its format is the user's intention , Then there is the reply of the machine or the action that should be taken .
The first story should be a direct process for robots to help users achieve their goals . then , You can add stories that users do not provide information or turn to other topics . In the following example , Added a user to exchange greetings with the robot , The story of a user making a subscription request and then a machine requesting user information .
stories:
- story: greet and subscribe
steps:
- intent: greet
- action: utter_greet
- intent: subscribe
- action: newsletter_form
- active_loop: newsletter_form
Forms
In many cases, machines need to collect user information , For example, users subscribe to news , You need to know the user's email . stay Rasa Inside , Collect information and use forms to complete . The following example shows a form for collecting user mailboxes .
slots:
email:
type: text
mappings:
- type: from_text
conditions:
- active_loop: newsletter_form
requested_slot: email
forms:
newsletter_form:
required_slots:
- email
Rules
Rules Defined some fixed rules , For some purposes , Use rules to define the machine's fixed response to these intentions . For example, in the following example , The first rule defines when identifying users is subscribe When the intention of , Adopt startup newsletter_form act . The second rule is only in newsletter_form It will not start until it is started , When active loop The state is no longer active , Even if the form is completed .
rules:
- rule: activate subscribe form
steps:
- intent: subscribe
- action: newsletter_form
- active_loop: newsletter_form
- rule: submit form
condition:
- active_loop: newsletter_form
steps:
- action: newsletter_form
- active_loop: null
- action: utter_subscribed
Train and talk to your assistant
With the data above , You can train the model . The original text provides an exchange meeting for training , You can train the model by pressing the training button , After training, you can also talk directly .
You can follow the examples provided in the tutorial , Modify the code , Adapt to a new task .
You have built an assistant , What's next ?
After training the model , You can verify whether the robot meets your requirements through dialogue . But for complex tasks , Manual testing is inefficient .rase Provides a method of automated testing , Build for testing stories, And then execute rasa test You can automate the test . The test of stories Long bottom like this :
stories:
- story: test for greet and subscribe
steps:
- user: |
Hello there
intent: greet
- action: utter_greet
- user: |
I want to subscribe to the newsletter. My email is [email protected]
intent: subscribe
- action: utter_subscribed
summary
Just like program language hello world equally , This part introduces rasa One of the robots hello world Program . Know how to use rasa Data and components to be provided : For training language understanding module NLU data , It is used for the machine to generate a corresponding reply to the user's intention Response data , For dialogue process Stories data , Components that collect user information and what robots must abide by Rules Set up . Last , It also introduces the of automated testing rasa test command .
边栏推荐
- GPON other manufacturers' configuration process analysis
- MySQL index (1)
- Distributed solution - distributed lock solution - redis based distributed lock implementation
- Kotlin流程控制、循环
- Two minutes will take you to quickly master the project structure, resources, dependencies and localization of flutter
- JDBC exercise - query data encapsulated into object return & simple login demo
- Flutter2 heavy release supports web and desktop applications
- Introduction to GNN
- View and modify the MySQL data storage directory under centos7
- Hexadecimal conversion summary
猜你喜欢
Automated test lifecycle
Redis clean cache
Take you two minutes to quickly master the route and navigation of flutter
UNIX socket advanced learning diary -ipv4-ipv6 interoperability
Yum only downloads the RPM package of the software to the specified directory without installing it
JSON parsing error special character processing (really speechless... Troubleshooting for a long time)
MySQL splits strings for conditional queries
Volatile instruction rearrangement and why instruction rearrangement is prohibited
Third party payment interface design
Preliminary exploration of basic knowledge of MySQL
随机推荐
Hexadecimal conversion summary
PXE启动配置及原理
Understanding the architecture type of mobile CPU
Get data from the database when using JMeter for database assertion
struct MySQL
图像超分实验:SRCNN/FSRCNN
MySQL regular expression
Conversion du format de données GPS [facile à comprendre]
End to end neural network
Introduction to relational model theory
Iterator details in list... Interview pits
信息服务器怎么恢复,服务器数据恢复怎么弄[通俗易懂]
Seven polymorphisms
Ecplise development environment configuration and simple web project construction
GPS数据格式转换[通俗易懂]
MySQL installation, Windows version
SAP 自开发记录用户登录日志等信息
Detailed structure and code of inception V3
Implementing Yang Hui triangle with cyclic queue C language
Third party payment interface design