DCA:多Agent进行分段Encode的文本摘要

Deep Communicating Agents for Abstractive Summarization

Celikyilmaz, A. , Bosselut, A. , He, X. , & Choi, Y. . (2018). Deep communicating agents for abstractive summarization.

论文PDF地址:http://in.arxiv.org/pdf/1803.10357v3

代码地址(未写完):https://github.com/theDoctor2013/DCA-AbstractiveSummarization

1 概述

传统的seq2seq方法,应对长文本摘要还是有些乏力,这篇论文中的方法,将文档 X X X分为了 n n n个部分,每个部分都由一个Agent处理,同时每个Agent之间还会互相传递信息,然后通过每个Agent内部的Attention与Agents之间的Attention得到结果输入到一个Decoder中,最终得到输出单词在词典上的概率分布。整体模型如下图所述:

Model 图片

2 模型

2.1 Agent

前面说了,每个Agent单独处理文章的一部分。论文中的描述是尽可能保持原文段落和句子完整性地把原文平均分成 n n n分(n是Agent数量,论文中 n = 3 n=3 n=3)。每个Agent由三部分组成:

2.1.1 Local Encoder

Local Encoder如同字面意思,直接用双向LSTM对输入数据进行计算,不考虑其他Agent的信息,所以是Local, 下面 h h h是LSTM的hidden state, e e e是词向量
h → i ( 1 ) , h ← i ( 1 ) = bLSTM ⁡ ( e i , h ⃗ i − 1 ( 1 ) , h ← i + 1 ( 1 ) ) \stackrel{\rightarrow}{h}_{i}^{(1)}, \stackrel{\leftarrow}{h}_{i}^{(1)}=\operatorname{bLSTM}\left(e_{i}, \vec{h}_{i-1}^{(1)}, \stackrel{\leftarrow}{h}_{i+1}^{(1)}\right) hi(1),hi(1)=bLSTM(ei,h i1(1),hi+1(1))

h i ( 1 ) = W 1 [ h ⃗ i ( 1 ) , h ← i ( 1 ) ] h_{i}^{(1)}=W_{1}\left[\vec{h}_{i}^{(1)}, \stackrel{\leftarrow}{h}_{i}^{(1)}\right] hi(1)=W1[h i(1),hi(1)]

2.1.2 Contextual Encoder

这个Contextual(上下文相关的)就是在计算过程中,接受了其他Agents的数据,Contextual Encoder同样也是双向LSTM,只是输入的数据变化了。这个Encoder可以有多层层叠,对于第 k k k层(k>=2,因为第一层是Local Encoder):
h ⃗ i ( k + 1 ) , h ← i ( k + 1 ) = bLSTM ⁡ ( f ( h i ( k ) , z ( k ) ) , h ⃗ i − 1 ( k + 1 ) , h ← i + 1 ( k + 1 ) ) . \vec{h}_{i}^{(k+1)}, \stackrel{\leftarrow}{h}_{i}^{(k+1)}=\operatorname{bLSTM}\left(f\left(h_{i}^{(k)}, z^{(k)}\right), \vec{h}_{i-1}^{(k+1)}, \stackrel{\leftarrow}{h}_{i+1}^{(k+1)}\right). h i(k+1),hi(k+1)=bLSTM(f(hi(k),z(k)),h i1(k+1),hi+1(k+1)).

h i ( k + 1 ) = W 2 [ h ⃗ i ( k + 1 ) , h ← i ( k + 1 ) ] h_{i}^{(k+1)}=W_{2}\left[\vec{h}_{i}^{(k+1)}, \stackrel{\leftarrow}{h}_{i}^{(k+1)}\right] hi(k+1)=W2[h i(k+1),hi(k+1)]

其中 z z z是来自于其他Agents的信息, h m , I ( k ) h_{m,I}^{(k)} hm,I(k)为第m个Agent,第k层的最后一个hidden state:
z ( k ) = 1 M − 1 ∑ m ≠ a h m , I ( k ) z^{(k)}=\frac{1}{M-1} \sum_{m \neq a} h_{m, I}^{(k)} z(k)=M11m̸=ahm,I(k)
公式(3)中的 f f f为可训练的函数,用来整合上下文信息:
f ( h i ( k ) , z ( k ) ) = v 1 T tanh ⁡ ( W 3 h i ( k ) + W 4 z ( k ) ) f\left(h_{i}^{(k)}, z^{(k)}\right)=v_{1}^{\mathrm{T}} \tanh \left(W_{3} h_{i}^{(k)}+W_{4} z^{(k)}\right) f(hi(k),z(k))=v1Ttanh(W3hi(k)+W4z(k))
其中的可训练参数 v 1 , W 3 , W 4 v_1, W_3, W_4 v1,W3,W4在所有Agents中共享。

通过这种方式,让各个Agent共享了全局的信息。

2.2 Decoder

2.2.1 Word Attention

Decoder使用单层LSTM,初始state为第一个Agent的最后一个state,每一步 t t t,都会预测摘要文本中的一个词,并计算计算Attention来获得新的state:
l a t = softmax ⁡ ( v 2 T tanh ⁡ ( W 5 h a ( K ) + W 6 s t + b 1 ) ) l_{a}^{t}=\operatorname{softmax}\left(v_{2}^{\mathrm{T}} \tanh \left(W_{5} h_{a}^{(K)}+W_{6} s_{t}+b_{1}\right)\right) lat=softmax(v2Ttanh(W5ha(K)+W6st+b1))
其中 l a t l_a^t lat就是第t步,第a个Agent中所有词的Attention。进而可以计算Agent的context vector, K是Encoder最后一层:
c a t = ∑ i l a , i t h a , i ( K ) c_{a}^{t}=\sum_{i} l_{a, i}^{t} h_{a, i}^{(K)} cat=ila,itha,i(K)

2.2.2 Agents Attention

得到每个Agents的内容向量之后,可以做Agents之间的Attention来计算每一段的重要性:
g t = softmax ⁡ ( v 3 T tanh ⁡ ( W 7 c t + W 8 s t + b 2 ) ) g^{t}=\operatorname{softmax}\left(v_{3}^{\mathrm{T}} \tanh \left(W_{7} c^{t}+W_{8} s_{t}+b_{2}\right)\right) gt=softmax(v3Ttanh(W7ct+W8st+b2))

c t ∗ = ∑ a g a t c a t c_{t}^{*}=\sum_{a} g_{a}^{t} c_{a}^{t} ct=agatcat

这个 c t ∗ c_{t}^{*} ct就是第t步的全文context vector。之后利用这个c与前面提到的s,传入多层感知机并softmax可以得到当前步输出词的分布:
P v o c ( w t ∣ s t , w t − 1 ) = softmax ⁡ ( MLP ⁡ ( [ s t , c t ∗ ] ) ) P^{v o c}\left(w_{t} | s_{t}, w_{t-1}\right)=\operatorname{softmax}\left(\operatorname{MLP}\left(\left[s_{t}, c_{t}^{*}\right]\right)\right) Pvoc(wtst,wt1)=softmax(MLP([st,ct]))
这里,作者又提出一个观点,就是为了保障生成句子信息的完整性,要避免不同Agents的来回切换,所以将前一步的c也作为这一层的数据进行计算,也就是将公式(11)改为下面:
P v o c ( w t ∣ s t , w t − 1 ) = softmax ⁡ ( MLP ⁡ ( [ s t , c t ∗ , c t − 1 ∗ ] ) ) P^{v o c}\left(w_{t} | s_{t}, w_{t-1}\right)=\operatorname{softmax}\left(\operatorname{MLP}\left(\left[s_{t}, c_{t}^{*}, c_{t-1}^{*}\right]\right)\right) Pvoc(wtst,wt1)=softmax(MLP([st,ct,ct1]))

2.2.3 Pointer Generator

为了能够直接从原文中摘取词汇,添加了Pointer Generator,首先计算从词典中生成或是从原文copy的概率,其中y是人工摘要:
p a t = σ ( v 5 T c a t + v 6 T s t + v 7 T y t + b ) p_{a}^{t}=\sigma\left(v_{5}^{\mathrm{T}} c_{a}^{t}+v_{6}^{\mathrm{T}} s_{t}+v_{7}^{\mathrm{T}} y_{t}+b\right) pat=σ(v5Tcat+v6Tst+v7Tyt+b)
在通过这个概率计算每个Agent对应输出的词的分布:
P a ( w t ∣ ⋅ ) = p a t P v o c ( w t ∣ ⋅ ) + ( 1 − p a t ) u a , w t P^{a}\left(w_{t} | \cdot\right)=p_{a}^{t} P^{v o c}\left(w_{t} | \cdot\right)+\left(1-p_{a}^{t}\right) u_{a, w}^{t} Pa(wt)=patPvoc(wt)+(1pat)ua,wt
最后,根据前面计算的Agents Attention计算最终的输出分布:
P ( w t ∣ s t , w t − 1 ) = ∑ a g a t P a ( w t ∣ ⋅ ) P\left(w_{t} | s_{t}, w_{t-1}\right)=\sum_{a} g_{a}^{t} P^{a}\left(w_{t} | \cdot\right) P(wtst,wt1)=agatPa(wt)

2.3 Mixed Losses

为了得到更好地语言模型,论文中使用了MLE和Semantic Cohesion,又为了得到更好地连续性使用了强化学习,并将他们联合在一起进行优化:
L M L E = − ∑ t = 1 N log ⁡ p ( y t ∗ ∣ y 1 ∗ … y t − 1 ∗ , d ) L_{\mathrm{MLE}}=-\sum_{t=1}^{N} \log p\left(y_{t}^{*} | y_{1}^{*} \ldots y_{t-1}^{*}, d\right) LMLE=t=1Nlogp(yty1yt1,d)

L S E M = ∑ q = 2 Q cos ⁡ ( s q ′ , s q − 1 ′ ) L_{\mathrm{SEM}}=\sum_{q=2}^{Q} \cos \left(s_{q}^{\prime}, s_{q-1}^{\prime}\right) LSEM=q=2Qcos(sq,sq1)

L R L = ( r ( y ~ ) − r ( y ^ ) ) ∑ t = 1 N log ⁡ p ( y ^ t ∣ y ^ 1 … y ^ t − 1 , d ) L_{\mathrm{RL}}=(r(\tilde{y})-r(\hat{y})) \sum_{t=1}^{N} \log p\left(\hat{y}_{t} | \hat{y}_{1} \ldots \hat{y}_{t-1}, d\right) LRL=(r(y~)r(y^))t=1Nlogp(y^ty^1y^t1,d)

将他们三个通过参数 λ , γ \lambda, \gamma λ,γ 联合起来
L M L E − S E M = L M L E + λ L S E M L_{\mathrm{MLE}-\mathrm{SEM}}=L_{\mathrm{MLE}}+\lambda L_{\mathrm{SEM}} LMLESEM=LMLE+λLSEM

L M I X E D = γ L R L + ( 1 − γ ) L M L E L_{\mathrm{MIXED}}=\gamma L_{\mathrm{RL}}+(1-\gamma) L_{\mathrm{MLE}} LMIXED=γLRL+(1γ)LMLE

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值