Neural machine translation by jointly learning to align and translate論文閱讀筆記

Title

Neural machine translation by jointly learning to align and translate

(零)細節

  • 傳統的phrase-based translation system,特點是consists of many small sub-components that are tuned separately

(一)摘要

  • 神經機器翻譯是應用到機器翻譯領域的新方法,當前的做法就是使用encoder-decoders架構,將a source sentence變成a fixed-length的vector。然後使用decoder生成翻譯,通過聯合訓練來最大化輸出翻譯句子的概率。這種方式很難處理長句子,並且Cho et al證明隨着句子長度的增加,basic編碼器-解碼器的性能確實會迅速下降。
  • 作者認爲fixed-length的向量是繼續提升encoder-decoder 框架性能的一個瓶頸(bottleneck),然後作者提出讓模型能夠去自動地search for parts of a source sentence that are relevant to predicting a target word。就是找到和翻譯後的word最相關的源句中的關鍵部分。就像人把’the dog’翻譯’狗’那樣,作者提出的網絡試圖找到和"狗"最相關的源句部分就是"the dog"

(二)介紹

  • 本文提出的網絡試圖將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(yx)

  • 從neural networks角度看神經機器翻譯

    • (Cho et al., 2014a) and (Sutskever et al., 2014)使用neural neteworks去直接學習上面的條件分佈,具體的做法,就是使用兩個RNN將可變長度的源句子編碼爲固定長度的向量,並將該向量解碼爲可變長度的目標句子。
    • Sutskever et al. (2014)使用LSTM作爲基本單元來進行翻譯
    • Adding neural components to existing translation system進一步提升翻譯性能。

3.1 RNN Encoder-Decoder

3.1.1 Encoder部分

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,ht1)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} htRn爲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最後一個時刻的輸出隱狀態。

3.1.2 Decoder部分

  • 輸入爲context vector c c c以及所有之前預測的words{ y 1 , . . . , y t ′ − 1 {y_1,...,y_{t^{'}-1}} y1,...,yt1},

  • 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=1Tp(yt{y1,,yt1},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,,yt1},c)=g(yt1,st,c)

  • 也可以使用其他的architectures 比如a hybrid of an RNN以及a de-convolutional neural network can be used (Kalchbrenner and Blunsom, 2013)

(四)Learning to align and translate

  • 整體框架:
    在這裏插入圖片描述

    encoder由雙向RNN組成,解碼器在翻譯過程中serching trough a source sentence

4.1 Decoder:General Description

​ 使用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(yiy1,,yi1,x)=g(yi1,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(si1,yi1,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=1Txα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(si1,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} si1(just before emitting y i y_i yi, Eq. (4)) and the j-th annotation h j h_j hj of the input sentence.

  • 文中參數化the alignment model α \alpha α作爲一個feedforward neural network which is jointly trained with
    all the other components of the proposed system.這裏似乎沒有介紹 α \alpha α的3種形式。

4.2 ENCODER: BIDIRECTIONAL RNN FOR ANNOTATING SEQUENCES

  • 採用雙向RNN作爲編碼器:
    • forward RNN f ⃗ \vec{f} f 產生的隱狀態爲: ( h ⃗ 1 , … , h ⃗ T x ) \left(\vec{h}_{1}, \ldots, \vec{h}_{T_{x}}\right) (h 1,,h Tx)
    • backward RNN f ← \overleftarrow{f} f 產生的隱狀態爲: ( h ← 1 , ⋯   , h ← T x ) \left(\overleftarrow{h}_{1}, \cdots, \overleftarrow{h}_{T_{x}}\right) (h 1,,h Tx)
  • 最終得到的狀態向量爲: h j = [ h ⃗ j ⊤ ; h ← j ⊤ ] ⊤ h_{j}=\left[\vec{h}_{j}^{\top} ; \overleftarrow{h}_{j}^{\top}\right]^{\top} hj=[h j;h j]

(五)實驗設置

論文最後做對比,挑一個不如我們模型的,而且還是最近的模型,對於兩個模型使用相同的訓練過程和相同的數據集。

5.1 數據集

  • WMT ’14
  • 預處理操作:
    • 我們使用Axelrod等人(2011)的數據選擇方法,將組合語料庫的大小減少到348M個單詞
    • We do not use any monolingual data other than the mentioned parallel corpora(只使用這個), although it may be possible to use a much larger monolingual corpus to pretrain an encoder
    • 將news-test-2012和news-test-2013concatenate作爲驗證(validation)集
    • evaluate the models on the test set (news-test-2014) 測試集
    • 我們使用每種語言中最常用的30,000個單詞來訓練我們的模型。任何未包含在候選列表中的單詞都會被映射到一個特殊的標記([UNK])。我們不會對數據進行任何其他特殊的預處理。比如lowercasing或者stemming

5.2 模型

  • 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最大條件概率

(六)結果

6.1 定量結果

在這裏插入圖片描述

這裏面的Moses是conventional phrase-based translation system (Moses)傳統基於短語的翻譯系統

在這裏插入圖片描述

從圖中可以看出RNNsearch-30和RNNsearch-50對句子的長度都更穩健。尤其是RNNsearch50,即使句子長度爲50或更長,也沒有表現出性能下降

6.2 定性分析

6.2.1 Alignment

在這裏插入圖片描述
通過圖可以看出,在生成目標詞時,源句中的哪些位置被認爲更重要。我們沿着每個矩陣的對角線看到很強的權重

6.2.2 Long Sentences

在這裏插入圖片描述

​ 從圖2中可以清楚地看到,在翻譯長句方面,所提出的模型比傳統模型好得多。這可能是因爲RNNsearch不需要將一個長句子完美地編碼成一個固定長度的向量,而只需要精確地編碼輸入句子中圍繞特定單詞的部分

對比兩個模型的翻譯結果,法語俺也不懂,就不放上去了,作者想要說明的就是本文提出的模型確實要比前人的好。

(七)相關工作

7.1 learning to align

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.)。

7.2 Neural Network for machine Translation

和我們工作不同路子的神經機器翻譯:

  • Bengio et al. (2003)

  • Schwenk (2012)

  • Kalchbrenner and Blunsom (2013) and Devlin et al. (2014)

(八)總結

  • 總結就是升級版的摘要信息。就是🐮🍺,這腦子忒好

注:在寫論文閱讀筆記的時候,我覺得用一些原句能夠更好地反應作者的意圖 注:Markdown上插入的表情有點醜,這是牛🐮,這是啤酒🍺