https://www.youtube.com/watch?v=6s69XY025MU
https://www.youtube.com/watch?v=bCz4OMemCcA
(출처 : https://ko.wikipedia.org/wiki/BLEU)
BLEU(Bilingual Evaluation Understudy)
: 자연어 처리 분야에서 사용하는 평가 지표인듯.
나는 vision task에 관심이 많기 때문에 이 이상의 detail은 생략...
그냥 간단히 model의 출력이 인간의 출력에 얼만큼 비슷한지 평가하는 지표로 생각.
우리는 reccurence 및 convolution을 제외하고 오직 attention mechanism
에 기반한
a new simple network architecture인 Transformer
를 제안한다.
두 가지 machine translation tasks에 대한 실험 결과,
transformer model들이 품질 면에서 우수하며 parallelizable and train time이 훨씬 적다는 것을 보여준다.
우리 model은 WMT 2014 English-to-German translation task에서 28.4 BLEU를 달성하여 기존의 state-of-the-art 결과를 능가했다.
RNN가 특히 LSTM과 같은 gated recurrent neural networks는
language modeling 및 machine translation에서
state of the art approaches로 확립되어져 왔다.
(RNN 단점)
Recurrent model은 본질적으로 training examples에서 parallelization을 배제하며,
memory constraint으로 인해 긴 sequence lengths에서 critical하다.
최근 이를 해결하기 위한 여러 연구들이 있긴 했지만, 여전히 근본적인 제약이 남아있다..
Attention mechanism은 input이나 output sequences의 거리에 관계없이
dependencies를 modeling할 수 있도록 해주어 다양한 task에서 좋은 sequence modeling 및 transduction models의 필수 요소가 되었다.
이 논문에서는 recurrent를 배제하고 input 및 output 간의 global dependencies을
완전히 attention mechanism에 의존하는 model architecture인 Transformer를 제안한다.
Transformer는 more parallelization을 가능하게 하며, 8개의 P100 GPU에서 12시간만 training 후에도 번역 품질은 new state of the art 수준을 도달할 수 있게 되었다.
(앞선 논문들의 문제점)
sequential computation을 줄이는 것을 목표로 하는 Extended Neural GPU, ByteNet, ConvS2S의 기초적인 building block으로서
CNN을 사용하는 model들은 모든 input and output position에 대해 병렬로 hidden representations을 계산한다.
이러한 model에서 두 가지 임의의 input 또는 output 위치에서 signal을 관련시키기 위해 필요한 작업 수는 위치 간의 거리에 따라 선형적으로(ConvS2S의 경우) 또는 log적으로(ByteNet의 경우) 증가한다.
이로 인해 먼 위치 간의 dependencies를 학습하는 것이 더 어려워진다.
Transformer에서는 이러한 작업 수를 일정한 수로 줄였지만,
평균화된 attention-weighted position으로 인해 effective resolution가 감소하는 비용이 발생한다. (?)
이 효과는 section 3.2에서 설명된 Multi-Head Attention으로 상쇄시킴으로써 극복됨.
(attention mechanism의 성공사례, 연구들)
Self-attention, intra-attention이라고도 불리는 이는 single sequence의 다양한 위치 간의 관계를
나타내어 sequence의 representation을 계산하는 attention mechanism이다.
Self-attention은 reading comprehension, abstractive summarization, tectual entailment and learning task-independent representations 등 다양한 작업에서 성공적으로 사용됨.
End-to-end memory networks는 sequence에 맞춘 recurrence 대신에 attention mechanism을 기반으로 하며,
simple-language question answering and language modeling tasks에서 잘 수행된다는 것이 입증되었다[34].
(이 논문에서 최초로 attention mechanism만 사용한 Transformer를 소개)
그러나 우리가 알고 있는 선에서,
Transformer는 sequence에 맞춘 RNN 또는 Convolution을 사용하지 않고,
input과 output의 representation을 계산하는 데에
전적으로 self-attention에 의존하는 최초의 model transduction(변환)이다.
(다른 논문에서는 RNN, CNN에 attention mechanism을 써서 좋은 성능을 보였는데
이 논문에서는 RNN, CNN을 아예 쓰지 않고 attention mechanism만 써서 input과 output의 representation을 계산하는 듯...)
다음 section에서는, self-attention 기반 Transformer에 대해 설명하고,
다른 model에 비해 갖는 장점을 논의할 것임.
Decoder도 identical layers로 stack되어져있다.
encoder layer의 2개의 sub-layers들에 추가로,
decoder는 encoder stack의 output에 대한 multi-head attention을 수행하는 세 번째 sub-layer를 삽입했다.
encoder와 비슷하게, 각각의 sub-layer에 residual connection을 적용했고, layer normalization을 거친다.
또한 decoder의 self-attention sub-layer를 수정하여
각 position이 그 뒤의 position에 대해 attention할 수 없도록 했다.
이러한 masking은, output embedding이 한 position씩 offset되기 때문에
position 에 대한 prediction이 보다 작은 position의 알려진 output에만 의존하도록 보장한다.
우리는 특정한 attention을 "Scaled Dot-Product Attention"이라고 부른다.
input은 dimension이 인 queries와 keys, 그리고 인 values로 구성된다.
우리는 query와 모든 keys들을 dot products하고,
가각을 로 나눈 뒤,
softmax function을 적용하여 values들의 weights를 얻는다.
실제로, 우리는 동시에 여러 query로 이루어진 set에 대해 attention function을 계산한다.
이들을 matrix 로 함께 묶어서 표현한다.
keys와 values 역시 matrix 와 로 함께 묶어서 나타낸다.
우리는 matrix of output을 다음과 같이 계산한다.
두 가지 가장 흔히 사용되는 attention functions으로
additive attention과 dot-product(multiplicative) attention이 있다.
Dot-product attention은 scaling factor 을 곱해주는 것을 제외하고는 우리의 algorithm과 동일하다.
additive attention과 dot-product attention은 이론적으로 유사하지만,
실제로 dot-product attention이 optimized matrix multiplication code를 사용하여 구현할 수 있기 때문에 보다 빠르고 space-efficient하기 때문에 많이 사용된다.
-dimension의 key, value, query로 single attention function을 수행하는 대신,
query, keys 및 values에 대해 서로 다른 번의 trained된 linear projection을 통해
및 dimension으로 linearly projection하는 것이 유익하다고 알아냈다.
이러한 projection된 query, key 및 value의 각 version에 대해 병렬로 attention function을 수행하고,
이로부터 -dimensional output values를 얻는다.
이들은 concatenated되고 다시 projection되어 final value가 만들어진다.
Multi-head attention은 model이 서로 다른 representation subspace에 있는 information에 대해
함께 attention할 수 있도록 한다.
single attention head의 경우, averaging하는 것이 이를 억제한다.
(이해를 위한 그림 : https://codingopera.tistory.com/44)
우리 model은 recurrence나 convolution을 포함하지 않으므로,
model이 sequence의 순서를 활용하려면 sequence 내 token의 상대적이거나 절대적인 위치에 대한 정보를 준비해야 한다.
이를 위해 우리는 encoder와 decoder stack의 맨 아래에 "positional encodings"을 input embedding에 추가하였다.
positional encoding은 embedding과 동일한 dimension인 을 가지므로 두 값이 더해질 수 있다.
positional encoding의 선택지는 많이 있으며, learned and fixed된 것이 있다.
이 논문에서는 sine and cosine function을 사용하여
서로 다른 frequency의 positional encoding을 사용한다.
Architecture 정리, 요약
self-attention layer가 recurrent와 convolution layer에 비해 어떠한 장점이 있는지 3가지 상황을 고려하여 설명할 것임.
부가적인 이점으로,
self-attention은 더욱 interpretable(해석가능한) model을 제공할 수 있다.
우리는 model에서 얻은 attention distribution을 검토하고, appendix에서 discussiong할 것임.
또한 multi-head가 명확하게 서로 다른 task를 수행하는 것은 물론,
많은 attention head가 문장의 문법적 및 의미적 구조와 관련된 행동을 나타내는 것으로 보임.