RASA2.2.X Rasa Playground

Learn the basics of building an assistant with Rasa Open Source with this interactive guide. You will be able to customize the assistant, talk to it and download the project so you can continue to build.

通过本交互式指南,学习使用Rasa开源构建助手的基础知识。您将能够自定义assistant,与它对话并下载项目,以便继续构建。

 

Build your assistant

建立你的助理

In this guide, we are creating an assistant that helps users subscribe to a newsletter. Go through each of the steps below to see how a simple assistant is created:

在本指南中,我们将创建一个帮助用户订阅时事通讯的助手。通过下面的每一个步骤,看看如何创建一个简单的助手

  1. NLU data

What are the various things people might say to an assistant that can help them subscribe to a newsletter?

For an assistant to recognize what a user is saying no matter how the user phrases their message, we need to provide example messages the assistant can learn from. We group these examples according to the idea or the goal the message is expressing, which is also called the intent. In the code block on the right, we have added an intent called greet, which contains example messages like “Hi”, “Hey”, and “good morning”.

Intents and their examples are used as training data for the assistant's Natural Language Understanding (NLU) model.

人们会对助手说些什么来帮助他们订阅时事通讯呢?
为了让助手能够识别用户所说的内容,不管用户如何表达他们的消息,我们需要提供助手可以学习的示例消息。我们根据信息所表达的想法或目标(也称为意图)将这些例子进行分组。在右侧的代码块中,我们添加了一个名为greet的意图,它包含了像“Hi”、“Hey”和“good morning”这样的示例消息。意图和它们的例子被用作协会的训练数据

RASA2.2.X Rasa Playground_第1张图片

 

  1. Responses  

 

Now that the assistant understands a few messages users might say, it needs responses it can send back to the user.

 

“Hello, how can I help you?” and “what’s your email address?” are some of the responses our assistant will use. You’ll see how to connect user messages and responses in the next steps.

 

In the code block below, we have listed some responses and added one or more text options for each of them. If a response has multiple text options, one of these options will be chosen at random whenever that response is predicted.

现在,助手理解了用户可能会说的一些消息,它需要可以发送回用户的响应。您好,有什么需要帮忙的吗?你的电子邮件地址是什么?是我们的助理会用到的一些回答。在接下来的步骤中,您将看到如何连接用户消息和响应。在下面的代码块中,我们列出了一些响应,并为每个响应添加了一个或多个文本选项。如果一个响应有多个文本选项,那么在预测该响应时将随机选择其中一个选项。

RASA2.2.X Rasa Playground_第2张图片

 

  1.  Stories

Stories are example conversations that train an assistant to respond correctly depending on what the user has said previously in the conversation. The story format shows the intent of the user message followed by the assistant’s action or response.

 

Your first story should show a conversation flow where the assistant helps the user accomplish their goal in a straightforward way. Later, you can add stories for situations where the user doesn't want to provide their information or switches to another topic.

 

In the code block below, we have added a story where the user and assistant exchange greetings, the user asks to subscribe to the newsletter, and the assistant starts collecting the information it needs through the newsletter_form. You will learn about forms in the next step.

故事是训练助手根据用户之前在对话中所说的正确回应的示例对话。故事格式显示了用户消息的意图,随后是助理的操作或响应。您的第一个故事应该显示一个对话流程,其中助手将帮助用户以一种直接的方式实现他们的目标。稍后,您可以为用户不希望提供他们的信息或切换到另一个主题的情况添加故事。在下面的代码块中,我们添加了一个故事,用户和助手在其中交换问候,用户请求订阅时事通讯,助手开始通过时事通讯表单收集它需要的信息。您将在下一步了解表单。

RASA2.2.X Rasa Playground_第3张图片

 

  1. Forms 表单

There are many situations where an assistant needs to collect information from the user. For example, when a user wants to subscribe to a newsletter, the assistant must ask for their email address.

 

You can do this in Rasa using a form. In the code block below, we added the newsletter_form and used it to collect an email address from the user.

有很多情况下,助理需要从用户那里收集信息。例如,当用户想要订阅时事通讯时,助理必须要他们的电子邮件地址。
您可以在Rasa中使用表单来实现这一点。在下面的代码块中,我们添加了newsletter_form,并使用它从用户那里收集电子邮件地址。

RASA2.2.X Rasa Playground_第4张图片

 

 

  1. Rules

 

规则描述的是对话的某些部分应该始终遵循相同的路径,无论之前在对话中说了什么。我们希望我们的助手总是以特定的行动响应特定的意图,因此我们使用规则将该行动映射到意图。在下面的代码块中,我们添加了一条规则,每当用户表示意图订阅时,该规则就会触发newsletter_form。我们还添加了一个规则,一旦提供了所有必需的信息,就会触发utter_subscribed动作。第二条规则仅适用于以下情况:通讯表单一开始是激活的;一旦它不再活动(active_loop: null),表单就完成了。学习更多关于规则和如何编写规则的知识。现在你已经完成了所有的步骤,向下滚动与你的助手交谈。

RASA2.2.X Rasa Playground_第5张图片

 

Train and talk to your assistant

Once you have reviewed the steps above, you’re ready to train your assistant. The training process generates a new machine learning model based on the training data you’ve provided.

 

To train the assistant on the NLU data, stories, forms, rules and responses above, click the Train button:

一旦你回顾了上面的步骤,你就准备好培训你的助手了。训练过程根据您提供的训练数据生成一个新的机器学习模型。

要对助理进行NLU数据、故事、表格、规则和回答的培训,请点击train按钮:

RASA2.2.X Rasa Playground_第6张图片

RASA2.2.X Rasa Playground_第7张图片

 

 

Looking for a challenge? Customize your assistant

You can use this page to create an assistant that does something other than helping users subscribe to a newsletter.

 

Try choosing a simple task for your assistant to do, like ordering a pizza or booking an appointment. Adapt the code blocks at each step to fit the new scenario, then train your assistant again to see it in action.

您可以使用此页面创建一个助手,该助手除了帮助用户订阅时事通讯外,还可以做其他事情。

试着选择一个简单的任务让你的助手来做,比如订披萨或预约。在每个步骤中调整代码块以适应新的场景,然后再次培训您的助手以查看它的实际操作。

 

You have built your assistant! What’s next?#

 

Install Rasa open source to keep building.

When you train a model, you always want to check that your assistant still behaves as you expect. You can do that by talking to your assistant and seeing that it works. However, as your assistant becomes more complex, you will want to use test stories to ensure your model makes correct predictions

当你训练一个模型时,你总是想要检查你的助手是否仍然像你期望的那样行为。你可以和你的助理谈谈,看看它是否有效。然而,随着您的助手变得更加复杂,您将希望使用测试故事来确保您的模型做出正确的预测

尝试运行rasatest 以确保您的助手通过测试:

RASA2.2.X Rasa Playground_第8张图片

Check out other docs pages to learn more about Rasa’s CLIDomainsActions, and your config’s Pipeline and Policies.

查看其他文档页面,了解更多关于Rasa的CLI、域、动作和配置的管道和策略。

你可能感兴趣的:(rasa,自然语言处理)