论文笔记 - A Neural Attention Model for Abstractive Sentence Summarization

接之前的NLP 笔记 - Text Summarization,介绍一种 abstractive summarization 方法 textsum。

Background

Summarization Phenomena

先来观察下文本摘要的一些现象,一般是通过对源文本进行泛化(generalization)、删除(deletion)、改写(paraphrase)等操作来产生目标文本,也就是文本摘要。看一下例子

  • Generalization
    Source: Russian Defense Minister Ivanov called Sunday for the creation of a joint front for combating global terrorism.
    Target: Russia calls for joint front against terrorism.
  • Deletion
    Source: Russian Defense Minister Ivanov called Sunday for the creation of a joint front for combating global terrorism.
    Target: Russia calls for joint front against terrorism.
  • Paraphrase
    Source: Russian Defense Minister Ivanov called Sunday for the creation of a joint front for combating global terrorism.
    Target: Russia calls for joint front against terrorism.

Types of Sentence Summary

对于上面等一些操作,产生了文本摘要的几类技术模型。

  • Compressive: deletion-only:
    压缩,通过对源文本的删除操作产生目标文本。
  • Extractive: deletion and reordering:
    抽取式,摘要句子完全从源文档中抽取形成,详细见 NLP 笔记 - Text Summarization
  • Abstractive: arbitary transformation
    合成式,从源文档中抽取句子并进行改写形成摘要。

看下几种方法的比较
elements.png

目前已经有的一些相关工作

  • Syntax-Based
    Dorr, Zajic, and Schwartz 2003; Cohn and Lapata 2008; Woodsend, Fend, and Lapata 2010
  • Topic-Based
    Zajic, Dorr, and Schwartz 2004
  • Machine Translation-based
    Banko, Mittal, and Witbrock 2000
  • Semantics-Based
    Liu et al 2015

Textsum

Textsum,论文戳 A Neural Attention Model for Abstractive Sentence Summarization,tensorflow 代码戳 tensorflow/models/textsum。Textsum是一种 abstractive model,主要有下面四个组件构成:

  • Neural language model
  • Attention-based encoder model
  • Generation model
  • Beam-search decoder & additional features model extractive elements

下面逐个进行讨论。

Neural language model

借鉴了机器翻译的思想,在 A Neural Probabilistic Language Model (Bengio et al. 2013)的基础上,加了一个 attention-based encoder(Bahdanau et al. 2014) 来学习输入文本的 latent soft alignment。

先看一下整体逻辑,看图说话,下面左图圈出来的部分是一个feed-forward neural network language model(NNLM),详情戳NLP 笔记 - Machine Translation(Neuron models),它的输入是当前 output 已经产生的上下文 $y_c$(注意这个 context 窗口的长度是固定的),与词向量矩阵 E 做个映射,经过线性变化以及激活函数得到得分矩阵 U,再经过一个 softmax 层得到概率分布形式的输出,也就是下一个单词 $y_{i+1}$,现在我们要加上左边的 attention-based encoder,对输入 source text 和当前我们拥有的 context $y_c$ 做一个 encode,放大的话就是右图。对 context embedding 和 source 的每个单词做一个加权的点乘(weighted dot product)得到 attention distribution 也就是 P,对 source text 做一个局部的平滑(local smoothing),然后对 source 的 smoothing 版本和 attention distribution 做一个点乘,就得到了我们要的 enc,最后把两边的东西一起扔到 softmax 里得到输出。

abs_graph.png

看个例子,如下图,行是 source text,列是 output text,假定我们已经产生了 “russia calls”,现在目标是产生下一个单词 for,我们的模型将利用 attention distribution of source 以及 embedding of context,来得到 for 这个 next word。因为我们用了 bag of words 的 smoothing 版本,也就是说我们对 called 周围的单词进行了加权,attention 很大程度上会指向 called,具体逻辑见下一部分 encoders。
abs_ex1.png

上面说到了,这里选择的 encoder 是 attention-based encoder,下面来看一下为什么选这个 encoder。

Encoders

Bag-of-words Encoder

BoW encoder 把 encoder 参数估计看作是一个 uniform distribution,赋予了每个词相同的权重,同时忽略了单词词序。

bow_encoder.png

Convolutional Encoder

Convolutional Encoder 通过局部卷积来考虑邻近单词的互动,单词/词组权重由网络训练产生。
conv%20model2.png
conv%20model.png

Attention-Based Encoder

灵感来自 Bahdanau et al. (2014) attention-based contextual encoder。和 BoW 相似的一个简单的模型,只不过把 BoW 的 uniform distribution 替换成一个 input 和 summary 之间的 soft alignment P (如下图),是一个机器翻译的思路。之后用学习到的这个 soft alignment 来给输入的平滑版本进行加权。比如说,如果当前的上下文和位置 i 能很好的对齐,那么单词 $x_{i-Q},…,x_{i+Q}$ 就会被 encoder 赋予更高的权重。与 NNLM 结合的话这个模型可以看作是 attention-based neural machine translation model 的精简版。

$G \in R_{D*V}$: embdding of the context
$P \in R_{H*(CD)}$: new weight matrix parameter mapping between the context embedding and input embedding
$Q$: smoothing window

abs_ex1.png attention_decoder.png

Generating Summaries

用 beam-search decoder 来寻找最好的 summary,这是机器翻译模型的标准化方法(Bahdanau et al., 2014; Sutskever et al., 2014; Luong et al., 2015) ,这里做了一点改进。

beam%20search.png

算法如上,我们需要维护一个词库 V 以及前 k 个最好的 context,复杂度是 O(KNV)。

Tuning

最后论文提到了一个 tuning,这其实是在 word embedding 维度太低,语义表示不完全时,去人工添加一些特征,这可以 handle 一些 rare/unseen words 的问题,让系统的 extractive/abstractive 趋势更为平衡。
通过修改评分函数来直接估计 summary 概率,使用对数线性模型。
tuning.png

徐阿衡 wechat
欢迎关注:徐阿衡的微信公众号
客官,打个赏呗~