Beauty of Programming lecture

lecture from Microsoft

Describes typical automatic answering system, comprising a knowledge base based on QA (KB-QA), text-based Q (Text-QA) based FAQ Q (Community-QA) and the like. In addition, there will be a brief description of the technology in this competition questions and answers related to the task.

Based on the school's website to build your own robot, respond to questions and information extraction, man machine interaction. It includes many features and modules.

Tasks, methods, questions and answers related to the method and be introduced based on real examples

Systems based on a given database, to answer questions raised by humans.

Types of problems: The answer is an entity, the answer is defined, the answer is yes / no, the answer is opinion, more like a problem

Early qa system is specialized in specific areas, then leap in computing power, allowing the QA system to develop the field

Three categories:

Knowledge-based Q & A system KBQA

Database system is structured, but the knowledge base is the relationship between a number of entities, relationships between entities is in the form of an abstract label

The key is two things: First, the problem can not actually detect the entity to another entity relationship problems mentioned detected

Applications: Microsoft Bing bing, direct direct structured search, Advantages: get the answer directly, saving the user information to the results page relocation

Home excavated from the school subject + verb + object (structured triples), you can answer the question: Who Tsinghua University is to identify entities do first, knowledge is knowledge base to store the entities and relationships. Entity Recognition: Tsinghua University, mentioned in the context of what is to identify the relationship about which entity: the relationship between the president, the answer to retrieve: <Tsinghua University, president, Qiu Yong>

But how do you identify entities and relationships identified based on a given problem:

Start with a basic approach, from a number of sites like Wikipedia to get the name of the entity, with the knowledge of the above-mentioned problem input to mark, to mark questions which actually referred to the relationship. Other issues: There are many different versions of the same entity names, some of the places to do some detailed expansion of

relationship recognition:

One is the relationship identification method can create problem-based templates (who is the founder of what -> founder artificial write extended question templates or search logs to extract the template is the whole problem can be completely covered.).

一类是创造基于关系关键字的方法,创办人–从其他地方抓取关键字都表示了创办人的意思。提示:如果有很多满足当前关系的实体对,可以去海量去文本中挖掘句子,这个句子的条件是同时包含了满足这个关系的某一个实体对。若两个实体出现在一个句子中,这两个实体间又在知识库中存在某关系,那这个句子的其他部分就在对知识库里的这个关系做陈述。通过类似方式来抓取一些知识库中关键多对应的不同的关键字来用于检测问的问题是提到知识库中的哪个关系

基于文档的问答系统DBQA

很多知识是无法经过人类整理编辑录入知识库的,哪怕是google的freebase也是不全面的。需要利用其他一些非结构化的知识,可以基于文档中的句子来进行搜索

应用:问题对应的搜索返回网页中包含的句子和段落很好的回答问的问题,直接就返回了结果

预选赛中的一个任务:给出了训练数据开发数据测试数据,训练数据给出了三元组,问题是同样的问题,七句话来自同一个篇章。第一列是答案标签,第六行是1:是答案,其他不是答案:是0。任务是:给你一个篇章再给一个问题,选出篇章中的一句来保证这是当前问题的答案。根据答案标签来训练问题答案句匹配模型,但是实际测试时只会给当前的篇章和问题,没有答案标签,要排序,排出最相关的一句话。

再比如校园机动车公告网页,第四句话是非常相关的,作为答案输出。对文档内容做处理。

提示:1、数数,重复的字词很多,就有问题答案关系

2、词向量。每个句子都可以转化成词向量,表示当前词的语言。然后看词向量上的距离

3、深度学习工具,做模型上的训练,使问题和正确答案相关性非常强,以实现答案抽取

像百度知道,奖励机制,点赞来提取出高质量的问题和答案对,用历史答案来回复现在的高相似度的问题。

应用:微软小冰,进入公众号后,索引整理该公众号的历史文章,用户会问文章中含有的问题(一般是多引擎协同工作),直接用历史文章中的答案对来回答

核心的目的是计算一个输入问题和历史问题的相似度,这就需要一个问题和问题的匹配模型。那么采用如何的训练数据来得到这样一个匹配模型。像百度知道这样来抽取训练数据,页面中会有一堆其他类似问题,即重新定向到历史问题。有这样的问题和相似问题的数据之后就可以训练一个模型,给一个分数来表明两个问题的相似度。

计算相似度是一个语义理解的问题,这是nlp中的最核心问题。概念:有一些方式根据相似数据做模型,如一个词缀对齐。


第二类是同义词和近似词表,另外海量的翻译数据,对翻译数据进行对其之后,一个现象:如果源语言端的两个词或者短语对应的反义词是相同的,则这两个源语言是近似的。同义词的信息抽取

第三类是有了相似问题的海量数据之后,可以用深度学习或者是神经网络模型来做一个模型。概要性解释:把每一个问题转化成一个n维或者是1000维向量,每一个维度都是实值,人觉得是一千个数字,但是机器觉得1000维数字来对问题来编码来保证语意相同的两个句子在向量空间距离上是非常近的。给工具包,看说明

一些工具包
中文分词
词向量
句子向量
语言理解

最后的是去年的评测比赛提供的两个的基准的问答系统的实例。虽然系统非常简单,但可以以此为基础进行扩展

如何建立面向任务的自然语言理解模型

人工智能助理(AI Bot)的一个重要部分是自然语言理解模型。本课程将介绍面向任务的自然语言理解模型,以及如何利用微软认知服务的自然语言理解智能服务(LUIS)快速开发应用合适的模型

什么是面向任务的自然语言理解模型

三大特点:通过自然语言交互、完成特定的任务、具备一定知识和推理的能力

举例:

通过自然语言交互:首先制定会议对应一个功能,team包含一组人,时间地点。慢慢拆解每个句子部分

转入到meeting的功能:四个会议的要素

myteam:office graph

相对时间: 根据测算

地点:

对于面向任务的自然语言bot,他们的模型是两大步

第一步:叫做intent,就是理解用户需要我们做什么。倒过来想,能帮用户做什么。

第二步叫entity,在那句话中给了我们哪些参数。或者说需要哪些参数

两部分解决方法

基于规则:像正则表达式,去纂写规则。当手头上并没有用户数据(冷启动)。成长困难,用户负责性变多,管理这些规则是很难的,尤其是协作、管理数据、标定数据。

基于数据:应用机器学习算法,用数据来学习对应的模型,更可持续

机器学习算法用于自然理解模型中可用于两部分

大专栏  编程之美lectureg" alt=""/>

intent:文本分类问题。线性模型、逻辑回归、cnn、lstm

entity:从一句话中找到相应段落。然后给它一个语义标签。可以变成一个序列标注问题。条件随机场,dl中crf的算法

但是我们今天讲的是基于数据的解决方案

LUIS

介绍下:这是个平台化的机器学习解决方案,简答易上手

通过内建减少feature上花费的时间,高阶语言的表示。两个常用特征:entity的列表和正则表达式

基本工具:解析时间、标注器、很多领域的工具

suggestion:通过主动学习

demo

先登录,跳转到my apps,点new apps。dashboard,放了常见信息。

点开intent,增加新的:查考分

输入一些utterance:如计算机系的录取分数线是多少,然后save。所以同时想到要在entity那里加一个“院系”。然后回到utterance,把计算机系这几个字框住,然后标注为院系,save。就形成了一句标注的语句。

previous entity中有些时间年龄之类的內建。通过这种方式不停的去加训练数据。

再来看list feature,提供列表。给一个值之后有更多类似值推荐。

点train application就开始训练。然后就可以测试了。

下一步就是发布,endpoint key选luistest,然后点publish,拿到一个url。通过get拿到结果

add flag勾上,timezone可以解决相对时间passing的问题,在postman中测试

再看看一个正常的bot(可以直接import dataset)

batch testing里面增加数据集

dashbroad里面的suggested utterance:
通过发布的链接进来的所有的句子都会通过一个模块,推荐到这。选择一个模型,如capacity,然后相对应的句子加入到utterance单元中去

通常这样做会得到一个更好的模型

经验总结

1、兵无常势
针对具体的任务选择规则还是数据
或者是两者的结合

2、循序渐进

3、三思而行

框架中具体的细节决定成败:模型方面、数据方面、如何交互、如何提示,简单易用和足够聪明

1.介绍微软Bot Framework 的配置以及如何用Bot Framework SDK开发对话聊天机器人。2.介绍如何使用Bot Framework中的QnA Maker开发问答聊天机器人。3.介绍如何使用Bot Framework讲自己开发的聊天机器人发布到多个聊天工具中。4.用实际案例帮助大家熟悉Bot Framework的使用以及在开发过程中需要注意的问题。

Bot Framework开发框架,帮助开发者快速有效开发

三大重要部分

一、bot connector

帮助开发者将聊天机器人发布到交流平台上,所以开发者只需要开发一个后端服务,节省通讯端的开发成本

二、bot builder sdks

开源sdk,快速生成开发模板,提供开发工具。这次参赛选手主要是和bot builder打交道

三、bot dicrectory

像一个bot的商店,可以看到并用其他人开发的bot

今天主要是以实际操作为主
开发环境贮备和基本步骤
实际操作来快速上手

准备

今天用C#。其他语言可以看官方文档
升级到最新版本

下载bot application template模板,然后拷到对应目录

引入bot bulider的sdk
直接从github上下载bot builder源码

最后,需要安装bot的模拟器

实际操作例子

官网

注意看文档(包括如何连接人工智能的工具louis、关于图像和语音的api)

下载
,解压之后放到vs的temple文件夹里面

新建一个工程

new bop 包的使用

然后在browse搜寻bot builder,然后installupdate,

messagecontroller是我们主要要面对的,用于收发用户的消息

dialogs就是对话的主要组成,今天主要来看在收发消息的时候怎么和用户进行交流,进入rootdialog

有个函数交messagerecieveasunc,收到消息返回的方法,

得到是result转化成activity,是一个类,回复是文字

看一下demo,问题和答案

用模拟器来调试

编译运行
![](http://i4.buimg.com/588926/f4cfe0c8c5ed57c9.png
会发布一个http本地服务,在模拟器中后缀http://localhost:3979/api/messages

另外一个多轮对话的demo

对于Louis

新建一个app,新建两个entity,一个是教学楼一个是系别







需要丰富

train之后publish


返回json的结果,识别问句的意图,得到关键属性,然后bot框架 则帮我们包装,让我们更快的使用louis的结果

Fill in luismodel in luis id and key, saving development time, to define two constants entity that is not inside the line and classroom building

methods specific query to see the location, trying to get the value of the building, watching json structure there is no entity and then returns a location where

The previous example explains how to bot framework and luis link to make luis intended to identify and deal with the problem of extracted entities nlp, then bot framework to execute the appropriate logic, and user and communicate, and finally look at a more complex examples: form. For the filling, it provides a framework for

First define an enumeration type: male or female

definition of some templates, defines four key attributes


numeric user input verification

pattern to quickly write a regular expression

Callback function, and then look formbuilder

Some keyword
message, field, confirm, oncompletion, build

Guess you like

Origin www.cnblogs.com/liuzhongrong/p/11874288.html