---
title: [DL輪読会]Convolutional Sequence to Sequence Learning
tags:  #deep learning  
author: [Deep Learning JP](https://www.docswell.com/user/DeepLearning2023)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/LE35ZLL4J5.jpg?width=480
description: 2017/5/19 Deep Learning JP: http://deeplearning.jp/seminar-2/
published: May 19, 17
canonical: https://www.docswell.com/s/DeepLearning2023/5982G7-dlconvolutional-sequence-to-sequence-learning
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/LE35ZLL4J5.jpg)

DL輪読会
Convolutional Sequence to Sequence Learning
2017/05/19
松尾研究室
M1 中川 ⼤海


# Page. 2

![Page Image](https://bcdn.docswell.com/page/8EDDRNN5EG.jpg)

Agenda
1. Information
2. Introduction
3. Related Works
4. Proposed Model
5. Experiments &amp; Results
6. Conclusion
2


# Page. 3

![Page Image](https://bcdn.docswell.com/page/V7PXW55DE8.jpg)

1. Information
• Author
– Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, Yann N. Dauphin
– FAIR(Facebook AI Research)
• Submitted for arXiv on 8 May 2017
• Summary
• fully convolutionalなseq2seqモデル
• GLU, multi-hop attention, residual connectionなどの機構
• GNMTより精度⾼くて9倍くらい早い
• 実装がGitHubに上がってます(https://github.com/facebookresearch/fairseq)
3


# Page. 4

![Page Image](https://bcdn.docswell.com/page/2JVL8PPG7Q.jpg)

2. Introduction
• 翻訳界隈でGNMT(Google Neural Machine Translation)が話題
– encoder-decoder, bi-directional encoder, attention, LSTMブロック積んでresidual層で勾配消失防ぐ
• ⼀⽅、⾃然⾔語処理界隈では最近は並列計算できるCNNを⽤いるモデルが流⾏り
– RNN: 並列計算できない、系列が⻑くなると勾配消失しやすい
– CNN: 並列計算できるため計算⾼速化が可能、離れた系列間の関係も学習しやすい
• これまでもCNNを⽤いた⼿法は数々存在し、以下のような系譜をたどっている
1. 精度は勝てないけど計算は早くなる
2. 限られたデータセットでなら勝てる: [Bradbury et al. (2016), Kalchbrenner et al. (2016)]
3. 多様なデータセットで勝てる: [Gehring et al. (2016), Dauphin et al. (2016)]
• not fully convolutional
• not generative model like seq2seq
4


# Page. 5

![Page Image](https://bcdn.docswell.com/page/5EGX5PQDJL.jpg)

3. Related Work: ⾃然⾔語処理におけるタスク
• 識別
– language modeling(⾔語モデル)
– sentence classification
– sentiment analysis
– etc
• 評価指標
– Accuracy
– PPL(Perplexity)
• 単語の平均分岐数
• 2(1単語あたりのエントロピー)
• ⽣成
– sequence to sequence learning
• 翻訳, 要約
– caption generation
– etc
• どれぐらい単語を特定しにくいか(＝⼩さいほどよい)
– BLEU(Bilingual Evaluation Understudy)
• 正解(プロの翻訳)と予測の類似度的な指標
• ⼤きいほどよい
– ...
5


# Page. 6

![Page Image](https://bcdn.docswell.com/page/4JQ8Z2KX7P.jpg)

3. Related Work: GNMT
[Wu et al. 2016]
• encoder-decoderモデル
– encode: 翻訳元の⾔語から潜在状態
– decode: 潜在状態から翻訳先の⾔語へ
• ⼀層⽬のみbi-directional encoder
– 初めの⽅の単語も⽂脈情報考慮できる
– encoderの精度はattentionの効果にも影響
• attention
– ⼊⼒系列のどこに注⽬して訳すればよいかまで学習
– 計算時間は増えるが⻑い系列に特に有効
• 各層をresidualに
– 出⼒H(x)でなく残差関数F(x)=H(x)-xを学習
– 層を増やしても勾配消失しにくい
– ⼊⼒をそのまま出⼒に加算するだけで実装できる
6


# Page. 7

![Page Image](https://bcdn.docswell.com/page/K7423LP2J1.jpg)

3. Related Work: CNNを活⽤した⾃然⾔語処理モデル
• Sentence Classification
[Kim, 2014]
• Character-level Text classification
• Quasi-RNN
[Zhang et al. 2015]
[Bradbury et al. 2016]
– LSTMライクにプーリング
• その他いろいろあります
–
http://ksksksks2.hatenadiary.jp/entry/20170122/1485082800
–
http://deeplearning.hatenablog.com/entry/neural_machine_translation_theory#seq2seq
–
https://www.slideshare.net/sheemap/convolutional-neural-netwoks
• 計算は⾼速化されるが、LSTMベースより精度が良
かったり悪かったり、有効なデータセットが限られて
いたり
7


# Page. 8

![Page Image](https://bcdn.docswell.com/page/LJ1M1L9KEG.jpg)

3. Related Work: CNNを活⽤した⾃然⾔語処理モデル
• Language Modeling with Gated CNN
[Dauphin et al. 2016]
– Gated Linear Unitsをゲート関数として導⼊
– Residual処理
– WikiText-103のタスクでSoTAのPPL
– LSTMベースの20倍の速度
8


# Page. 9

![Page Image](https://bcdn.docswell.com/page/GJW38VQPJ2.jpg)

3. Related Work: CNNを活⽤したNMT
• Language Modeling with Gated CNN
[Dauphin et al. 2016]
– Gated Linear Unitsをゲート関数として導⼊
– “allows the model to select which words or features are relevant to predict the next word.”
– それまでの翻訳を踏まえて、その時点で⽂脈の特定の部分に着⽬するか広く⾒るか...などを表すゲート関数を学習できる
– tanhベースのゲート関数よりも勾配が消失しにくい
9


# Page. 10

![Page Image](https://bcdn.docswell.com/page/4EZV84W6J3.jpg)

4. Proposed Model
• やっていること
1. ⼊⼒をembedding→畳み込みしてGLUに通す
• decoder側も同様
2. multi-hop attentionを計算
• allow machines to reference different parts of text to
build understanding during encoding.
3. attentionつきの⼊⼒とdecoder contextsから予測
10


# Page. 11

![Page Image](https://bcdn.docswell.com/page/Y765P3GLEV.jpg)

4. Proposed Model
• やっていること
1. ⼊⼒をembedding→畳み込みしてGLUに通す
• decoder側も同様
2. multi-hop attentionを計算
• allow machines to reference different parts of text to
build understanding during encoding.
3. attentionつきの⼊⼒とdecoder contextsから予測
11


# Page. 12

![Page Image](https://bcdn.docswell.com/page/G75YKLVM74.jpg)

4. Proposed Model
• やっていること
1. ⼊⼒をembedding→畳み込みしてGLUに通す
• decoder側も同様
2. multi-hop attentionを計算
• allow machines to reference different parts of text to
build understanding during encoding.
3. attentionつきの⼊⼒とdecoder contextsから予測
12


# Page. 13

![Page Image](https://bcdn.docswell.com/page/9J2GWL3RJR.jpg)

4. Proposed Model
• やっていること
1. ⼊⼒をembedding→畳み込みしてGLUに通す
• decoder側も同様
2. multi-hop attentionを計算
• allow machines to reference different parts of text to
build understanding during encoding.
3. attentionつきの⼊⼒とdecoder contextsから予測
→もう少し詳しく⾒ていきます
13


# Page. 14

![Page Image](https://bcdn.docswell.com/page/DEYVLQ15EM.jpg)

4. Proposed Model
• やっていること
1. ⼊⼒をembedding→畳み込みしてGLUに通す
• decoder側も同様
• Position Embedding
を
によって
にembedding。
もconcatenateして
とする。
– inputやoutputが⽂のどの部分を扱っているかの情報
14


# Page. 15

![Page Image](https://bcdn.docswell.com/page/VJNM4K2478.jpg)

4. Proposed Model
• やっていること
1. ⼊⼒をembedding→畳み込みしてGLUに通す
• decoder側も同様
• Convolution
⼊⼒ベクトル
を
のカーネルで畳み込んで
とする。
– 各隠れ層でresidual処理を⾏っている
15


# Page. 16

![Page Image](https://bcdn.docswell.com/page/YE9NQV14E3.jpg)

4. Proposed Model
• やっていること
1. ⼊⼒をembedding→畳み込みしてGLUに通す
• decoder側も同様
• Gated Linear Units
から
へ変換。
– σ(B) controls which inputs A of the current context are
relevant
16


# Page. 17

![Page Image](https://bcdn.docswell.com/page/GE8KGP4V7D.jpg)

4. Proposed Model
• やっていること
2. multi-hop attentionを計算
– current decoder state
attention score
– conditional input
から
を求める
– decoder state summary
からattention
とprevious target element
とoutput of the last encoder
を求める
を求める
z: large input context
e: point information
zがkey、z+eがvalueとして
key-value memory networkのように働くらしい
17


# Page. 18

![Page Image](https://bcdn.docswell.com/page/LELZG16RJR.jpg)

4. Proposed Model
• やっていること
2. multi-hop attentionを計算
– decoder layer
•
はk-1個のattention historyにアクセスできる
に
が含まれるため
– 過去のattention情報を反映しやすい
• RNNだと消失しやすい
– https://code.facebook.com/posts/1978007565818999/anovel-approach-to-neural-machine-translation/
18


# Page. 19

![Page Image](https://bcdn.docswell.com/page/4JMVQW5PJW.jpg)

4. Proposed Model
• やっていること
3. attentionつきの⼊⼒とdecoder contextsから予測
19


# Page. 20

![Page Image](https://bcdn.docswell.com/page/PJR28Y3YE9.jpg)

5. Experiments &amp; Results
• Translation task
– Datasets
• WMTʼ16 English-Romanian, WMTʼ14 English-German, WMTʼ14 English-French
– Experiment 1: Recurrent vs. Convolutional
• LSTMベースのモデルたち, ByteNet, GNMT
– Experiment2: Generation speed vs. GNMT
– Experiment3: Effect of some architectures
20


# Page. 21

![Page Image](https://bcdn.docswell.com/page/PEXD8G447X.jpg)

5. Experiments &amp; Results
• Summarization task
– Datasets
• Abstractive summarization (Gigaword corpus)
– Compare Accuracy with RNN SoTA Models
• Shen et al., 2016
• Suzuki &amp; Nagata, 2017
21


# Page. 22

![Page Image](https://bcdn.docswell.com/page/3EKXK4ZP7D.jpg)

5. Results: Translation task
• 1. Recurrent vs. Convolutional
– いずれのデータセットでも最良のBLEU
22


# Page. 23

![Page Image](https://bcdn.docswell.com/page/L735ZLD4E5.jpg)

5. Results: Translation task
• 2. Generation speed vs. GNMT
– 提案モデルのGPU(K40)でGNMTの
GPU(K80)より⾼精度で9.3倍の速さ
• K80はK40⼆つ分みたいなもの
• “We did not have such a GPU available”
– ビームサーチ幅(b)を広げるとスピードは多少落ち
るが、BLEUは上がる
– CPUはコア数が違うので⽐較できないとのこと
23


# Page. 24

![Page Image](https://bcdn.docswell.com/page/87DDRNP57G.jpg)

5. Results: Translation task
• 3. Effect of position embedding
– position embeddingはあまり影響なし
24


# Page. 25

![Page Image](https://bcdn.docswell.com/page/VJPXW5ND78.jpg)

5. Results: Translation task
• 3. Effect of multi-step attention
– decoder layer全てにattentionするのが最良
– 計算的なoverheadもほとんどない
25


# Page. 26

![Page Image](https://bcdn.docswell.com/page/2EVL8PKGJQ.jpg)

5. Results: Translation task
• 3. Effect of kernel size &amp; depth
– 狭く、深くが良い
– Encoderは結構深くできる
– Decoderはあまり効果なし
26


# Page. 27

![Page Image](https://bcdn.docswell.com/page/57GX5P9DEL.jpg)

5. Results: Summarization task
• Accuracy
– 勝ってるorそんなに負けてない(らしい)
– ⽐較対象のモデルはいろいろspecificな加⼯してる
• けど、⼿を加えていない提案モデルでも同じくらいの精度を出せている、とのこと
– 提案モデルにも同様の処理はできる(らしい)
27


# Page. 28

![Page Image](https://bcdn.docswell.com/page/4EQ8Z2WXJP.jpg)

6. Conclusion
• fully convolutionalなseq2seqモデルを提案
– GLU, residual connection, multi-hop attention(, position embedding)などの機構を活⽤
• seq2seqモデルでSoTAな精度&amp;GNMTの9倍の速度を達成した
28


# Page. 29

![Page Image](https://bcdn.docswell.com/page/KJ423LK2E1.jpg)

感想
• CNNすごい
• NMTとかattentionとか全然わかってなかったので勉強になりました
– 参考資料⾒ると結構分かるようになると思います
29


# Page. 30

![Page Image](https://bcdn.docswell.com/page/LE1M1LXK7G.jpg)

参考⽂献
•
Gehring, Jonas, et al. &quot;Convolutional Sequence to Sequence Learning.&quot; arXiv preprint arXiv:1705.03122 (2017).
•
Kim, Yoon. &quot;Convolutional neural networks for sentence classification.&quot; arXiv preprint arXiv:1408.5882 (2014).
•
Zhang, Xiang, Junbo Zhao, and Yann LeCun. &quot;Character-level convolutional networks for text
classification.&quot; Advances in neural information processing systems. 2015.
•
Bradbury, James, et al. &quot;Quasi-Recurrent Neural Networks.&quot; arXiv preprint arXiv:1611.01576 (2016).
•
Wu, Yonghui, et al. &quot;Google&#039;s Neural Machine Translation System: Bridging the Gap between Human and
Machine Translation.&quot; arXiv preprint arXiv:1609.08144 (2016).
•
Dauphin, Yann N., et al. &quot;Language Modeling with Gated Convolutional Networks.&quot; arXiv preprint
arXiv:1612.08083 (2016).
•
Shen, Shiqi, et al. &quot;Neural Headline Generation with Sentence-wise Optimization.&quot; arXiv preprint
arXiv:1604.01904 (2016).
•
Suzuki, Jun, and Masaaki Nagata. &quot;Cutting-off Redundant Repeating Generations for Neural Abstractive
Summarization.&quot; EACL 2017 (2017): 291.
30


# Page. 31

![Page Image](https://bcdn.docswell.com/page/GEW38VNPE2.jpg)

参考⽂献
• Facebook AI Researchによる説明
– https://code.facebook.com/posts/1978007565818999/a-novel-approach-to-neural-machine-translation/
• NMT⼀般の参考
– http://deeplearning.hatenablog.com/entry/neural_machine_translation_theory#seq2seq
• GNMTの解説
– http://smerity.com/articles/2016/google_nmt_arch.html
– http://www.yasuhisay.info/entry/2016/11/23/000000
• Residual層の解説
– http://terada-h.hatenablog.com/entry/2016/12/13/192940
• Attentionの解説
– https://www.slideshare.net/yutakikuchi927/deep-learning-nlp-attention
– インタラクティブに理解できる→
http://distill.pub/2016/augmented-rnns/
31


