Neural machine translation은 machine translation 분야에서 부상하고 있는 분야로, 주로 encoder-decoder 구조를 따른다. 이때 encoder는 source sentence를 읽고 fixed-lengh vector로 encoding하는 역할이고, decoder는 이 encoded vector를 번역하여 output을 생성하는 역할을 한다. 그 대표적인 모델이 Seq2Seq인데, 여기서 encoder는 source sentence를 fixed-length vector로 바꾸기 때문에 문장의 길이가 긴 경우 어려움이 발생한다. 이 문제를 해결하기 위해 본 논문에서는 입력 문장 전체를 단일 벡터로 encoding할 필요 없이 읽어들임과 동시에 번역하는 모델을 도입했는데, 이를 attention mechanism이라 한다.
확률적인 관점에서 봤을 때, translation은 source sentence $\mathbf x$에 대한 conditional probability를 최대로 만드는 target sentence $\mathbf y$를 찾는 문제, 즉 $\arg \max_\mathbf y p(\mathbf y|\mathbf x)$를 구하는 문제가 된다. Neural machine translation에서 우리는 parallel training corpus를 이용하여 sentence pair의 conditional probability를 최대화하는 모델을 만든다. 이렇게 translation model로 conditional distribution을 학습시킨 후 source sentence가 주어지면 conditional probability가 최대가 되는 문장을 찾음으로써 그에 대응되는 translation을 생성할 수 있다.
Encoder-Decoder framework에서 encoder는 input sentence인 $\mathbf x = (x_1, \cdots, x_{T_x})$를 vector $c$로 변환한다. RNN을 적용시킨 식은 다음과 같다.
이때 $h_t \in \mathbb R^n$은 time $t$에서의 hidden state를 의미하며 $c$는 sequence of hidden states로부터 생성된다. 또한 $f$와 $q$는 적절한 nonlinear function을 의미한다.
Decoder는 context vector $c$와 previously predicted words $\{y_1, \cdots, y_{t'-1}\}$이 주어졌을 때 $y_{t'}$을 학습할 수 있다. 따라서 번역 결과가 $\mathbf y = (y_1, \cdots, y_{T_y})$의 확률은 다음과 같이 구할 수 있다.
RNN을 적용할 경우 conditional probability의 식은 다음과 같다.
이때 $g$는 nonlinear function이고, $s_t$는 RNN의 hidden state를 의미한다.
이 section에서는 neural machine translation에서의 새로운 architecture인 attention mechanism을 제시한다.