当前位置:网站首页>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 .
边栏推荐
- Swift - add navigation bar
- MySQL transaction
- GPS data format conversion [easy to understand]
- Learning items
- Learn the memory management of JVM 03 - Method area and meta space of JVM
- View and modify the MySQL data storage directory under centos7
- Common commands and basic operations of Apache Phoenix
- Understanding the architecture type of mobile CPU
- Why learn harmonyos and how to get started quickly?
- Acid transaction theory
猜你喜欢
Resnet+attention project complete code learning
ZABBIX ODBC database monitoring
Summary of C language learning problems (VS)
Learn memory management of JVM 01 - first memory
A guide to threaded and asynchronous UI development in the "quick start fluent Development Series tutorials"
Read and understand the rendering mechanism and principle of flutter's three trees
C language structure is initialized as a function parameter
JDBC -- extract JDBC tool classes
UNIX socket advanced learning diary -ipv4-ipv6 interoperability
Embedded software architecture design - message interaction
随机推荐
Learn memory management of JVM 01 - first memory
Yum only downloads the RPM package of the software to the specified directory without installing it
UNIX socket advanced learning diary -ipv4-ipv6 interoperability
Resnet18 actual battle Baoke dream spirit
MySQL view
Distributed solution - completely solve website cross domain requests
ZABBIX agent2 installation
Sqoop import and export operation
MySQL regular expression
IPv6与IPv4的区别 网信办等三部推进IPv6规模部署
Distributed solution - distributed session consistency problem
ZABBIX monitors mongodb (template and deployment operations)
Deep discussion on the decoding of sent protocol
Distributed solution - distributed lock solution - redis based distributed lock implementation
Redis highly available sentinel mechanism
Redis highly available slice cluster
Implementing Yang Hui triangle with cyclic queue C language
Solve the problem of cache and database double write data consistency
Redis cluster configuration
Third party payment interface design