论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

Commonsense Knowledge Aware Conversation Generation with Graph Attention

1 出发点

       现有的具有外部知识的模型,大多采用非结构化、开放域知识或者结构化、小规模、特定域的知识,这就导致模型存在依赖高质量的非结构化知识的问题或者在开放域的对话场景下表现不佳的问题。而且,大多数模型通常孤立地利用知识三元组(实体),而不是在知识图中将知识三元组作为一个整体来对待。

2 贡献

       提出了两种图注意力机制:(1)、静态图注意力机制,编码被检索出来的知识图用来增强输入句子的语义信息,这样可以更好的理解输入。(2)、动态图注意力机制,读取知识图和其中的知识三元组,然后利用其中的信息生成更好的回答。

3 任务定义

       给定对话历史X=x1...xnX=x_{1}...x{n}和知识图的集合G={g1...gNG}G=\{g_{1}...g_{N_{G}}\}的条件下,生成一个目标回答Y=y1...ymY=y_{1}...y_{m}。每个知识图由一系列的三元组组成gi={τ1...τNgi}g_{i}=\{\tau_{1}...\tau_{N_{gi}}\},每个知识三元组τ=(h,r,t)\tau=(h,r,t),分别代表:头实体、关系和尾实体。note:GG并不是整个知识库中的所有图的集合,只是其中的一部分,这一部分是以XX中的单词为索引检索得到的。
       作者在模型中使用TransE[1]来表示实体和关系。并且使用MLP使得模型可以使用实体和关系的TransE表示,如公式1所示,k\pmb{k}为一个知识三元组的表示:
k=(h,r,t)=MLP(TransE(h,r,t))\pmb{k}=(\pmb{h},\pmb{r},\pmb{t})=MLP(TransE(h,r,t))

公式1
(note:公式中粗体字代表向量)

4 模型

模型整体结构如图1所示,下面分模块依次介绍模型结构。
论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

图1

4.1 Knowledge Interpreter

       Knowledge Interpreter通过合并单词向量和对应的图向量增强每个单词的语义信息,使得模型更好的理解输入XX,如图2:
论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

图2

       图2中,单词‘ray’对应于第一个图,其中橙色圆圈代表‘ray’实体,淡蓝色圆圈代表与其有关系的实体,箭头代表关系;单词‘sunlight’对应于第二个图;单词‘of’因为没有对应的实体所以使用一个特殊的图来代表。然后通过静态图注意力机制计算被检索出来的图的向量表示gig_{i},并且与单词向量w(xt)w(x_{t})(tt代表单词的位置)拼接作为单词最终的向量e(xt)=[w(xt);gi])e(x_{t})=[w(x_{t});g_{i}])。下面介绍静态图注意力机制,思想主要来源于[2]
       静态图注意力机制将对应图的所有三元组K(gi)={k1...kNgi}K(g_{i})=\{k_{1}...k_{N_{gi}}\}作为输入,然后利用注意力机制确定每个三元组的重要性,最后利用加权和得到图向量gig_{i},如公式2、3和4:
论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式2

论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式3

论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式4

       其中kn=(hn,rn,tn)\pmb{k_{n}}=(\pmb{h_{n}},\pmb{r_{n}},\pmb{t_{n}}),为每个三元组的向量表达。原文中说明:注意力机制计算的是关系rnr_{n}和实体hntnh_{n}、t_{n}之间的联系。但是我并没有读懂为什么要这样做,文中也没有具体直观的解释,如果有知道的可以留言,相互学习下。

4.2 Knowledge Aware Generator

       knowledge aware generator通过充分使用被检索出来的知识图中的信息去更好的生成回答,它共有两个作用:(1)、通过每个被检索出来的gig_{i}生成一个具有图感知的上下文向量用于更新decoder的隐藏状态。(2)、从被检索的图中或者单词表中选择合适的单词生成,如图3:
论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

图3

       公式5和6是decoder的隐藏状态的更新操作:
论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式5

论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式6

       这里需要注意下公式6,它与Knowledge Interpreter中的e(xt)=[w(xt);gi])e(x_{t})=[w(x_{t});g_{i}])不同,公式5中的ctc_{t}是对encoder输出的H=h1...hnH=h_{1}...h_{n}的加权和,与常规的具有注意力机制的encoder-decoder结构的做法相一致。ctgc^{g}_{t}是对图向量{g1...gNg}\{g_{1}...g_{N_{g}}\}的加权和,ctgc^{g}_{t}是对所有三元组向量{K(g1...K(gNG))}\{K(g_{1}...K(g_{N_{G}}))\}的加权和。
       动态图注意力机制是一个具有层结构的从上到下的过程。它先利用注意力机制为图向量gig_{i}做加权和得到ctgc^{g}_{t},如公式7、8和9:
论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式7

论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式8

论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式9

       其中的注意力机制计算的是decoder的隐藏状态sts_{t}和每个图向量gig_{i}的关系。
       然后利用注意力机制对每个图向量gig_{i}中的所有kik_{i}做加权和得到ctkc^{k}_{t},如公式10、11和12:
论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式10

论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式11

论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式12

       其中注意力机制计算的是decoder的隐藏状态sts_{t}和每个三元组向量kik_{i}的关系。
       最后通过如下规则生成一个单词,如公式13、14、15、16和17:
论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式13

论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式14

论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式15

论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式16

论文笔记:基于外部知识的会话模型Commonsense Knowledge Aware Conversation Generation with Graph Attention

公式17

       其中γt\gamma_{t}是一个标量,用于衡量PcP_{c}PeP_{e}对单词生成的贡献,公式17是将这两个分布拼接,其中每个值我都为下一个要生成的单词概率。note:每个kik_{i}有三部分构成,kik_{i}所对应的那个实体单词是其中的尾实体,这点可以通过图2可以看出,每次生成的为紫色圆点。

5 相关阅读

[1] Translating embeddings for modeling multirelational data
[2] Graph attention networks