AI界的产品经理AI自然语言处理(...

dialogflow.com “试玩报告”

2018-01-07  本文已影响152人  yobanana

现在无论是在线购买商品或咨询问题,对话机器人或者说智能客服已经成为了不可或缺的部分,仅论量的话“人机”交互早已超过了“人人”交互。而对话式交互更加接近现实,提升查询交互体验的同时为营销等场景提供了更加精确的服务入口。虽然国内巨头都有相应产品,但你会发现他们的网站重在阐述我家产品很牛,如果想了解一些基本概念有所收获的话,推荐谷大爷的dailogflow。这个网站竟然需要科学上网 - - ||
下文主要根据网站的文档了解概念并依据示例实践一些基本功能,如果你感兴趣,又不方便翻墙,花几分钟看下本文就能有个简单的了解,如果有“条件”,看完之后建议自己玩一下更加深刻。
下面简介内容来自官方英文文档,英文好的话可以忽略我的中文翻译,中文括号为补充说明。

简介

The process a Dialogflow agent follows from invocation to fulfillment is similar to someone answering a question, with some liberties taken of course. In the example scenario below, the same question is being asked, but we compare the "human to human" interaction with a conversation with an Dialogflow agent.
Dialogflow agent(对话代理)调用流程和同某人自由问答类似。如同下面给出的例子,基于一个同样的问题,比较真实情况下人们之间的对话与对话代理之间的区别。

Welcome 欢迎/开场白

Bill's friend Harry wants to ask him a question. So as not to be rude, Harry says "Hello" to Bill first.
张三的朋友李四想问他一个问题,为了不失礼貌最好先打个招呼,“你好”。(所以同样的,对话代理也需要设定一个开场白来回复用户,例如用户说你好的时候回复“有什么可以帮到您?”)

Invocation 调用

In order to start a conversation with an agent, the user needs to invoke the agent. A user does this by asking to speak with the agent in a manner specified by the agent's developer.
为了进行人机对话,用户需要先启动一个对应代理。用户通过代理开发人员提供的特定流程进行对话。(用户在开发人员提供的应用场景内触发机器对话)

Request 提问

Harry asks Bill "What's the weather supposed to be like in San Francisco tomorrow?" Because Bill is familiar with the city and the concept of weather, he knows what Harry is asking for.
李四问张三:“明天旧金山天气怎么样”,因为张三更加熟悉这座城市和天气方面的知识,他知道怎么回答李四。

Intent 意图

A user asks the agent "What's the weather supposed to be like in San Francisco tomorrow?" In Dialogflow, an intent houses elements and logic to parse information from the user and answer their requests.
在Dialogflow中,当用户问旧金山明天天气怎么样时,一个意图相关元素和逻辑会识别用户提问和回答对应问题。(Dialogflow 理解问题的方式是从对话信息中获得用户的意图)

User says 用户可能会这么问

For the agent to understand the question, it needs examples of how the same question can be asked in different ways. Developers add these permutations to the User Says section of the intent. The more variations added to the intent, the better the agent will comprehend the user.
为了让对话代理理解用户提出的问题,需要先给出同样问题用户可能会提问的方式。开发人员添加用户说话方式组合到对应的意图中。添加的例子越多,对话代理就越能理解用户。(Dialogflow需要预设一些谈话例子,在此基础上通过技术手段把问题“扩展”,当用户提问不完全与例子相同也能判断出其实是一个问题)

Entities 实体

The Dialogflow agent needs to know what information is useful for answering the user's request. These pieces of data are called entities. Entities like time, date, and numbers are covered by system entities. Other entities, like weather conditions or seasonal clothing, need to be defined by the developer so they can be recognized as an important part of the question.
对话代理需要知道用户提问中的关键信息,这些数据被定义为实体:例如时间,日期以及很多系统自带实体;还包括例如天气条件,季节性穿着,还有需要由开发人员自定义的实体信息以便系统能识别为关键信息。(如果觉得实体这俩个字比较抽象,可以近似的理解为关键词,或者同义词)

Fulfillment 实现(场景)

Armed with the information Bill needs, he searches for the answer using his favorite weather provider. He enters the location and time to get the results he needs.
李四使用他最喜欢的能提供他所需信息的天气应用,通过输入地点和时间获得他所需的结果。

Fulfillment Request 实现请求

Dialogflow sends this information to your webhook, which subsequently fetches the data needed (per your development). Your webhook parses that data, determines how it would like to respond, and sends it back to Dialogflow
Dialogflow向你开发的web服务接口发送信息,获得所需信息,该接口用来解析请求并将答复返回给Dialogflow(Dialogflow 分析出意图,然后根据开发人员针对该意图预设的操作调用相应的接口,最后向用户展示答复)

Response “人类对话答复”

After scanning the page for the relevant info, Bill tells Harry "It looks like it's going to be 65 and overcast tomorrow."
张三在查询过相关网站后,回答李四:“明天温度为18度左右,阴天”

Response “Dialogflow对话答复”

With the formatted reply "in hand", Dialogflow delivers the response to your user. "It looks like it's going to be 65 and overcast tomorrow."
通过格式化现有回复数据(例如通过上面提到的web服务接口获得数据),Dialogflow推送答复给用户:“明天温度为18度左右,阴天”。

Context “人类对话上下文”

Now that the conversation is on the topic of weather, Bill won't be thrown off if Harry asks "How about the day after that?" Because Harry had asked about San Francisco, follow up questions will more than likely be about the same city, unless Harry specifies a new one.
现在谈话的主题是天气,当张三继续提问“那后天呢?” ,李四会认为他还想知道当前讨论城市旧金山后天的天气,除非张三在提问中特指了新的。

Context “Dialogflow对话上下文”

Similar to Bill's scenario, context can be used to keep parameter values, from one intent to another. Contexts are also used to repair a conversation that has been broken by a user or system error, as well as branch conversations to different intents, depending on the user's response.
同人类间对话类似,Dialogflow对话保存上下文参数,即使从当前意图转化为另一个意图。上下文也经常用来修复对话中断和系统异常,或者根据用户的回复切换到不同的意图场景,。
(中断场景例如今天问了旧金山天气,即使过几天再来问“天气咋样?”,也能根据之前的对话上下文判断是在问旧金山的天气)

光说不练假把式

参考文档创建一个天气对话代理。
新建agent 输入名字 weatherAgent ,选择语言为英语 。然后点创建


image.png

然后你会进入该代理的控制台:


image.png

点击创建意图
在User says 输入框内输入 "Weather forecast in San Francisco tomorrow "
此处注意一个特殊操作,当你选择语句的一段时会弹框出参数配置,可以根据过滤器(fliter)输入框检索出你需要的那个参数

image.png
下面是配置好的样子
image.png
添加意图对应的回复,在Response中添加语句:“I don't kown the weather for $date and $geo-city”,注意输入$时会如下面所示弹出下拉框给你选择。
image.png
点击右上角的保存按钮后来试试生效了没,在最右上角的“try it now”中输入刚才你保存的用户问句。
image.png
可以看到生效了,不仅回答了我问题,还把参数部分替换为我的问句内容,当前提问时间是1月7日,但问的问题是明天,所以date部分为1月8日。
让我们来考考它,换一个说法:“How about the weather in San Francisco tomorrow”
image.png
可以看到上图所示,还是分析出来了,66666
可以尝试问下周的天气:Weather forecast in San Francisco one week later ,类似问题也同样能解析出对应的时期:
image.png
接下来创建一个实体,配置一个和天气--Weather同义的词
image.png
如上图,先输入weather 然后在当前行继续输入“tianqi” ,可以追加输入数个随意单词作为同义词。点击保存,试一下:
image.png
生效了~
最后再提一下Integrations-集成功能,在集成配置中开启Web Demo开关:
image.png
浏览器打开提示链接https://bot.dialogflow.com/X(X二级地址可以自定义)
image.png
怎么样,很方便吧?

总结

Dialogflow通过极简的方式提供了很多强大的功能,例如官方文档详细说明的如何通过自定义接口接受意图并返回答复,以及各类客户端集成办法,还有不断新增的识别训练等功能。
比较遗憾的是虽然提供了看似挺丰富的中文语言选项(简体,繁体,粤语/HK),但支持的不是很好,没有实现英文的用户问答那样配置一个例子,能扩展识别多种问法,所以示例用了英文,相信未来会逐步支持。
本文中仅仅叙述了平台几个功能,用它能实现的交互场景太多太多。欢迎大家提供看法一起讨论,以及提出本文错漏的部分。感谢你的阅读。

上一篇下一篇

猜你喜欢

热点阅读