Attention in NLP
Advantage:
- integrate information over time
- handle variable-length sequences
- could be parallelized
Seq2seq
Encoder–Decoder framework:
Encoder:
h t = f ( x t , h t − 1 ) h_t = f(x_t, h_{t-1}) ht=f(xt,ht−1)
c = q ( h 1 , . . . , h T x ) c = q({h_1,...,h_{T_x}}) c=q(h1,...,hTx)
Sutskeveretal.(2014) used an LSTM as f and q ( h 1 , ⋅ ⋅ ⋅ , h T ) = h T q ({h_1,··· ,h_T}) = h_T q(h1,⋅⋅⋅,hT)=hT
Decoder:
p ( y ) = ∑ t = 1 T p ( y t ∣ y 1 , . . . , y t − 1 , c ) p(y) = \sum_{t=1}^T p(y_t | {y_1,...,y_{t-1}}, c) p(y)=t=1∑Tp(yt∣y1,...,yt−1,

本文详细探讨了自然语言处理中Attention机制的优势,如处理可变长度序列和并行化。介绍了Seq2seq模型的Encoder-Decoder框架,并讲解了Learning to Align and Translate的概念。接着,文章阐述了不同类型的Attention,包括硬注意力与软注意力、全局与局部注意力、Feed-forward NN中的注意力、层次注意力以及自我注意力。最后,总结了Attention机制的本质,它是一种查询到键值对的映射,用于捕捉序列内部的依赖关系和结构。

2347

被折叠的 条评论
为什么被折叠?



