Neural machine translation by jointly learning to align and translate
本文提出的網絡試圖將input sentence編碼成a sequence of vectors and chooses a subset of these vectors adaptively while decoding the translation,不需要將一個完整的句子squash into a fixed vector,能夠更好地適應長句子。
本文提出的網絡提升了神經機器翻譯的性能,尤其是針對長句子而言,同時文中還進行了qualitative analysis(定性分析),去在原句和翻譯句之間構建linguistically plausible (soft-)alignment語言上合理的(軟)對齊。
從統計學角度來看神經機器翻譯
在給定原句的情況下,希望找到一個目標句子 y \mathbf{y} y,目標函數爲最大化條件概率
arg max y p ( y ∣ x ) \arg \max _{\mathbf{y}} p(\mathbf{y} \mid \mathbf{x}) argymaxp(y∣x)
從neural networks角度看神經機器翻譯
h t = f ( x t , h t − 1 ) c = q ( { h 1 , ⋯ , h T x } ) \begin{array}{c} h_{t}=f\left(x_{t}, h_{t-1}\right) \\ c=q\left(\left\{h_{1}, \cdots, h_{T_{x}}\right\}\right) \end{array} ht=f(xt,ht−1)c=q({h1,⋯,hTx})
input sentence: x = ( x 1 , ⋯ , x T x ) \mathbf{x}=\left(x_{1}, \cdots, x_{T_{x}}\right) x=(x1,⋯,xTx)
編碼成的vector c c c
h t ∈ R n h_{t} \in \mathbb{R}^{n} ht∈Rn爲t時刻的隱狀態
f f f和 q q q是非線性函數
對於 Sutskever et al. (2014) 使用LSTM作爲 f f f,並且 c c c就是 q ( { h 1 , ⋯ , h T } ) = h T q\left(\left\{h_{1}, \cdots, h_{T}\right\}\right)=h_{T} q({h1,⋯,hT})=hT最後一個時刻的輸出隱狀態。
輸入爲context vector c c c以及所有之前預測的words{ y 1 , . . . , y t ′ − 1 {y_1,...,y_{t^{'}-1}} y1,...,yt′−1},
將 p ( y ) p(\mathbf{y}) p(y)利用條件概率進行分解
p ( y ) = ∏ t = 1 T p ( y t ∣ { y 1 , ⋯ , y t − 1 } , c ) p(\mathbf{y})=\prod_{t=1}^{T} p\left(y_{t} \mid\left\{y_{1}, \cdots, y_{t-1}\right\}, c\right) p(y)=t=1∏Tp(yt∣{y1,⋯,yt−1},c)
利用RNN可以將條件概率進行建模:
p ( y t ∣ { y 1 , ⋯ , y t − 1 } , c ) = g ( y t − 1 , s t , c ) p\left(y_{t} \mid\left\{y_{1}, \cdots, y_{t-1}\right\}, c\right)=g\left(y_{t-1}, s_{t}, c\right) p(yt∣{y1,⋯,yt−1},c)=g(yt−1,st,c)
也可以使用其他的architectures 比如a hybrid of an RNN以及a de-convolutional neural network can be used (Kalchbrenner and Blunsom, 2013)
整體框架:
encoder由雙向RNN組成,解碼器在翻譯過程中serching trough a source sentence,
使用RNN解碼器框架來代替條件概率定義:
p ( y i ∣ y 1 , … , y i − 1 , x ) = g ( y i − 1 , s i , c i ) p\left(y_{i} \mid y_{1}, \ldots, y_{i-1}, \mathbf{x}\right)=g\left(y_{i-1}, s_{i}, c_{i}\right) p(yi∣y1,…,yi−1,x)=g(yi−1,si,ci)
其中 s i s_i si爲解碼器RNN的隱狀態, s i = f ( s i − 1 , y i − 1 , c i ) s_{i}=f\left(s_{i-1}, y_{i-1}, c_{i}\right) si=f(si−1,yi−1,ci),不同於之前架構的地方時,原來 y i y_i yi是基於固定向量 c c c的,而現在 y i y_i yi是基於 c i c_i ci的。而這裏 c i c_i ci又是依賴於 ( h 1 , . . h T x ) (h_1,..h_{T_x}) (h1,..hTx)的, c i c_i ci的計算方式爲:
c i = ∑ j = 1 T x α i j h j c_{i}=\sum_{j=1}^{T_{x}} \alpha_{i j} h_{j} ci=j=1∑Txαijhj
其中
α i j = exp ( e i j ) ∑ k = 1 T x exp ( e i k ) e i j = a ( s i − 1 , h j ) \begin{array}{c} \alpha_{i j}=\frac{\exp \left(e_{i j}\right)}{\sum_{k=1}^{T_{x}} \exp \left(e_{i k}\right)} \\ e_{i j}=a\left(s_{i-1}, h_{j}\right) \end{array} αij=∑k=1Txexp(eik)exp(eij)eij=a(si−1,hj)
e i , j e_{i,j} ei,jis an alignment model which scores how well the inputs around position j and the output at position i match. The score is based on the RNN hidden state s i − 1 s_{i−1} si−1(just before emitting y i y_i yi, Eq. (4)) and the j-th annotation h j h_j hj of the input sentence.
論文最後做對比,挑一個不如我們模型的,而且還是最近的模型,對於兩個模型使用相同的訓練過程和相同的數據集。
RNN Encoder–Decoder(前人模型) (RNNencdec, Cho et al.) Train了兩個模型,length up to 50 words(RNNencdec-30)以及length up to 30 words(RNNencdec-50)
RNNsearch(本文模型) Train了兩個模型,length up to 30 words(RNNsearch-30)以及length up to 50 words(RNNsearch-50)
encoder採用1000個隱狀態的雙向RNN,decoder有1000 hidden units
In both cases, we use a multilayer network with a single maxout (Goodfellow et al., 2013) hidden layer to compute the conditional probability of each target word (Pascanu et al., 2014).
a minibatch stochastic gradient descent (SGD) algorithm together with Adadelta,batch_size大小爲80,訓練了5天
訓練完成後使用beam search最大條件概率
這裏面的Moses是conventional phrase-based translation system (Moses)傳統基於短語的翻譯系統
從圖中可以看出RNNsearch-30和RNNsearch-50對句子的長度都更穩健。尤其是RNNsearch50,即使句子長度爲50或更長,也沒有表現出性能下降
通過圖可以看出,在生成目標詞時,源句中的哪些位置被認爲更重要。我們沿着每個矩陣的對角線看到很強的權重
從圖2中可以清楚地看到,在翻譯長句方面,所提出的模型比傳統模型好得多。這可能是因爲RNNsearch不需要將一個長句子完美地編碼成一個固定長度的向量,而只需要精確地編碼輸入句子中圍繞特定單詞的部分
對比兩個模型的翻譯結果,法語俺也不懂,就不放上去了,作者想要說明的就是本文提出的模型確實要比前人的好。
A similar approach of aligning an output symbol with an input symbol was proposed recently by
Graves (2013) in the context of handwriting synthesis.
本文工作和他們工作的區別是:the modes of the weights of the annotations only move in one directionGraves (2013).
我們的工作是 requires computing the annotation weight of every word in the source sentence for each word in the translation。不過這樣對於輸入輸出句子長度有限制(也就是This drawback is not severe with the task of translation in which most of input and output sentences are only 15–40 words. However, this may limit the applicability of the proposed scheme to other tasks.)。
和我們工作不同路子的神經機器翻譯:
Bengio et al. (2003)
Schwenk (2012)
Kalchbrenner and Blunsom (2013) and Devlin et al. (2014)
注:在寫論文閱讀筆記的時候,我覺得用一些原句能夠更好地反應作者的意圖 注:Markdown上插入的表情有點醜,這是牛🐮,這是啤酒🍺