← Back to Blog

[Paper Review] Neural Machine Translation by Jointly Learning to Align and Translate

paper review > deep learning

2026-07-093 min read

#paper-review #deep-learning #natural-language-processing #attention #machine-translation

논문 링크: Neural Machine Translation by Jointly Learning to Align and Translate

논문 정보

항목내용
출판 시점2014년
저자Dzmitry Bahdanau, Kyunghyun Cho, Yoshua Bengio
주제Neural machine translation, additive attention

핵심 아이디어

이 논문은 encoder-decoder 기반 neural machine translation에 attention mechanism을 도입했다. 기존 seq2seq는 encoder의 마지막 hidden state 하나에 입력 문장 전체를 압축해야 했다. 문장이 길어지면 이 고정 길이 vector가 bottleneck이 된다.

Attention은 decoder가 매 step마다 encoder hidden states 전체를 보고, 현재 출력에 필요한 위치에 가중치를 둔다.

RNNsearch의 핵심은 번역할 때 입력 문장 전체를 하나의 vector로 압축하지 않고, 필요한 source token을 매 step마다 다시 참고하게 만든 것이다.

왜 중요한가

이 논문은 NLP에서 attention을 본격적으로 사용하게 만든 대표 작업이다. 이후 Transformer의 self-attention으로 이어지는 중요한 전 단계이다.

수식으로 보는 핵심

Encoder는 source token annotation hjh_j를 만든다. Decoder step ii에서는 이전 decoder state si1s_{i-1}와 각 encoder annotation hjh_j 사이의 alignment score를 계산한다.

eij=a(si1,hj)e_{ij} = a(s_{i-1}, h_j)

Bahdanau attention에서 aa는 작은 feedforward network다.

eij=vatanh(Wasi1+Uahj)e_{ij} = v_a^\top \tanh(W_a s_{i-1} + U_a h_j)

Score는 softmax를 거쳐 attention weight가 된다.

αij=exp(eij)kexp(eik)\alpha_{ij} = \frac{\exp(e_{ij})}{\sum_k \exp(e_{ik})}

Context vector는 encoder annotation의 weighted sum이다.

ci=jαijhjc_i = \sum_j \alpha_{ij} h_j

Decoder는 이 context를 사용해 다음 단어 확률을 낸다.

p(yiy<i,x)=g(yi1,si,ci)p(y_i \mid y_{<i}, x) = g(y_{i-1}, s_i, c_i)

Attention의 핵심 수식은 고정 길이 vector 하나 대신, 매 decoding step마다 cic_i를 새로 계산한다는 점이다.

이 구조 때문에 긴 source sentence의 모든 정보를 마지막 hidden state 하나에 압축하지 않아도 된다.

기존 Encoder-Decoder의 병목

초기 seq2seq model은 encoder가 source sentence를 마지막 hidden state 하나로 압축하고, decoder가 그 vector만 보고 target sentence를 생성했다. 짧은 문장에서는 동작할 수 있지만, 문장이 길어지면 모든 정보를 하나의 고정 길이 vector에 넣어야 한다. 이는 정보 병목이 된다.

Alignment와 Context Vector

Bahdanau attention은 decoder의 현재 state와 encoder의 각 annotation 사이의 score를 계산한다. 이 score를 softmax로 바꾸면 source position에 대한 attention weight가 된다. 그 다음 encoder annotation의 weighted sum으로 context vector를 만든다.

Decoder는 매 time step마다 다른 context vector를 받는다. 즉 target word를 생성할 때마다 source sentence의 필요한 부분을 다시 본다.

Attention은 번역에서 alignment를 별도 모델로 고정하지 않고, 번역 모델 안에서 함께 학습하게 만든다.

Additive Attention

이 논문의 attention score는 작은 feedforward network로 계산된다. Query와 key의 dot product를 바로 쓰는 Transformer식 attention과 달리, decoder state와 encoder annotation을 결합한 뒤 nonlinear layer를 통과시킨다. 이 때문에 additive attention 또는 Bahdanau attention이라고 부른다.

실험적 의미

논문은 긴 문장에서 기존 encoder-decoder보다 더 나은 번역 품질을 보였다. 특히 attention weight를 시각화하면 target word가 source sentence의 어느 부분을 참고하는지 대략적인 alignment로 해석할 수 있다.

한계

이 모델은 여전히 RNN 기반이라 sequential computation이 병목이다. 긴 sequence를 병렬 처리하기 어렵고, decoder generation도 token by token으로 진행된다. 하지만 attention이라는 아이디어는 이후 self-attention과 Transformer로 확장되며 NLP architecture의 중심이 되었다.

읽을 포인트

정리

이 논문은 attention을 현대 deep learning의 핵심 도구로 만든 출발점 중 하나다. 핵심은 encoder가 모든 정보를 하나의 vector에 숨기게 하지 않고, decoder가 필요한 순간에 필요한 source representation을 선택하게 만든 것이다.