rasa 实体,意图_使用rasa在实体数据中定义概念_weixin_26728245的博客-程序员宅基地

技术标签: python  java  机器学习  大数据  

rasa 实体,意图

介绍(Introduction)

Looking at the chatbot development tools and environments currently available, there are three ailments which require remedy:

查看当前可用的聊天机器人开发工具和环境,有三种需要补救的疾病:

  • Compound Contextual Entities

    复合上下文实体

  • Entity Decomposition

    实体分解

  • Deprecation of Rigid State Machine, Dialog Management

    弃用刚性状态机,对话框管理

Rasa is actively addressing all three of these items. But, the concern of this article is entities which can be decomposed and broken up into types or groupings.

Rasa积极解决所有这三个问题。 但是,本文关注的是可以分解并分解为类型或分组的实体。

For example, in a banking scenario, you will most probably have the entity of account. This alone can suffice and in general you don’t have more options to work with.

例如,在银行业务场景中,您很可能拥有帐户实体 仅此一项就足够了,通常您没有更多选择。

But the ideal is to have the ability to create subsets for entities. Or, as in this case, be able to assign roles to the entity of account. For instance, there are different types of accounts. When you transfer money, you would want to have a to and from type of entity account.

但是理想的情况是具有为实体创建子集的能力。 或者,在这种情况下,可以将角色分配给account的实体。 例如,有不同类型的帐户。 当你汇款,你会希望有一个实体类型的帐户

添加实体角色 (Adding Entity Roles)

In the nlu.md file, I have defined an intent to exchange money from one currency to another. This is an example of a user utterance with compound entities.

nlu.md文件中,我定义了一种将货币从一种货币兑换为另一种货币的意图。 这是使用复合实体的用户话语的示例。

Within the user utterance, three entities are defined:

在用户话语中,定义了三个实体:

  • Transaction

    交易
  • Currency

    货币
  • Date/Time

    约会时间

Here is an example of how to define entities with roles in the nlu.md file.

这是一个如何在nlu.md文件中定义具有角色的实体的示例

## intent:exchange- I want to [change](transaction) [US dollars]{"entity": "currency", "role": "change_from"} to [Euros]{"entity": "currency", "role": "change_to"} on [Friday](date_time)- Can I [exchange](transaction) [euros]{"entity": "currency", "role": "change_from"} for [Rand]{"entity": "currency", "role": "change_to"} on [Saturday](date_time)- give me a rate to [change](transaction) [pounds sterling]{"entity": "currency", "role": "change_from"} for [Japanese Yen]{"entity": "currency", "role": "change_to"} on [Monday](date_time)- what are rates to [convert](transaction) [Australian Dollar]{"entity": "currency", "role": "change_from"} for [Russian Ruble]{"entity": "currency", "role": "change_to"} on [next week Thursday](date_time)- I want to [change](transaction) [US dollars]{"entity": "currency", "role": "change_from"} to [Canadian dollar]{"entity": "currency", "role": "change_to"} on [Friday](date_time)

The entity of currency is broken up into two roles:

货币实体分为两个角色:

  • Change From and

    更改

  • Change To.

    改成。

Here is a practical example of user input requesting to exchange money. This is performed using Postman and the Rasa NLU API.

这是用户输入请求兑换货币的实际示例。 这是使用Postman和Rasa NLU API执行的。

Image for post
User utterance example with multiple compound entities.
具有多个复合实体的用户话语示例。

The JSON output clearly define the recognized intent of exchange. With this, three entities are identified. The entity of currency has an additional value of role. In this case, the segmenting the currency changed from and to.

JSON输出明确定义了公认的交换意图 这样,确定了三个实体。 货币实体具有附加的角色价值 在这种情况下,对货币的细分从和更改为。

Image for post
exchange with the 实体entities and 各自角色的 respective roles. 交换

添加实体组 (Adding Entity Groups)

Entity groups allow for entities to be grouped together. In the banking example, I have created the entity tiers. There are 5 tiers; Silver, Gold and Bronze; grouped together. Constituting group one.

实体组允许将实体分组在一起。 在银行业务示例中,我创建了实体。 共有5层; 银,金和青铜; 分组在一起。 组成第一组。

Platinum & Black are grouped together. Constituting group two.

白金黑色组合在一起。 组成第二组。

Here is an example on how to define entities with groups in the nlu.md file.

这是有关如何在nlu.md文件中定义具有组的实体的示例

## intent:tiers- [Silver]{"entity": "tiers", "group": "1"} accounts have lower interest for saving than [Platinum]{"entity": "tiers", "group": "2"} - [Gold]{"entity": "tiers", "group": "1"} accounts have lower interest for saving than [black]{"entity": "tiers", "group": "2"}- [Bronze]{"entity": "tiers", "group": "1"} accounts have lower interest for saving than [Platinum]{"entity": "tiers", "group": "2"}

And the example of a user utterance, mentioning two of the tiers.

还有一个用户话语示例,其中提到了两个层次。

Image for post
User utterance with different tiers which can be grouped.
可以分组的不同级别的用户话语。

The result is a JSON output with the entity tiers defined, and the grouping of the entity.

结果是定义了实体和实体分组的JSON输出。

Image for post
tiers is correctly identified, with the 值正确标识了意图 group value for each entity.

Rasa实体 (Rasa Entities)

语境与复合(Contextual & Compound)

One of Rasa’s strong points all along were compound and contextual entities.

一直以来,Rasa的强项之一是复合实体和上下文实体。

Contextually means that entities are not recognized by the chatbot by asking the user directly for the input, or found via a finite lookup list. But rather entities are detected based on their context within the utterance or sentence.

上下文意味着聊天机器人无法通过直接向用户询问输入或通过有限的查找列表来发现实体。 而是根据实体在话语或句子中的上下文来检测实体。

This is closer aligned with how we as humans detect entities in a conversation.

这与我们人类如何检测对话中的实体更加一致。

Image for post
Rasa ~ Compound & Contextual Entities in Rasa-X
Rasa〜Rasa-X中的复合和上下文实体

Compound entities mean I can capture multiple entities per intent, or user utterance. In a scenario where the user gives you all the information in one utterance, you have the ability to capture all those values in one go.

复合实体意味着我可以根据意图或用户话语捕获多个实体。 在用户一次发给您所有信息的情况下,您可以一次性捕获所有这些值。

This translate into fewer dialog turns and a more efficient chatbot.

这样可以减少对话次数,提高聊天机器人的效率。

实体角色 (Entity Roles)

The starting point of entities are that you can add labels to words. Hence you can define concepts in your data.

实体的起点是可以在单词上添加标签。 因此,您可以在数据中定义概念。

In the example below, you have different city types defined with other entities.

在以下示例中,您与其他实体定义了不同的城市类型。

## intent:travel_details- I want to travel by [train](travel_mode) from [Berlin](from_city) to [Stuttgart](to_city) on [Friday](date_time)

This is not elegant, as multiple entities need to be created for one real-word object, namely city.

这不是很优雅,因为需要为一个实词对象(即city)创建多个实体。

And in this example, city have two roles; the city of departure and the city of arrival. With Rasa you are able to define these entities with specific roles in your project’s nlu.md file.

在这个例子中,城市扮演着两个角色。 出发城市和到达城市。 使用Rasa,您可以在项目的nlu.md文件中定义具有特定角色的这些实体。

## intent:travel_details
- I want to travel by [train](travel_mode) from [Berlin]{"entity": "city", "role": "depart"} to [Stuttgart]{"entity": "city", "role": "arrive"} on [Friday](date_time)

The output looks like this:

输出如下所示:

I want to travel by train from Berlin to Stuttgart on next week Wednesday.
{
"intent": {
"name": "travel_details",
"confidence": 0.9981381893157959
},
"entities": [
{
"entity": "travel_mode",
"start": 20,
"end": 25,
"value": "train",
"extractor": "DIETClassifier"
},
{
"entity": "city",
"start": 31,
"end": 37,
"role": "depart",
"value": "Berlin",
"extractor": "DIETClassifier"
},
{
"entity": "city",
"start": 41,
"end": 49,
"role": "arrive",
"value": "Stuttgart",
"extractor": "DIETClassifier"
}
],
"intent_ranking": [
{
"name": "travel_details",
"confidence": 0.9981381893157959
},

实体组 (Entity Groups)

This feature allows for entities to be grouped together with a specific group label. The best way to explain this is with an example…

此功能允许将实体与特定的组标签一起分组。 最好的解释方法是举一个例子……

Again, defined in your /data/nlu.md file:

同样,在您的/data/nlu.md文件中定义:

## intent:teams- The first team will be [John]{"entity": "teamMember", "group": "1"}, [Mary]{"entity": "teamMember", "group": "1"} and [Geoff]{"entity": "teamMember", "group": "1"} and the second groupto travel will be [Martha]{"entity": "teamMember", "group": "2"}, [Adam]{"entity": "teamMember", "group": "2"} and [Frank]{"entity": "teamMember", "group": "2"}.

And the output from Rasa NLU:

以及Rasa NLU的输出:

The first team will be John, Mary and Geoff and the second group to travel will be Martha, Adam and Frank.
{
"intent": {
"name": "teams",
"confidence": 0.9999754428863525
},
"entities": [
{
"entity": "teamMember",
"start": 23,
"end": 33,
"group": "1",
"value": "John, Mary",

"extractor": "DIETClassifier"
},
{
"entity": "teamMember",
"start": 38,
"end": 43,
"group": "1",
"value": "Geoff",

"extractor": "DIETClassifier"
},
{
"entity": "teamMember",
"start": 83,
"end": 95,
"group": "2",
"value": "Martha, Adam",

"extractor": "DIETClassifier"
},
{
"entity": "teamMember",
"start": 100,
"end": 105,
"group": "2",
"value": "Frank",

"extractor": "DIETClassifier"
}

结论 (Conclusion)

It is evident that there are a few applications where complex user utterances and compound entities will need to be handled. This development by Rasa will most probably be extended and include other structures.

显然,在一些应用程序中,需要处理复杂的用户话语和复合实体。 Rasa的这项开发很可能会扩展并包括其他结构。

在这里阅读更多 (Read More Here)

翻译自: https://medium.com/@CobusGreyling/define-concepts-in-your-entity-data-with-rasa-cc133f865860

rasa 实体,意图

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_26728245/article/details/109123420

智能推荐

oracle rman 登录方式,oracle rman登陆及连接target数据库的步骤方法_情商和口才的博客-程序员宅基地

方法一:[[email protected]~]$ rman target sys/[email protected] catalogcatalog_admin/[email protected]: Release 10.2.0.1.0 - Production on Mon Jan 20 07:56:30 2014Copyright(c) 1982, 20...

Andoid:crystax-ndk 解压目录_胡大炮的妖孽人生的博客-程序员宅基地

博主的机器是Windows10 x64的 下载了 crystax-ndk-10.3.2-windows-x86_64版本(如图) 自动解压至以下目录(如图) C:\Users\用户名\AppData\Local\VirtualStore\Windows\SysWOW64\crystax-ndk-10.3.2

c语言程序电压采样,单片机电压采集装置课程设计(AD转换及编程实现).doc_杉果游戏的博客-程序员宅基地

word文档 可自由复制编辑单片机课程设计姓 名: 学 号:专 业:  电子科学与技术题 目: 单片机电压采集装置专 题: AD转换及编程实现指导教师:设计地点: 实验楼 时 间:2012 年 12月单片机课程设计任务书专业年级 电科 学号 学生姓名任务下达日期:2012年 12 月20 日设计日期: 2012年12月1设计题目...

php+mysql美容整形医院接单派单系统_Thinkphp内核微商拓客新零售平台源码新零售的派单工具产品营销推广神器让客户主动加你买货..._我本废柴的博客-程序员宅基地

Thinkphp内核微商拓客新零售平台源码,新零售的派单工具,产品营销推广神器,让客户主动加你买货一个新零售的派单工具,有了平台,会让客户主动加你买货,100%成交,还会积极帮你转介绍,让你不仅仅获得派单,还能建立自己的商友圈,积累强大的人脉。平台的机制中一共分为13个商友星级,从一星到十三星,每升一星就会获得大量的平台派单,升到13星一共可获得百万笔零售订单。平台没有行业限制,无论你是微商,电商...

域服务器账号权限,域中文件服务器权限设置_Jerry Jho的博客-程序员宅基地

一个父子多域环境,然后中国属于asia子域。中国有台文件服务器,需要设定NTFS权限,请问,权限设定时,不同的安全组,有什么不同的区别?譬如domain local,global ,universal, 等等。回答:根据您的描述,我对这个问题的理解是:您想知道AD中的组的区别。首先我们先看一下这些组的区别:Global: 只能添加本域的帐号,但是可以被其他域用于权限委派。Domain Local:...

极值滤波matlab,[转载]转:Matlab信号提取、频谱分析、滤波、阈值设定、寻找极值点..._BREgrenadier的博客-程序员宅基地

好的作业题目可以激起人挑战的欲望,并指引着自己学习一系列的东西。可是这样的题目并不常见,上一次见到是什么时候我已经不记得了,昨天,一道让人忍不住叫好的作业题目摆在我的面前。先看题目,是某大学大四学生的课程作业:-------题目Heart Beat Period Detection背景交代In clinic, it is frequently required to detect heart ra...

随便推点

html文本框怎么加注释,html 注释(html如何添加注释符号)_goodpartner18的博客-程序员宅基地

注释标签用于在HTML插入注释。HTML注释标签您能够经过如下语法向HTML源代码增加注释:实例注释:在开始标签中有一个惊叹号,可是结束标签中没有。浏览器不会显现注释,可是能够帮助记录您的HTML文档。您可以利用注释在HTML中放置告诉和提醒信息:实例这是一个阶段。亲身试一试注释对于HTML纠错也大有帮助,由于您可以一次注释一行HTML代码,以查找错误:实例亲身试一试条件注释您或许会在HTML中偶...

华为C8825D刷机失败解决方法_weixin_30266829的博客-程序员宅基地

说明:遇到的问题如下:刷机失败,开机出现以下结果:无法进入recovery模式,无法开机.解决方法:1.找一张内存卡,空白是最好2.下载华为官网上的C8825D组件下载链接:http://consumer.huawei.com/cn/support/downloads/index.htm3.将下载出来的zip解压出来,并将dload文件放在SD卡的根...

html5 视频 video 002_weixin_34082789的博客-程序员宅基地

为什么80%的码农都做不了架构师?>>> ...

mysql中如何删除某个字段中的某个字符_weixin_30321449的博客-程序员宅基地

假如表名为user,表如下iddevid11,2,3,12,13,14要删除表user的devid字段中的1的值,注意12,13,13是不能删除。php语法如下:$delnum = 1;$id =1;$sql = "update user set devid = trim(both ',' from replace(co...

推荐文章

热门文章

相关标签