当前位置:网站首页>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?
- [HDU 2096] 小明A+B
- Detailed steps for upgrading window mysql5.5 to 5.7.36
- SAP 自开发记录用户登录日志等信息
- The relationship between the size change of characteristic graph and various parameters before and after DL convolution operation
- Two minutes will take you to quickly master the project structure, resources, dependencies and localization of flutter
- Kotlin流程控制、循环
- Leetcode-1. Sum of two numbers (Application of hash table)
- Conversion du format de données GPS [facile à comprendre]
- [hdu 2096] Xiaoming a+b
猜你喜欢
Embedded software architecture design - message interaction
Detailed structure and code of inception V3
SAP 自开发记录用户登录日志等信息
How can beginners learn flutter efficiently?
Why learn harmonyos and how to get started quickly?
Distributed cache architecture - cache avalanche & penetration & hit rate
The relationship between the size change of characteristic graph and various parameters before and after DL convolution operation
About cache exceptions: solutions for cache avalanche, breakdown, and penetration
MySQL storage engine
ZABBIX ODBC database monitoring
随机推荐
Hexadecimal conversion summary
Introduction to relational model theory
How can beginners learn flutter efficiently?
ActiveMQ installation and deployment simple configuration (personal test)
GPS数据格式转换[通俗易懂]
Correct opening method of redis distributed lock
Solve the error 1045 of Navicat creating local connection -access denied for user [email protected] (using password
Preliminary exploration of basic knowledge of MySQL
Migrate data from Mysql to neo4j database
Learn garbage collection 01 of JVM -- garbage collection for the first time and life and death judgment
C alarm design
MySQL index - extended data
Learn the memory management of JVM 02 - memory allocation of JVM
Why learn harmonyos and how to get started quickly?
Swift - add navigation bar
C language structure is initialized as a function parameter
Redis highly available sentinel cluster
How to recover the information server and how to recover the server data [easy to understand]
Solve the problem of cache and database double write data consistency
View and modify the MySQL data storage directory under centos7