当前位置:网站首页>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 .
边栏推荐
- How does MySQL execute an SQL statement?
- How to recover the information server and how to recover the server data [easy to understand]
- MySQL data table operation DDL & data type
- Time conversion error
- Distributed solution - distributed session consistency problem
- Solve the problem of cache and database double write data consistency
- Redis highly available sentinel cluster
- Array cyclic shift problem
- II. Data type
- Preliminary exploration of basic knowledge of MySQL
猜你喜欢
Preliminary exploration of basic knowledge of MySQL
Storage Basics
JDBC -- extract JDBC tool classes
Knowledge representation (KR)
A guide to threaded and asynchronous UI development in the "quick start fluent Development Series tutorials"
Learn memory management of JVM 01 - first memory
UNIX socket advanced learning diary -ipv4-ipv6 interoperability
Flutter2 heavy release supports web and desktop applications
Constructing expression binary tree with prefix expression
ActiveMQ installation and deployment simple configuration (personal test)
随机推荐
MySQL stored procedure
Why learn harmonyos and how to get started quickly?
JDBC exercise - query data encapsulated into object return & simple login demo
Learning items
Solve the error 1045 of Navicat creating local connection -access denied for user [email protected] (using password
语义分割实验:Unet网络/MSRC2数据集
Get data from the database when using JMeter for database assertion
MySQL transaction
Get the variable address of structure member in C language
Leetcode-1. Sum of two numbers (Application of hash table)
Add a new cloud disk to Huawei virtual machine
A new WiFi option for smart home -- the application of simplewifi in wireless smart home
JSON parsing error special character processing (really speechless... Troubleshooting for a long time)
前几年外包干了四年,秋招感觉人生就这样了..
Learn garbage collection 01 of JVM -- garbage collection for the first time and life and death judgment
MySQL index (1)
MySQL regular expression
ZABBIX customized monitoring disk IO performance
Distributed solution - Comprehensive decryption of distributed task scheduling platform -xxljob
Take you two minutes to quickly master the route and navigation of flutter