Provided proper attribution is provided, Google hereby grants permission to reproduce the tables and figures in this paper solely for use in journalistic or scholarly works.

---

적절한 출처 표기가 제공되는 경우, 구글은 본 논문의 표와 그림을 저널리즘 또는 학술적 목적으로만 복제할 수 있는 권한을 부여합니다.

---

# Attention Is All You Need

Ashish Vaswani$^{*}$
Google Brain
avaswani@google.com

Llion Jones$^{*}$
Google Research
llion@google.com

Noam Shazeer$^*$
Google Brain
noam@google.com

**Aidan N. Gomez$^{*}$ $^{\dagger}$**
University of Toronto
aidan@cs.toronto.edu

---

**Aidan N. Gomez$^{*}$ $^{\dagger}$**
토론토 대학교
aidan@cs.toronto.edu

---

**Niki Parmar**$^*$
Google Research
nikip@google.com

---

**니키 파르마르**$^*$
구글 리서치
nikip@google.com

---

Illia Polosukhin$^{*}$ $\ddagger$

illia.polosukhin@gmail.com

Jakob Uszkoreit$^{\ast}$
Google Research
usz@google.com

Łukasz Kaiser$^*$
Google Brain
lukaszkaiser@google.com

## Abstract

---

## 요약

---

The dominant sequence transduction models are based on complex recurrent or convolutional neural networks that include an encoder and a decoder. The best performing models also connect the encoder and decoder through an attention mechanism. We propose a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely. Experiments on two machine translation tasks show these models to be superior in quality while being more parallelizable and requiring significantly less time to train. Our model achieves 28.4 BLEU on the WMT 2014 English-to-German translation task, improving over the existing best results, including ensembles, by over 2 BLEU. On the WMT 2014 English-to-French translation task, our model establishes a new single-model state-of-the-art BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small fraction of the training costs of the best models from the literature. We show that the Transformer generalizes well to other tasks by applying it successfully to English constituency parsing both with large and limited training data.

---

우세한 순열 변환 모델들은 인코더와 디코더를 포함하는 복잡한 순환 또는 합성곱 신경망에 기반을 두고 있습니다. 가장 성능이 우수한 모델들은 또한 인코더와 디코더를 어텐션 메커니즘을 통해 연결합니다. 우리는 재귀와 합성곱을 완전히 배제하고 오직 어텐션 메커니즘에만 기반한 새로운 간단한 네트워크 구조인 Transformer를 제안합니다. 두 가지 기계 번역 작업에 대한 실험 결과, 이러한 모델들이 품질 면에서 우수할 뿐만 아니라 더 높은 병렬화를 가능하게 하며 훈련에 필요한 시간이 현저히 적음을 보여줍니다. 우리의 모델은 WMT 2014 영어-독일어 번역 작업에서 28.4 BLEU 점수를 달성하여 앙상블을 포함한 기존 최상의 결과보다 2 BLEU 이상 향상시켰습니다. WMT 2014 영어-프랑스어 번역 작업에서는 8개의 GPU에서 3.5일 동안 훈련한 후 단일 모델 기준 최신 BLEU 점수 41.8을 기록했으며, 이는 문헌상 최상의 모델들의 훈련 비용의 작은 부분에 불과합니다. 우리는 대규모 및 제한된 학습 데이터를 모두 사용하여 영어 구문 분석 작업에 성공적으로 적용함으로써 Transformer가 다른 작업으로 잘 일반화됨을 보여줍니다.

---

arXiv:1706.03762v7 [cs.CL] 2 Aug 2023

---

arXiv:1706.03762v7 [cs.CL] 2023년 8월 2일

---

$^*$Equal contribution. Listing order is random. Jakob proposed replacing RNNs with self-attention and started the effort to evaluate this idea. Ashish, with Illia, designed and implemented the first Transformer models and has been crucially involved in every aspect of this work. Noam proposed scaled dot-product attention, multi-head attention and the parameter-free position representation and became the other person involved in nearly every detail. Niki designed, implemented, tuned and evaluated countless model variants in our original codebase and tensor2tensor. Llion also experimented with novel model variants, was responsible for our initial codebase, and efficient inference and visualizations. Lukasz and Aidan spent countless long days designing various parts of and implementing tensor2tensor, replacing our earlier codebase, greatly improving results and massively accelerating our research.

$^\dagger$Work performed while at Google Brain.

$^\ddagger$Work performed while at Google Research.

---

$^*$동일한 기여도. 나열된 순서는 무작위입니다. Jakob은 RNN을 자기주의(self-attention)로 대체하는 아이디어를 제안하고, 이 아이디어를 평가하기 위한 작업을 시작했습니다. Ashish는 Illia와 함께 최초의 Transformer 모델을 설계하고 구현했으며, 이 작업의 모든 측면에 핵심적으로 관여했습니다. Noam은 스케일링된 닷-프로덕트 어텐션, 멀티헤드 어텐션 및 파라미터 없는 위치 표현을 제안했고, 거의 모든 세부 사항에 관여한 또 다른 주요 인물입니다. Niki는 원래 코드베이스와 tensor2tensor에서 수없이 많은 모델 변형을 설계, 구현, 튜닝 및 평가했습니다. Llion 또한 새로운 모델 변형에 실험했으며, 초기 코드베이스, 효율적인 추론 및 시각화를 담당했습니다. Lukasz와 Aidan은 tensor2tensor의 다양한 부분을 설계하고 구현하는 데 수많은 긴 날을 보냈으며, 이전 코드베이스를 대체하여 결과를 크게 개선하고 연구 속도를 비약적으로 가속화했습니다.

$^\dagger$Google Brain 재직 중 수행한 연구.

$^\ddagger$Google Research 재직 중 수행한 연구.

---

## 1 Introduction

---

## 1 서론

---

Recurrent neural networks, long short-term memory [13] and gated recurrent [7] neural networks in particular, have been firmly established as state of the art approaches in sequence modeling and transduction problems such as language modeling and machine translation [35, 2, 5]. Numerous efforts have since continued to push the boundaries of recurrent language models and encoder-decoder architectures [38, 24, 15].

Recurrent models typically factor computation along the symbol positions of the input and output sequences. Aligning the positions to steps in computation time, they generate a sequence of hidden states $h_t$, as a function of the previous hidden state $h_{t-1}$ and the input for position $t$. This inherently sequential nature precludes parallelization within training examples, which becomes critical at longer sequence lengths, as memory constraints limit batching across examples. Recent work has achieved significant improvements in computational efficiency through factorization tricks [21] and conditional computation [32], while also improving model performance in case of the latter. The fundamental constraint of sequential computation, however, remains.

Attention mechanisms have become an integral part of compelling sequence modeling and transduction models in various tasks, allowing modeling of dependencies without regard to their distance in the input or output sequences [2, 19]. In all but a few cases [27], however, such attention mechanisms are used in conjunction with a recurrent network.

In this work we propose the Transformer, a model architecture eschewing recurrence and instead relying entirely on an attention mechanism to draw global dependencies between input and output. The Transformer allows for significantly more parallelization and can reach a new state of the art in translation quality after being trained for as little as twelve hours on eight P100 GPUs.

---

순환 신경망, 특히 장기 단기 기억 [13] 및 게이트드 순환 [7] 신경망은 언어 모델링과 기계 번역과 같은 시퀀스 모델링 및 변환 문제에서 최첨단 접근 방식으로 확고히 자리 잡았습니다 [35, 2, 5]. 이후 수많은 연구들이 순환 언어 모델과 인코더-디코더 아키텍처의 한계를 지속적으로 넓혀 왔습니다 [38, 24, 15].

순환 모델은 일반적으로 입력 및 출력 시퀀스의 심볼 위치를 따라 계산을 분할합니다. 계산 시간의 단계에 위치를 정렬함으로써, 이전 은닉 상태 $h_{t-1}$과 위치 $t$의 입력을 함수로 하여 은닉 상태의 시퀀스 $h_t$를 생성합니다. 이러한 본질적으로 순차적인 성질은 학습 예제 내에서의 병렬화를 배제하며, 이는 메모리 제약이 예제 간 배치 처리를 제한하기 때문에 더 긴 시퀀스 길이에서 특히 중요합니다. 최근 연구는 인수분해 트릭 [21]과 조건부 계산 [32]을 통해 계산 효율성을 크게 개선했으며, 후자의 경우 모델 성능도 향상시켰습니다. 그러나 순차적 계산의 근본적인 제약은 여전히 존재합니다.

어텐션 메커니즘은 다양한 작업에서 매력적인 시퀀스 모델링 및 변환 모델의 핵심 부분이 되었으며, 입력 또는 출력 시퀀스 내 거리와 무관하게 의존성을 모델링할 수 있게 해줍니다 [2, 19]. 그러나 대부분의 경우 [27] 어텐션 메커니즘은 순환 네트워크와 함께 사용됩니다.

본 논문에서는 순환을 배제하고 대신 전적으로 어텐션 메커니즘에 의존하여 입력과 출력 간의 전역적 의존성을 추출하는 Transformer라는 모델 아키텍처를 제안합니다. Transformer는 훨씬 더 많은 병렬화를 가능하게 하며, 8개의 P100 GPU에서 단 12시간만 학습해도 번역 품질에서 새로운 최첨단 기록을 달성할 수 있습니다.

---

## 2 Background

---

## 2 배경

---

The goal of reducing sequential computation also forms the foundation of the Extended Neural GPU [16], ByteNet [18] and ConvS2S [9], all of which use convolutional neural networks as basic building block, computing hidden representations in parallel for all input and output positions. In these models, the number of operations required to relate signals from two arbitrary input or output positions grows in the distance between positions, linearly for ConvS2S and logarithmically for ByteNet. This makes it more difficult to learn dependencies between distant positions [12]. In the Transformer this is reduced to a constant number of operations, albeit at the cost of reduced effective resolution due to averaging attention-weighted positions, an effect we counteract with Multi-Head Attention as described in section 3.2.

Self-attention, sometimes called intra-attention is an attention mechanism relating different positions of a single sequence in order to compute a representation of the sequence. Self-attention has been used successfully in a variety of tasks including reading comprehension, abstractive summarization, textual entailment and learning task-independent sentence representations [4, 27, 28, 22].

End-to-end memory networks are based on a recurrent attention mechanism instead of sequence-aligned recurrence and have been shown to perform well on simple-language question answering and language modeling tasks [34].

To the best of our knowledge, however, the Transformer is the first transduction model relying entirely on self-attention to compute representations of its input and output without using sequence-aligned RNNs or convolution. In the following sections, we will describe the Transformer, motivate self-attention and discuss its advantages over models such as [17, 18] and [9].

---

순차적 계산을 줄이는 목표는 Extended Neural GPU [16], ByteNet [18] 및 ConvS2S [9]의 기초를 형성하며, 이들은 모두 합성곱 신경망을 기본 구성 요소로 사용하여 모든 입력 및 출력 위치의 은닉 표현을 병렬로 계산합니다. 이러한 모델에서 두 임의의 입력 또는 출력 위치 간 신호를 연관시키는 데 필요한 연산 수는 위치 간 거리에 따라 증가하며, ConvS2S의 경우 선형적으로, ByteNet의 경우 로그 함수적으로 증가합니다. 이는 먼 위치에 있는 요소들 간의 의존성을 학습하는 것을 더 어렵게 만듭니다 [12]. Transformer에서는 이 문제가 상수 개의 연산으로 줄어들지만, 주의 가중치를 적용한 위치들을 평균화함으로써 유효 해상도가 낮아지는 대가를 치릅니다. 이러한 효과는 3.2절에서 설명하는 Multi-Head Attention으로 상쇄됩니다.

자기 주의(Self-attention)는 때때로 내부 주의(intra-attention)라고 불리며, 단일 시퀀스의 서로 다른 위치들 간의 관계를 설정하여 시퀀스의 표현을 계산하는 주의 메커니즘입니다. 자기 주의는 읽기 이해, 추상적 요약, 텍스트蕴含(텍스트 함의), 그리고 작업 독립적인 문장 표현 학습을 포함한 다양한 작업에서 성공적으로 사용되었습니다 [4, 27, 28, 22].

End-to-end 메모리 네트워크는 시퀀스 정렬 순환 대신 재귀적 주의 메커니즘에 기반하며, 간단한 언어 질문 응답 및 언어 모델링 작업에서 우수한 성능을 보였습니다 [34].

그러나 저희의 지식 범위 내에서 Transformer는 시퀀스 정렬 RNN이나 합성곱을 사용하지 않고 오직 자기 주의에만 의존하여 입력과 출력의 표현을 계산하는 최초의 전도(transduction) 모델입니다. 다음 절들에서는 Transformer를 설명하고, 자기 주의의 동기를 부여하며, [17, 18] 및 [9]와 같은 모델들에 비해 갖는 장점들을 논의할 것입니다.

---

## 3 Model Architecture

---

## 3 모델 아키텍처

---

Most competitive neural sequence transduction models have an encoder-decoder structure [5, 2, 35]. Here, the encoder maps an input sequence of symbol representations $(x_1, ..., x_n)$ to a sequence of continuous representations $\mathbf{z} = (z_1, ..., z_n)$. Given $\mathbf{z}$, the decoder then generates an output sequence $(y_1, ..., y_m)$ of symbols one element at a time. At each step the model is auto-regressive [10], consuming the previously generated symbols as additional input when generating the next.

---

대부분의 경쟁력 있는 신경 시퀀스 전도 모델은 인코더-디코더 구조를 가지고 있다 [5, 2, 35]. 여기서 인코더는 기호 표현들의 입력 시퀀스 $(x_1, ..., x_n)$을 연속적인 표현들의 시퀀스 $\mathbf{z} = (z_1, ..., z_n)$로 매핑한다. $\mathbf{z}$가 주어지면, 디코더는 한 번에 하나의 원소를 생성하여 기호들의 출력 시퀀스 $(y_1, ..., y_m)$을 생성한다. 각 단계에서 모델은 자기회귀적(auto-regressive)이다 [10], 이는 다음을 생성할 때 이전에 생성된 기호들을 추가 입력으로 소비한다는 것을 의미한다.

---

<img src="images/3-1.png" style="zoom:70%; display: block; margin: 0 auto;" />

Figure 1: The Transformer - model architecture.

---

그림 1: Transformer - 모델 아키텍처.

---

The Transformer follows this overall architecture using stacked self-attention and point-wise, fully connected layers for both the encoder and decoder, shown in the left and right halves of Figure 1, respectively.

---

Transformer는 스택된 자기 주의 메커니즘과 지점별 완전 연결 레이어를 인코더와 디코더 모두에 사용하여 전체 아키텍처를 따르며, 이는 각각 그림 1의 왼쪽과 오른쪽 반에서 보여집니다.

---

## 3.1 Encoder and Decoder Stacks

---

## 3.1 인코더와 디코더 스택

---

**Encoder:** The encoder is composed of a stack of $N = 6$ identical layers. Each layer has two sub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, position-wise fully connected feed-forward network. We employ a residual connection [11] around each of the two sub-layers, followed by layer normalization [1]. That is, the output of each sub-layer is $\text{LayerNorm}(x + \text{Sublayer}(x))$, where $\text{Sublayer}(x)$ is the function implemented by the sub-layer itself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding layers, produce outputs of dimension $d_{\text{model}} = 512$.

**Decoder:** The decoder is also composed of a stack of $N = 6$ identical layers. In addition to the two sub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head attention over the output of the encoder stack. Similar to the encoder, we employ residual connections around each of the sub-layers, followed by layer normalization. We also modify the self-attention sub-layer in the decoder stack to prevent positions from attending to subsequent positions. This masking, combined with fact that the output embeddings are offset by one position, ensures that the predictions for position $i$ can depend only on the known outputs at positions less than $i$.

---

**인코더:** 인코더는 $N = 6$개의 동일한 레이어로 구성된 스택으로 이루어져 있습니다. 각 레이어에는 두 개의 하위 레이어가 있습니다. 첫 번째는 다중 헤드 자기 주의 메커니즘이고, 두 번째는 간단한 위치별 완전 연결 순방향 신경망입니다. 우리는 각 하위 레이어 주위에 잔차 연결 [11]을 사용하고, 그 뒤에 계층 정규화 [1]를 적용합니다. 즉, 각 하위 레이어의 출력은 $\text{LayerNorm}(x + \text{Sublayer}(x))$이며, 여기서 $\text{Sublayer}(x)$는 해당 하위 레이어 자체가 구현하는 함수입니다. 이러한 잔차 연결을 용이하게 하기 위해 모델 내 모든 하위 레이어와 임베딩 레이어는 차원 $d_{\text{model}} = 512$의 출력을 생성합니다.

**디코더:** 디코더 또한 $N = 6$개의 동일한 레이어로 구성된 스택으로 이루어져 있습니다. 인코더 레이어의 두 하위 레이어 외에도, 디코더는 인코더 스택의 출력에 대해 다중 주의를 수행하는 세 번째 하위 레이어를 삽입합니다. 인코더와 유사하게, 우리는 각 하위 레이어 주위에 잔차 연결을 사용하고 그 뒤에 계층 정규화를 적용합니다. 또한 디코더 스택의 자기 주의 하위 레이어를 수정하여 특정 위치가 이후 위치들에 주의를 기울이는 것을 방지합니다. 이러한 마스킹과 출력 임베딩이 한 위치만큼 오프셋되어 있다는 사실은, 위치 $i$에 대한 예측이 오직 $i$보다 작은 위치들의 알려진 출력에만 의존할 수 있도록 보장합니다.

---

## 3.2 Attention

---

## 3.2 어텐션

---

An attention function can be described as mapping a query and a set of key-value pairs to an output, where the query, keys, values, and output are all vectors. The output is computed as a weighted sum

---

어텐션 함수는 쿼리와 키-값 쌍의 집합을 출력으로 매핑하는 것으로 설명할 수 있으며, 여기서 쿼리, 키, 값 및 출력은 모두 벡터입니다. 출력은 가중 합으로 계산됩니다.

---

<img src="images/4-3.png" style="zoom:70%; display: block; margin: 0 auto;" />

Figure 2: (left) Scaled Dot-Product Attention. (right) Multi-Head Attention consists of several attention layers running in parallel.

---

그림 2: (왼쪽) 스케일된 닷-프로덕트 어텐션. (오른쪽) 멀티-헤드 어텐션은 병렬로 실행되는 여러 어텐션 레이어로 구성됩니다.

---

of the values, where the weight assigned to each value is computed by a compatibility function of the query with the corresponding key.

---

각 값에 할당된 가중치는 쿼리와 해당 키의 호환성 함수를 통해 계산됩니다.

---

## 3.2.1 Scaled Dot-Product Attention

---

## 3.2.1 스케일된 닷-프로덕트 어텐션

---

We call our particular attention "Scaled Dot-Product Attention" (Figure 2). The input consists of queries and keys of dimension $d_k$, and values of dimension $d_v$. We compute the dot products of the query with all keys, divide each by $\sqrt{d_k}$, and apply a softmax function to obtain the weights on the values.

In practice, we compute the attention function on a set of queries simultaneously, packed together into a matrix $Q$. The keys and values are also packed together into matrices $K$ and $V$. We compute the matrix of outputs as:

$$
\text{Attention}(Q, K, V) = \text{softmax}(\frac{QK^T}{\sqrt{d_k}})V \tag{1}
$$

The two most commonly used attention functions are additive attention [2], and dot-product (multiplicative) attention. Dot-product attention is identical to our algorithm, except for the scaling factor of $\frac{1}{\sqrt{d_k}}$. Additive attention computes the compatibility function using a feed-forward network with a single hidden layer. While the two are similar in theoretical complexity, dot-product attention is much faster and more space-efficient in practice, since it can be implemented using highly optimized matrix multiplication code.

While for small values of $d_k$ the two mechanisms perform similarly, additive attention outperforms dot product attention without scaling for larger values of $d_k$ [3]. We suspect that for large values of $d_k$, the dot products grow large in magnitude, pushing the softmax function into regions where it has extremely small gradients $^4$. To counteract this effect, we scale the dot products by $\frac{1}{\sqrt{d_k}}$.

---

우리는 특별한 주의 깊게 "스케일된 닷-곱 어텐션"(Figure 2)을 호출합니다. 입력은 차원이 $d_k$인 쿼리와 키, 그리고 차원이 $d_v$인 값으로 구성됩니다. 우리는 쿼리와 모든 키의 닷 곱을 계산하고, 각각을 $\sqrt{d_k}$로 나눈 후, 소프트맥스 함수를 적용하여 값에 대한 가중치를 얻습니다.

실제로 우리는 일련의 쿼리에 대해 어텐션 함수를 동시에 계산하며, 이를 행렬 $Q$로 함께 포장합니다. 키와 값도 또한 행렬 $K$와 $V$로 함께 포장됩니다. 우리는 출력의 행렬을 다음과 같이 계산합니다:

$$
\text{Attention}(Q, K, V) = \text{softmax}(\frac{QK^T}{\sqrt{d_k}})V \tag{1}
$$

가장 일반적으로 사용되는 두 가지 어텐션 함수는 가법적 어텐션 [2]과 닷-곱(승법적) 어텐션입니다. 닷-곱 어텐션은 스케일링 인자 $\frac{1}{\sqrt{d_k}}$를 제외하면 우리의 알고리즘과 동일합니다. 가법적 어텐션은 단일 은닉층을 가진 순방향 네트워크를 사용하여 호환성 함수를 계산합니다. 이론적 복잡성은 두 방법이 유사하지만, 닷-곱 어텐션은 실제로 훨씬 빠르고 공간 효율적이므로, 고도로 최적화된 행렬 곱셈 코드를 사용하여 구현할 수 있습니다.

$d_k$가 작은 값일 때 두 메커니즘은 비슷한 성능을 보이지만, $d_k$가 큰 값에서는 스케일링 없는 닷-곱 어텐션보다 가법적 어텐션이 더 우수한 성능을 보입니다 [3]. 우리는 $d_k$가 큰 값에서 닷 곱의 크기가 커져서 소프트맥스 함수가 매우 작은 기울기를 갖는 영역으로 밀려난다고 추측합니다 $^4$. 이 효과를 상쇄하기 위해 우리는 닷 곱을 $\frac{1}{\sqrt{d_k}}$로 스케일링합니다.

---

## 3.2.2 Multi-Head Attention

---

## 3.2.2 다중 헤드 어텐션

---

Instead of performing a single attention function with $d_{\text{model}}$-dimensional keys, values and queries, we found it beneficial to linearly project the queries, keys and values $h$ times with different, learned linear projections to $d_k$, $d_k$ and $d_v$ dimensions, respectively. On each of these projected versions of queries, keys and values we then perform the attention function in parallel, yielding $d_v$-dimensional

---

$d_{\text{model}}$ 차원의 키, 값 및 쿼리를 사용하는 단일 어텐션 함수를 수행하는 대신, 우리는 학습된 서로 다른 선형 프로젝션을 통해 쿼리, 키 및 값을 각각 $d_k$, $d_k$ 및 $d_v$ 차원으로 $h$번 선형적으로 투영하는 것이 유익함을 발견했습니다. 그런 다음 이러한 투영된 버전의 쿼리, 키 및 값 각각에 대해 병렬로 어텐션 함수를 수행하여 $d_v$ 차원의 결과를 얻습니다.

---

$^4$To illustrate why the dot products get large, assume that the components of $q$ and $k$ are independent random variables with mean 0 and variance 1. Then their dot product, $q \cdot k = \sum_{i=1}^{d_k} q_i k_i$, has mean 0 and variance $d_k$.

---

$^4$q와 k의 성분이 평균이 0이고 분산이 1인 독립적인 확률 변수라고 가정하면, 내적 $q \cdot k = \sum_{i=1}^{d_k} q_i k_i$는 평균이 0이고 분산이 $d_k$가 됩니다. 이는 내적 값이 커지는 이유를 설명하기 위한 것입니다.

---

output values. These are concatenated and once again projected, resulting in the final values, as depicted in Figure 2.

Multi-head attention allows the model to jointly attend to information from different representation subspaces at different positions. With a single attention head, averaging inhibits this.

$$
\begin{align}
&\text{MultiHead}(Q, K, V) = \text{Concat}(\text{head}_1, ..., \text{head}_{\text{h}})W^O \tag{*}\\
&\text{where head}_i = \text{Attention}(QW_i^Q, KW_i^K, VW_i^V) \tag{*}
\end{align}
$$

Where the projections are parameter matrices $W_i^Q \in \mathbb{R}^{d_{\text{model}} \times d_k}$, $W_i^K \in \mathbb{R}^{d_{\text{model}} \times d_k}$, $W_i^V \in \mathbb{R}^{d_{\text{model}} \times d_v}$ and $W^O \in \mathbb{R}^{hd_v \times d_{\text{model}}}$.

In this work we employ $h = 8$ parallel attention layers, or heads. For each of these we use $d_k = d_v = d_{\text{model}}/h = 64$. Due to the reduced dimension of each head, the total computational cost is similar to that of single-head attention with full dimensionality.

---

출력 값들이다. 이들은 연결된 후 다시 투영되어 최종 값을 생성하며, 이는 그림 2에 도시되어 있다.

멀티헤드 어텐션은 모델이 서로 다른 위치에서 서로 다른 표현 부분 공간으로부터의 정보를 함께 주시할 수 있게 한다. 단일 어텐션 헤드를 사용하면 평균화가 이를 저해한다.

$$
\begin{align}
&\text{MultiHead}(Q, K, V) = \text{Concat}(\text{head}_1, ..., \text{head}_{\text{h}})W^O \tag{*}\\
&\text{where head}_i = \text{Attention}(QW_i^Q, KW_i^K, VW_i^V) \tag{*}
\end{align}
$$

여기서 투영은 매개변수 행렬 $W_i^Q \in \mathbb{R}^{d_{\text{model}} \times d_k}$, $W_i^K \in \mathbb{R}^{d_{\text{model}} \times d_k}$, $W_i^V \in \mathbb{R}^{d_{\text{model}} \times d_v}$ 및 $W^O \in \mathbb{R}^{hd_v \times d_{\text{model}}}$이다.

본 연구에서는 병렬 어텐션 레이어 또는 헤드 $h = 8$개를 사용한다. 각각의 경우에 대해 $d_k = d_v = d_{\text{model}}/h = 64$를 사용한다. 각 헤드의 차원이 감소했으므로, 전체 계산 비용은 완전한 차원을 가진 단일 헤드 어텐션과 유사하다.

---

## 3.2.3 Applications of Attention in our Model

---

## 3.2.3 모델에서의 어텐션 적용

---

The Transformer uses multi-head attention in three different ways:

*   In "encoder-decoder attention" layers, the queries come from the previous decoder layer, and the memory keys and values come from the output of the encoder. This allows every position in the decoder to attend over all positions in the input sequence. This mimics the typical encoder-decoder attention mechanisms in sequence-to-sequence models such as [38, 2, 9].
*   The encoder contains self-attention layers. In a self-attention layer all of the keys, values and queries come from the same place, in this case, the output of the previous layer in the encoder. Each position in the encoder can attend to all positions in the previous layer of the encoder.
*   Similarly, self-attention layers in the decoder allow each position in the decoder to attend to all positions in the decoder up to and including that position. We need to prevent leftward information flow in the decoder to preserve the auto-regressive property. We implement this inside of scaled dot-product attention by masking out (setting to $-\infty$) all values in the input of the softmax which correspond to illegal connections. See Figure 2.

---

Transformer는 세 가지 다른 방식으로 멀티헤드 어텐션을 사용합니다:

*   "인코더-디코더 어텐션" 레이어에서는 쿼리가 이전 디코더 레이어에서 나오고, 메모리 키와 값은 인코더의 출력에서 나옵니다. 이를 통해 디코더의 모든 위치가 입력 시퀀스의 모든 위치에 대해 어텐션할 수 있습니다. 이는 [38, 2, 9]와 같은 시퀀스-투-시퀀스 모델의 일반적인 인코더-디코더 어텐션 메커니즘을 모방한 것입니다.
*   인코더에는 셀프 어텐션 레이어가 포함되어 있습니다. 셀프 어텐션 레이어에서는 모든 키, 값 및 쿼리가 동일한 소스에서 나오며, 이 경우 인코더 내 이전 레이어의 출력에서 나옵니다. 인코더의 각 위치는 인코더의 이전 레이어에 있는 모든 위치에 대해 어텐션할 수 있습니다.
*   마찬가지로, 디코더의 셀프 어텐션 레이어는 디코더의 각 위치가 해당 위치를 포함하여 디코더의 모든 위치에 대해 어텐션할 수 있도록 합니다. 오토레그ressive 속성을 유지하기 위해 디코더에서의 좌측 정보 흐름을 방지해야 합니다. 우리는 스케일된 닷 프로덕트 어텐션 내에서 이를 구현하며, 소프트맥스의 입력에서 불법 연결에 해당하는 모든 값을 마스킹(즉, $-\infty$로 설정)합니다. 그림 2를 참조하십시오.

---

## 3.3 Position-wise Feed-Forward Networks

---

## 3.3 위치별 피드포워드 네트워크

---

In addition to attention sub-layers, each of the layers in our encoder and decoder contains a fully connected feed-forward network, which is applied to each position separately and identically. This consists of two linear transformations with a ReLU activation in between.

$$
\text{FFN}(x) = \max(0, xW_1 + b_1)W_2 + b_2 \tag{2}
$$

While the linear transformations are the same across different positions, they use different parameters from layer to layer. Another way of describing this is as two convolutions with kernel size 1. The dimensionality of input and output is $d_{\text{model}} = 512$, and the inner-layer has dimensionality $d_{ff} = 2048$.

---

어텐션 하위 레이어 외에도, 인코더와 디코더의 각 레이어에는 완전히 연결된 순방향 피드포워드 네트워크가 포함되어 있으며, 이는 각 위치별로 독립적이고 동일하게 적용됩니다. 여기서는 두 개의 선형 변환 사이에 ReLU 활성화 함수가 사용됩니다.

$$
\text{FFN}(x) = \max(0, xW_1 + b_1)W_2 + b_2 \tag{2}
$$

선형 변환은 서로 다른 위치에서 동일하지만, 레이어 간에는 서로 다른 매개변수를 사용합니다. 이를 커널 크기가 1인 두 개의 합성곱 연산으로 설명할 수도 있습니다. 입력과 출력의 차원은 $d_{\text{model}} = 512$이며, 내부 레이어의 차원은 $d_{ff} = 2048$입니다.

---

## 3.4 Embeddings and Softmax

---

## 3.4 임베딩과 소프트맥스

---

Similarly to other sequence transduction models, we use learned embeddings to convert the input tokens and output tokens to vectors of dimension $d_{\text{model}}$. We also use the usual learned linear transformation and softmax function to convert the decoder output to predicted next-token probabilities. In our model, we share the same weight matrix between the two embedding layers and the pre-softmax linear transformation, similar to [30]. In the embedding layers, we multiply those weights by $\sqrt{d_{\text{model}}}$.

---

다른 시퀀스 전도 모델들과 마찬가지로, 우리는 학습된 임베딩을 사용하여 입력 토큰과 출력 토큰을 차원 $d_{\text{model}}$의 벡터로 변환합니다. 또한 디코더 출력을 예측된 다음 토큰 확률로 변환하기 위해 일반적인 학습된 선형 변환과 소프트맥스 함수를 사용합니다. 우리의 모델에서는 두 임베딩 레이어와 소프트맥스 전처리 선형 변환 간에 동일한 가중치 행렬을 공유하며, 이는 [30]에서와 유사합니다. 임베딩 레이어에서는 해당 가중치를 $\sqrt{d_{\text{model}}}$ 곱합니다.

---

Table 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations for different layer types. $n$ is the sequence length, $d$ is the representation dimension, $k$ is the kernel size of convolutions and $r$ the size of the neighborhood in restricted self-attention.

---

표 1: 서로 다른 레이어 유형에 대한 최대 경로 길이, 레이어별 복잡도 및 최소 순차 연산 수. $n$은 시퀀스 길이, $d$는 표현 차원, $k$는 합성곱의 커널 크기, $r$은 제한된 자기 주의에서 이웃의 크기를 나타냅니다.

---

| Layer Type | Complexity per Layer | Sequential Operations | Maximum Path Length |
| :--- | :---: | :---: | :---: |
| Self-Attention | $O(n^2 \cdot d)$ | $O(1)$ | $O(1)$ |
| Recurrent | $O(n \cdot d^2)$ | $O(n)$ | $O(n)$ |
| Convolutional | $O(k \cdot n \cdot d^2)$ | $O(1)$ | $O(log_k(n))$ |
| Self-Attention (restricted) | $O(r \cdot n \cdot d)$ | $O(1)$ | $O(n/r)$ |

---

| 레이어 유형 | 레이어당 복잡도 | 순차적 연산 | 최대 경로 길이 |
| :--- | :---: | :---: | :---: |
| 셀프 어텐션 | $O(n^2 \cdot d)$ | $O(1)$ | $O(1)$ |
| 순환 | $O(n \cdot d^2)$ | $O(n)$ | $O(n)$ |
| 합성곱 | $O(k \cdot n \cdot d^2)$ | $O(1)$ | $O(log_k(n))$ |
| 셀프 어텐션 (제한적) | $O(r \cdot n \cdot d)$ | $O(1)$ | $O(n/r)$ |

---

## 3.5 Positional Encoding

---

## 3.5 위치 인코딩

---

Since our model contains no recurrence and no convolution, in order for the model to make use of the order of the sequence, we must inject some information about the relative or absolute position of the tokens in the sequence. To this end, we add "positional encodings" to the input embeddings at the bottoms of the encoder and decoder stacks. The positional encodings have the same dimension $d_{\text{model}}$ as the embeddings, so that the two can be summed. There are many choices of positional encodings, learned and fixed [9].

In this work, we use sine and cosine functions of different frequencies:

$$
\begin{align}
PE_{(pos,2i)} &= sin(pos/10000^{2i/d_{\text{model}}}) \\
PE_{(pos,2i+1)} &= cos(pos/10000^{2i/d_{\text{model}}})
\end{align}
$$

where $pos$ is the position and $i$ is the dimension. That is, each dimension of the positional encoding corresponds to a sinusoid. The wavelengths form a geometric progression from $2\pi$ to $10000 \cdot 2\pi$. We chose this function because we hypothesized it would allow the model to easily learn to attend by relative positions, since for any fixed offset $k$, $PE_{pos+k}$ can be represented as a linear function of $PE_{pos}$.

We also experimented with using learned positional embeddings [9] instead, and found that the two versions produced nearly identical results (see Table 3 row (E)). We chose the sinusoidal version because it may allow the model to extrapolate to sequence lengths longer than the ones encountered during training.

---

모델에 순환 구조나 합성곱 연산이 포함되어 있지 않으므로, 모델이 시퀀스의 순서를 활용할 수 있도록 토큰의 상대적 또는 절대적 위치에 대한 정보를 주입해야 합니다. 이를 위해 인코더와 디코더 스택 하단의 입력 임베딩에 "위치 인코딩(positional encodings)"을 추가합니다. 위치 인코딩은 임베딩과 동일한 차원 $d_{\text{model}}$을 가지므로 두 값을 더할 수 있습니다. 학습 가능한 방식이나 고정된 방식 등 다양한 위치 인코딩 방법이 존재합니다 [9].

본 연구에서는 서로 다른 주파수를 가진 사인(sin) 및 코사인(cos) 함수를 사용합니다:

$$
\begin{align}
PE_{(pos,2i)} &= sin(pos/10000^{2i/d_{\text{model}}}) \\
PE_{(pos,2i+1)} &= cos(pos/10000^{2i/d_{\text{model}}})
\end{align}
$$

여기서 $pos$는 위치를, $i$는 차원을 나타냅니다. 즉, 위치 인코딩의 각 차원은 하나의 사인곡선에 해당합니다. 파장은 $2\pi$에서 $10000 \cdot 2\pi$까지 기하급수적으로 증가합니다. 우리는 이 함수를 선택했는데, 그 이유는 임의의 고정된 오프셋 $k$에 대해 $PE_{pos+k}$가 $PE_{pos}$의 선형 함수로 표현될 수 있어, 모델이 상대적 위치에 따른 어텐션을 쉽게 학습할 수 있을 것이라고 가정했기 때문입니다.

또한 대신 학습 가능한 위치 임베딩(learned positional embeddings) [9]을 사용하는 실험도 수행했으며, 두 버전 간에 거의 동일한 결과가 도출됨을 확인했습니다 (표 3 행 (E) 참조). 우리는 사인 곡선 기반 버전을 선택했는데, 이는 모델이 훈련 중 관찰된 시퀀스 길이보다 긴 시퀀스 길이에 대해 외삽(extrapolate)할 수 있을 것으로 예상되었기 때문입니다.

---

## 4 Why Self-Attention

---

## 4 자기 주의(Self-Attention)란 무엇인가

---

In this section we compare various aspects of self-attention layers to the recurrent and convolutional layers commonly used for mapping one variable-length sequence of symbol representations $(x_1, ..., x_n)$ to another sequence of equal length $(z_1, ..., z_n)$, with $x_i, z_i \in \mathbb{R}^d$, such as a hidden layer in a typical sequence transduction encoder or decoder. Motivating our use of self-attention we consider three desiderata.

One is the total computational complexity per layer. Another is the amount of computation that can be parallelized, as measured by the minimum number of sequential operations required.

The third is the path length between long-range dependencies in the network. Learning long-range dependencies is a key challenge in many sequence transduction tasks. One key factor affecting the ability to learn such dependencies is the length of the paths forward and backward signals have to traverse in the network. The shorter these paths between any combination of positions in the input and output sequences, the easier it is to learn long-range dependencies [12]. Hence we also compare the maximum path length between any two input and output positions in networks composed of the different layer types.

As noted in Table 1, a self-attention layer connects all positions with a constant number of sequentially executed operations, whereas a recurrent layer requires $O(n)$ sequential operations. In terms of computational complexity, self-attention layers are faster than recurrent layers when the sequence

---

이 섹션에서는 자기 주의(self-attention) 레이어의 다양한 측면을 기호 표현의 가변 길이 시퀀스 $(x_1, ..., x_n)$을 동일한 길이의 다른 시퀀스 $(z_1, ..., z_n)$로 매핑하는 데 일반적으로 사용되는 순환 및 합성곱 레이어와 비교합니다. 여기서 $x_i, z_i \in \mathbb{R}^d$이며, 이는 일반적인 시퀀스 전도 인코더 또는 디코더의 은닉 레이어에 해당합니다. 자기 주의 사용의 동기를 부여하기 위해 우리는 세 가지 바람직한 특성을 고려합니다.

하나는 레이어당 총 계산 복잡도입니다. 또 하나는 최소한의 순차적 연산 수로 측정되는 병렬화할 수 있는 연산량입니다.

세 번째는 네트워크 내 장기 의존성(long-range dependencies) 간의 경로 길이입니다. 장기 의존성을 학습하는 것은 많은 시퀀스 전도 작업에서 핵심적인 과제입니다. 이러한 의존성을 학습하는 능력에 영향을 미치는 주요 요인 중 하나는 순방향 및 역방향 신호가 네트워크를 통과해야 하는 경로의 길이입니다. 입력 및 출력 시퀀스의 임의의 위치 조합 간에 이러한 경로가 짧을수록 장기 의존성을 학습하기 더 쉽습니다 [12]. 따라서 우리는 서로 다른 레이어 유형으로 구성된 네트워크에서 임의의 두 입력 및 출력 위치 간의 최대 경로 길이도 비교합니다.

표 1에서 언급된 바와 같이, 자기 주의 레이어는 일정한 수의 순차적으로 실행되는 연산을 통해 모든 위치를 연결하는 반면, 순환 레이어는 $O(n)$개의 순차적 연산을 필요로 합니다. 계산 복잡도의 관점에서 볼 때, 시퀀스가 길어질 때 자기 주의 레이어는 순환 레이어보다 빠릅니다.

---

length $n$ is smaller than the representation dimensionality $d$, which is most often the case with sentence representations used by state-of-the-art models in machine translations, such as word-piece [38] and byte-pair [31] representations. To improve computational performance for tasks involving very long sequences, self-attention could be restricted to considering only a neighborhood of size $r$ in the input sequence centered around the respective output position. This would increase the maximum path length to $O(n/r)$. We plan to investigate this approach further in future work.

A single convolutional layer with kernel width $k < n$ does not connect all pairs of input and output positions. Doing so requires a stack of $O(n/k)$ convolutional layers in the case of contiguous kernels, or $O(\log_k(n))$ in the case of dilated convolutions [18], increasing the length of the longest paths between any two positions in the network. Convolutional layers are generally more expensive than recurrent layers, by a factor of $k$. Separable convolutions [6], however, decrease the complexity considerably, to $O(k \cdot n \cdot d + n \cdot d^2)$. Even with $k = n$, however, the complexity of a separable convolution is equal to the combination of a self-attention layer and a point-wise feed-forward layer, the approach we take in our model.

As side benefit, self-attention could yield more interpretable models. We inspect attention distributions from our models and present and discuss examples in the appendix. Not only do individual attention heads clearly learn to perform different tasks, many appear to exhibit behavior related to the syntactic and semantic structure of the sentences.

---

길이가 $n$인 경우, 이는 가장 일반적인 상황으로, 단어 조각(word-piece) [38] 및 바이트 쌍 인코딩(byte-pair) [31] 표현과 같은 최신 기계 번역 모델에서 사용되는 문장 표현의 경우, 표현 차원 $d$보다 작습니다. 매우 긴 시퀀스를 다루는 작업에 대한 계산 성능을 개선하기 위해, 자기 주의(self-attention)는 입력 시퀀스에서 해당 출력 위치를 중심으로 크기 $r$의 이웃만 고려하도록 제한할 수 있습니다. 이렇게 하면 최대 경로 길이가 $O(n/r)$로 증가합니다. 우리는 향후 연구에서 이 접근 방식을 더 자세히 조사할 계획입니다.

커널 너비 $k < n$인 단일 합성곱 레이어는 모든 입력 및 출력 위치 쌍을 연결하지 않습니다. 이를 달성하려면 연속적인 커널의 경우 $O(n/k)$개의 합성곱 레이어 스택이 필요하거나, 팽창 합성곱(dilated convolutions) [18]의 경우 $O(\log_k(n))$개의 레이어가 필요하며, 이는 네트워크 내 임의의 두 위치 사이의 가장 긴 경로의 길이를 증가시킵니다. 일반적으로 합성곱 레이어는 재귀적 레이어보다 $k$배 더 비쌉니다. 그러나 분리형 합성곱(separable convolutions) [6]은 복잡도를 $O(k \cdot n \cdot d + n \cdot d^2)$로 크게 줄입니다. 그러나 $k = n$인 경우조차도 분리형 합성곱의 복잡도는 자기 주의 레이어와 점별 피드포워드(point-wise feed-forward) 레이어의 조합과 동일하며, 이는 우리가 모델에서 채택한 접근 방식입니다.

부수적인 이점으로, 자기 주의는 더 해석 가능한 모델을 제공할 수 있습니다. 우리는 모델의 주의 분포를 검사하고 부록에서 예시를 제시하며 논의합니다. 개별 주의 헤드(heads)가 명확하게 다른 작업을 수행하는 것을 학습하는 것뿐만 아니라, 많은 주드가 문장의 구문론적 및 의미론적 구조와 관련된 행동을 나타내는 것으로 보입니다.

---

## 5 Training

---

## 5 훈련

---

This section describes the training regime for our models.

---

이 섹션에서는 우리 모델의 학습 방식을 설명합니다.

---

## 5.1 Training Data and Batching

---

## 5.1 학습 데이터 및 배치

---

We trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million sentence pairs. Sentences were encoded using byte-pair encoding [3], which has a shared source-target vocabulary of about 37000 tokens. For English-French, we used the significantly larger WMT 2014 English-French dataset consisting of 36M sentences and split tokens into a 32000 word-piece vocabulary [38]. Sentence pairs were batched together by approximate sequence length. Each training batch contained a set of sentence pairs containing approximately 25000 source tokens and 25000 target tokens.

---

우리는 약 450만 문장 쌍으로 구성된 표준 WMT 2014 영어-독일어 데이터셋에서 학습했다. 문장은 바이트 페어 인코딩(byte-pair encoding) [3]을 사용하여 인코딩되었으며, 이는 약 37,000개의 토큰을 공유하는 소스-타겟 어휘를 사용한다. 영어-프랑스어의 경우, 3600만 문장으로 구성된 훨씬 더 큰 WMT 2014 영어-프랑스어 데이터셋을 사용했으며, 토큰을 32,000 단어 조각(word-piece) 어휘로 분할했다 [38]. 문장 쌍은 대략적인 시퀀스 길이에 따라 배치(batch)로 묶었다. 각 학습 배치에는 약 25,000개의 소스 토큰과 25,000개의 타겟 토큰을 포함하는 문장 쌍 집합이 포함되어 있었다.

---

## **5.2 Hardware and Schedule**

---

## **5.2 하드웨어 및 일정**

---

We trained our models on one machine with 8 NVIDIA P100 GPUs. For our base models using the hyperparameters described throughout the paper, each training step took about 0.4 seconds. We trained the base models for a total of 100,000 steps or 12 hours. For our big models,(described on the bottom line of table 3), step time was 1.0 seconds. The big models were trained for 300,000 steps (3.5 days).

---

우리는 8개의 NVIDIA P100 GPU를 갖춘 단일 머신에서 모델을 학습했습니다. 논문 전반에 걸쳐 설명된 하이퍼파라미터를 사용한 기본 모델의 경우, 각 학습 단계는 약 0.4초가 소요되었습니다. 기본 모델은 총 100,000단계(12시간) 동안 학습되었습니다. 대형 모델의 경우(표 3 하단 라인에 기술됨), 단계당 시간은 1.0초였습니다. 대형 모델은 300,000단계(3.5일) 동안 학습되었습니다.

---

## 5.3 Optimizer

---

## 5.3 최적화 알고리즘

---

We used the Adam optimizer [20] with $\beta_1 = 0.9$, $\beta_2 = 0.98$ and $\epsilon = 10^{-9}$. We varied the learning rate over the course of training, according to the formula:

$$
lrate = d_{\text{model}}^{-0.5} \cdot \min(step\_num^{-0.5}, step\_num \cdot warmup\_steps^{-1.5}) \tag{3}
$$

This corresponds to increasing the learning rate linearly for the first *warmup_steps* training steps, and decreasing it thereafter proportionally to the inverse square root of the step number. We used $warmup\_steps = 4000$.

---

우리는 $\beta_1 = 0.9$, $\beta_2 = 0.98$ 및 $\epsilon = 10^{-9}$을 사용하여 Adam 최적화 알고리즘 [20]을 적용했습니다. 학습률은 훈련 과정에서 다음 공식에 따라 변경되었습니다:

$$
lrate = d_{\text{model}}^{-0.5} \cdot \min(step\_num^{-0.5}, step\_num \cdot warmup\_steps^{-1.5}) \tag{3}
$$

이는 처음 *warmup_steps* 단계 동안 학습률을 선형적으로 증가시키고, 이후에는 단계 수의 역제곱근에 비례하여 감소시키는 것에 해당합니다. 우리는 $warmup\_steps = 4000$을 사용했습니다.

---

## 5.4 Regularization

---

## 5.4 정규화

---

We employ three types of regularization during training:

---

학습 중에는 세 가지 유형의 정규화를 사용합니다:

---

Table 2: The Transformer achieves better BLEU scores than previous state-of-the-art models on the English-to-German and English-to-French newstest2014 tests at a fraction of the training cost.

---

표 2: Transformer는 영어-독일어 및 영어-프랑스어 newstest2014 테스트에서 이전의 최첨단 모델보다 더 높은 BLEU 점수를 달성했으며, 훈련 비용은 그 일부분에 불과합니다.

---

| Model | EN-DE | EN-FR | EN-DE | EN-FR |
| :--- | :---: | :---: | :---: | :---: |
| ByteNet [18] | 23.75 | | | |
| Deep-Att + PosUnk [39] | | 39.2 | | $1.0 \cdot 10^{20}$ |
| GNMT + RL [38] | 24.6 | 39.92 | $2.3 \cdot 10^{19}$ | $1.4 \cdot 10^{20}$ |
| ConvS2S [9] | 25.16 | 40.46 | $9.6 \cdot 10^{18}$ | $1.5 \cdot 10^{20}$ |
| MoE [32] | 26.03 | 40.56 | $2.0 \cdot 10^{19}$ | $1.2 \cdot 10^{20}$ |
| Deep-Att + PosUnk Ensemble [39] | | 40.4 | | $8.0 \cdot 10^{20}$ |
| GNMT + RL Ensemble [38] | 26.30 | 41.16 | $1.8 \cdot 10^{20}$ | $1.1 \cdot 10^{21}$ |
| ConvS2S Ensemble [9] | 26.36 | **41.29** | $7.7 \cdot 10^{19}$ | $1.2 \cdot 10^{21}$ |
| Transformer (base model) | 27.3 | 38.1 | $\mathbf{3.3 \cdot 10^{18}}$ | |
| Transformer (big) | **28.4** | **41.8** | $2.3 \cdot 10^{19}$ | |

**Residual Dropout** We apply dropout [33] to the output of each sub-layer, before it is added to the sub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the positional encodings in both the encoder and decoder stacks. For the base model, we use a rate of $P_{drop} = 0.1$.

---

**잔여 드롭아웃** 각 하위 레이어의 출력에 드롭아웃 [33]을 적용한 후, 이를 하위 레이어 입력에 더하고 정규화합니다. 또한 인코더와 디코더 스택에서 임베딩과 위치 인코딩의 합에도 드롭아웃을 적용합니다. 기본 모델의 경우 $P_{drop} = 0.1$의 드롭아웃 비율을 사용합니다.

---

**Label Smoothing** During training, we employed label smoothing of value $\epsilon_{ls} = 0.1$ [36]. This hurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.

---

**라벨 스무딩** 학습 중 우리는 $\epsilon_{ls} = 0.1$ 값의 라벨 스무딩을 사용했습니다 [36]. 이는 모델이 더 불확실해지도록 학습하게 하여 퍼플렉시티(perplexity)에는 부정적인 영향을 미치지만, 정확도와 BLEU 점수는 향상시킵니다.

---

## 6 Results

---

## 6 결과

---

## 6.1 Machine Translation

---

## 6.1 기계 번역

---

On the WMT 2014 English-to-German translation task, the big transformer model (Transformer (big) in Table 2) outperforms the best previously reported models (including ensembles) by more than 2.0 BLEU, establishing a new state-of-the-art BLEU score of 28.4. The configuration of this model is listed in the bottom line of Table 3. Training took 3.5 days on 8 P100 GPUs. Even our base model surpasses all previously published models and ensembles, at a fraction of the training cost of any of the competitive models.

On the WMT 2014 English-to-French translation task, our big model achieves a BLEU score of 41.0, outperforming all of the previously published single models, at less than $1/4$ the training cost of the previous state-of-the-art model. The Transformer (big) model trained for English-to-French used dropout rate $P_{drop} = 0.1$, instead of 0.3.

For the base models, we used a single model obtained by averaging the last 5 checkpoints, which were written at 10-minute intervals. For the big models, we averaged the last 20 checkpoints. We used beam search with a beam size of 4 and length penalty $\alpha = 0.6$ [38]. These hyperparameters were chosen after experimentation on the development set. We set the maximum output length during inference to input length + 50, but terminate early when possible [38].

Table 2 summarizes our results and compares our translation quality and training costs to other model architectures from the literature. We estimate the number of floating point operations used to train a model by multiplying the training time, the number of GPUs used, and an estimate of the sustained single-precision floating-point capacity of each GPU $^5$.

---

WMT 2014 영어-독일어 번역 작업에서 대형 트랜스포머 모델(표 2의 Transformer (big))은 이전에 보고된 최상의 모델들(앙상블 포함)보다 BLEU 점수가 2.0 이상 높게 나타나며, 28.4라는 새로운 최고 기록(BLEU score)을 달성했습니다. 이 모델의 구성은 표 3의 마지막 줄에 나열되어 있습니다. 훈련은 8개의 P100 GPU에서 3.5일 동안 수행되었습니다. 기본 모델조차도 경쟁 모델들의 훈련 비용의 일부로 모든 이전 출판 모델과 앙상블을 능가합니다.

WMT 2014 영어-프랑스어 번역 작업에서 대형 모델은 BLEU 점수 41.0을 달성하여 이전에 출판된 모든 단일 모델을 능가했으며, 이전 최고 기록 모델의 훈련 비용의 $1/4$ 미만으로 이를 달성했습니다. 영어-프랑스어용 Transformer (big) 모델은 드롭아웃 비율이 0.3 대신 $P_{drop} = 0.1$로 설정되었습니다.

기본 모델의 경우, 10분 간격으로 저장된 마지막 5개 체크포인트를 평균한 단일 모델을 사용했습니다. 대형 모델의 경우 마지막 20개 체크포인트를 평균했습니다. 빔 검색을 사용했으며, 빔 크기는 4이고 길이 패널티는 $\alpha = 0.6$ [38]로 설정했습니다. 이러한 하이퍼파라미터들은 개발 세트에서의 실험을 통해 선택되었습니다. 추론 시 최대 출력 길이는 입력 길이 + 50으로 설정했지만, 가능한 경우 조기 종료를 적용했습니다 [38].

표 2는 우리의 결과를 요약하고, 문헌에서 제시된 다른 모델 아키텍처들과 비교하여 번역 품질과 훈련 비용을 보여줍니다. 모델 훈련에 사용된 부동 소수점 연산 횟수는 훈련 시간, 사용된 GPU 수, 그리고 각 GPU의 지속 가능한 단정밀도 부동 소수점 성능 추정치를 곱하여 추정합니다 $^5$.

---

## 6.2 Model Variations

---

## 6.2 모델 변형

---

To evaluate the importance of different components of the Transformer, we varied our base model in different ways, measuring the change in performance on English-to-German translation on the

---

Transformer의 다양한 구성 요소의 중요도를 평가하기 위해, 우리는 기본 모델을 다양한 방식으로 변형시켰으며, 영어에서 독일어로의 번역 작업에서의 성능 변화를 측정했습니다.

---

$^5$We used values of 2.8, 3.7, 6.0 and 9.5 TFLOPS for K80, K40, M40 and P100, respectively.

---

$^5$K80, K40, M40 및 P100에 대해 각각 2.8, 3.7, 6.0 및 9.5 TFLOPS의 값을 사용했습니다.

---

Table 3: Variations on the Transformer architecture. Unlisted values are identical to those of the base model. All metrics are on the English-to-German translation development set, newstest2013. Listed perplexities are per-wordpiece, according to our byte-pair encoding, and should not be compared to per-word perplexities.

---

표 3: Transformer 아키텍처의 변형. 표에 명시되지 않은 값은 기본 모델과 동일합니다. 모든 지표는 영어-독일어 번역 개발 세트인 newstest2013 기준입니다. 나열된 퍼플렉시티(perplexity)는 바이트 쌍 부호화(byte-pair encoding)에 따른 단어 조각(wordpiece) 단위이며, 단어 단위 퍼플렉시티와는 비교할 수 없습니다.

---

| | $N$ | $d_{\text{model}}$ | $d_{\text{ff}}$ | $h$ | $d_k$ | $d_v$ | $P_{drop}$ | $\epsilon_{ls}$ | train steps | PPL (dev) | BLEU (dev) | params $\times 10^6$ |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| base | 6 | 512 | 2048 | 8 | 64 | 64 | 0.1 | 0.1 | 100K | 4.92 | 25.8 | 65 |
| (A) | | | | 1 | 512 | 512 | | | | 5.29 | 24.9 | |
| | | | | 4 | 128 | 128 | | | | 5.00 | 25.5 | |
| | | | | 16 | 32 | 32 | | | | 4.91 | 25.8 | |
| | | | | 32 | 16 | 16 | | | | 5.01 | 25.4 | |
| (B) | | | | 16 | | | | | | 5.16 | 25.1 | 58 |
| | | | | 32 | | | | | | 5.01 | 25.4 | 60 |
| (C) | 2 | | | | | | | | | 6.11 | 23.7 | 36 |
| | 4 | | | | | | | | | 5.19 | 25.3 | 50 |
| | 8 | | | | | | | | | 4.88 | 25.5 | 80 |
| | | 256 | | | 32 | 32 | | | | 5.75 | 24.5 | 28 |
| | | 1024 | | | 128 | 128 | | | | 4.66 | 26.0 | 168 |
| | | | 1024 | | | | | | | 5.12 | 25.4 | 53 |
| | | | 4096 | | | | | | | 4.75 | 26.2 | 90 |
| (D) | | | | | | | 0.0 | | | 5.77 | 24.6 | |
| | | | | | | | 0.2 | | | 4.95 | 25.5 | |
| | | | | | | | | 0.0 | | 4.67 | 25.3 | |
| | | | | | | | | 0.2 | | 5.47 | 25.7 | |
| (E) | | positional embedding instead of sinusoids | | | | | | | | 4.92 | 25.7 | |
| big | 6 | 1024 | 4096 | 16 | | | 0.3 | | 300K | **4.33** | **26.4** | 213 |

development set, newstest2013. We used beam search as described in the previous section, but no checkpoint averaging. We present these results in Table 3.

In Table 3 rows (A), we vary the number of attention heads and the attention key and value dimensions, keeping the amount of computation constant, as described in Section 3.2.2. While single-head attention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.

In Table 3 rows (B), we observe that reducing the attention key size $d_k$ hurts model quality. This suggests that determining compatibility is not easy and that a more sophisticated compatibility function than dot product may be beneficial. We further observe in rows (C) and (D) that, as expected, bigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our sinusoidal positional encoding with learned positional embeddings [9], and observe nearly identical results to the base model.

---

개발 세트는 newstest2013입니다. 이전 섹션에서 설명한 대로 빔 서치를 사용했지만, 체크포인트 평균화는 수행하지 않았습니다. 이러한 결과는 표 3에 제시합니다.

표 3의 행 (A)에서는 계산량을 일정하게 유지하면서(섹션 3.2.2에서 설명함), 어텐션 헤드 수와 어텐션 키 및 값 차원을 변화시켰습니다. 단일 헤드 어텐션은 최상의 설정보다 BLEU 점수가 0.9 낮았으며, 헤드가 너무 많을 경우 품질도 저하되는 것을 알 수 있습니다.

표 3의 행 (B)에서는 어텐션 키 크기 $d_k$를 줄이면 모델 품질이 저하됨을 관찰했습니다. 이는 호환성을 결정하기가 쉽지 않으며, 내적(dot product)보다 더 정교한 호환성 함수가 유익할 수 있음을 시사합니다. 또한 행 (C)와 (D)에서 예상대로 더 큰 모델이 더 나은 성능을 보였으며, 드롭아웃이 과적합을 방지하는 데 매우 효과적임을 확인했습니다. 행 (E)에서는 사인파 위치 인코딩을 학습 가능한 위치 임베딩 [9]로 대체했으며, 기본 모델과 거의 동일한 결과를 관찰했습니다.

---

## 6.3 English Constituency Parsing

---

## 6.3 영어 구문 분석

---

To evaluate if the Transformer can generalize to other tasks we performed experiments on English constituency parsing. This task presents specific challenges: the output is subject to strong structural constraints and is significantly longer than the input. Furthermore, RNN sequence-to-sequence models have not been able to attain state-of-the-art results in small-data regimes [37].

We trained a 4-layer transformer with $d_{model} = 1024$ on the Wall Street Journal (WSJ) portion of the Penn Treebank [25], about 40K training sentences. We also trained it in a semi-supervised setting, using the larger high-confidence and BerkleyParser corpora from with approximately 17M sentences [37]. We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens for the semi-supervised setting.

We performed only a small number of experiments to select the dropout, both attention and residual (section 5.4), learning rates and beam size on the Section 22 development set, all other parameters remained unchanged from the English-to-German base translation model. During inference, we

---

Transformer가 다른 작업으로 일반화될 수 있는지 평가하기 위해 영어 구문 분석(constituency parsing) 실험을 수행했습니다. 이 작업은 특정 과제를 제시합니다: 출력은 강한 구조적 제약의 영향을 받으며 입력보다 훨씬 깁니다. 또한 RNN 순차-순간(sequence-to-sequence) 모델은 소규모 데이터 환경에서 최상위 결과를 달성하지 못했습니다 [37].

우리는 Penn Treebank [25]의 Wall Street Journal (WSJ) 부분인 약 40K 문장의 훈련 데이터를 사용하여 $d_{model} = 1024$ 크기의 4층 Transformer를 학습했습니다. 또한, 약 17M 문장을 포함하는 더 큰 고신뢰도 및 BerkleyParser 코퍼스 [37]를 사용하여 반지도(semi-supervised) 설정에서도 학습했습니다. WSJ 전용 설정에서는 16K 토큰의 어휘를 사용했고, 반지도 설정에서는 32K 토큰의 어휘를 사용했습니다.

우리는 Section 22 개발 세트에서 드롭아웃(주의와 잔여 연결 모두, 섹션 5.4 참조), 학습률 및 빔 크기 등을 선택하기 위해 소수의 실험만 수행했으며, 나머지 모든 파라미터는 영어-독일어 기본 번역 모델과 동일하게 유지되었습니다. 추론 동안 우리는

---

Table 4: The Transformer generalizes well to English constituency parsing (Results are on Section 23 of WSJ)

---

표 4: Transformer는 영어 구성 구문 분석에 잘 일반화됩니다 (결과는 WSJ의 섹션 23 기준)

---

| Parser | Training | WSJ 23 F1 |
| :---: | :---: | :---: |
| Vinyals & Kaiser el al. (2014) [37] | WSJ only, discriminative | 88.3 |
| Petrov et al. (2006) [29] | WSJ only, discriminative | 90.4 |
| Zhu et al. (2013) [40] | WSJ only, discriminative | 90.4 |
| Dyer et al. (2016) [8] | WSJ only, discriminative | 91.7 |
| Transformer (4 layers) | WSJ only, discriminative | 91.3 |
| Zhu et al. (2013) [40] | semi-supervised | 91.3 |
| Huang & Harper (2009) [14] | semi-supervised | 91.3 |
| McClosky et al. (2006) [26] | semi-supervised | 92.1 |
| Vinyals & Kaiser el al. (2014) [37] | semi-supervised | 92.1 |
| Transformer (4 layers) | semi-supervised | 92.7 |
| Luong et al. (2015) [23] | multi-task | 93.0 |
| Dyer et al. (2016) [8] | generative | 93.3 |

---

| 구문 분석기 | 학습 | WSJ 23 F1 |
| :---: | :---: | :---: |
| Vinyals & Kaiser et al. (2014) [37] | WSJ 전용, 판별적 | 88.3 |
| Petrov et al. (2006) [29] | WSJ 전용, 판별적 | 90.4 |
| Zhu et al. (2013) [40] | WSJ 전용, 판별적 | 90.4 |
| Dyer et al. (2016) [8] | WSJ 전용, 판별적 | 91.7 |
| Transformer (4층) | WSJ 전용, 판별적 | 91.3 |
| Zhu et al. (2013) [40] | 반지도 학습 | 91.3 |
| Huang & Harper (2009) [14] | 반지도 학습 | 91.3 |
| McClosky et al. (2006) [26] | 반지도 학습 | 92.1 |
| Vinyals & Kaiser et al. (2014) [37] | 반지도 학습 | 92.1 |
| Transformer (4층) | 반지도 학습 | 92.7 |
| Luong et al. (2015) [23] | 다중 작업 | 93.0 |
| Dyer et al. (2016) [8] | 생성적 | 93.3 |

---

increased the maximum output length to input length + 300. We used a beam size of 21 and $\alpha = 0.3$ for both WSJ only and the semi-supervised setting.

Our results in Table 4 show that despite the lack of task-specific tuning our model performs surprisingly well, yielding better results than all previously reported models with the exception of the Recurrent Neural Network Grammar [8].

In contrast to RNN sequence-to-sequence models [37], the Transformer outperforms the Berkeley-Parser [29] even when training only on the WSJ training set of 40K sentences.

---

최대 출력 길이를 입력 길이 + 300로 증가시켰습니다. WSJ 전용 및 준감독 학습 설정 모두에서 빔 크기는 21, $\alpha = 0.3$을 사용했습니다.

표 4의 결과는 작업 특화 튜닝이 없음에도 불구하고 모델이 놀라울 정도로 잘 수행되어, 순환 신경망 문법[8]을 제외한 기존 보고된 모든 모델보다 더 나은 결과를 보여준다는 것을 나타냅니다.

순환 신경망 시퀀스-투-시퀀스 모델[37]과 달리, 트랜스포머는 4만 문장의 WSJ 학습 세트만으로 학습하더라도 Berkeley-Parser[29]를 능가합니다.

---

## 7 Conclusion

---

## 7 결론

---

In this work, we presented the Transformer, the first sequence transduction model based entirely on attention, replacing the recurrent layers most commonly used in encoder-decoder architectures with multi-headed self-attention.

For translation tasks, the Transformer can be trained significantly faster than architectures based on recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014 English-to-French translation tasks, we achieve a new state of the art. In the former task our best model outperforms even all previously reported ensembles.

We are excited about the future of attention-based models and plan to apply them to other tasks. We plan to extend the Transformer to problems involving input and output modalities other than text and to investigate local, restricted attention mechanisms to efficiently handle large inputs and outputs such as images, audio and video. Making generation less sequential is another research goals of ours.

The code we used to train and evaluate our models is available at https://github.com/tensorflow/tensor2tensor.

**Acknowledgements** We are grateful to Nal Kalchbrenner and Stephan Gouws for their fruitful comments, corrections and inspiration.

---

본 연구에서는 어텐션(attention) 기반의 첫 번째 시퀀스 전도(sequence transduction) 모델인 Transformer를 제시하였습니다. 이는 인코더-디코더 구조에서 가장 일반적으로 사용되는 재귀적(recurrent) 레이어를 다중 헤드 자기 어텐션(multi-headed self-attention)으로 대체했습니다.

번역 작업에서 Transformer는 재귀적 또는 합성곱(convolutional) 레이어 기반 아키텍처보다 훨씬 빠르게 학습할 수 있습니다. WMT 2014 영어-독일어 및 WMT 2014 영어-프랑스어 번역 작업 모두에서 새로운 최첨단 성능을 달성했습니다. 전자 작업에서 우리의 최적 모델은 이전에 보고된 모든 앙상블 모델을 능가합니다.

우리는 어텐션 기반 모델의 미래에 대해 기대하며, 이를 다른 작업에도 적용할 계획입니다. 텍스트가 아닌 입력 및 출력 모달리티를 다루는 문제로 Transformer를 확장하고, 이미지, 오디오, 비디오와 같은 대규모 입력과 출력을 효율적으로 처리하기 위해 국소적이고 제한된 어텐션 메커니즘을 조사할 예정입니다. 생성 과정을 덜 순차적으로 만드는 것도 우리의 주요 연구 목표 중 하나입니다.

우리가 모델을 훈련하고 평가하는 데 사용한 코드는 https://github.com/tensorflow/tensor2tensor 에서 확인할 수 있습니다.

**감사의 글** 우리는 Nal Kalchbrenner와 Stephan Gouws에게 유용한 의견, 수정 사항 및 영감을 제공해 주신 것에 감사드립니다.

---

## References

---

## 참고문헌

---

[1] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. *arXiv preprint arXiv:1607.06450*, 2016.

[2] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. *CoRR*, abs/1409.0473, 2014.

[3] Denny Britz, Anna Goldie, Minh-Thang Luong, and Quoc V. Le. Massive exploration of neural machine translation architectures. *CoRR*, abs/1703.03906, 2017.

[4] Jianpeng Cheng, Li Dong, and Mirella Lapata. Long short-term memory-networks for machine reading. *arXiv preprint arXiv:1601.06733*, 2016.

---

[1] Jimmy Lei Ba, Jamie Ryan Kiros, Geoffrey E Hinton. 계층 정규화. *arXiv 미리보기 arXiv:1607.06450*, 2016.

[2] Dzmitry Bahdanau, Kyunghyun Cho, Yoshua Bengio. 정렬과 번역을 함께 학습하는 신경 기계 번역. *CoRR*, abs/1409.0473, 2014.

[3] Denny Britz, Anna Goldie, Minh-Thang Luong, Quoc V. Le. 신경 기계 번역 아키텍처의 대규모 탐색. *CoRR*, abs/1703.03906, 2017.

[4] Jianpeng Cheng, Li Dong, Mirella Lapata. 기계 읽기를 위한 장기 단기 기억 네트워크. *arXiv 미리보기 arXiv:1601.06733*, 2016.

---

[5] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk, and Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical machine translation. *CoRR*, abs/1406.1078, 2014.

[6] Francois Chollet. Xception: Deep learning with depthwise separable convolutions. *arXiv preprint arXiv:1610.02357*, 2016.

[7] Junyoung Chung, Çağlar Gülçehre, Kyunghyun Cho, and Yoshua Bengio. Empirical evaluation of gated recurrent neural networks on sequence modeling. *CoRR*, abs/1412.3555, 2014.

[8] Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, and Noah A. Smith. Recurrent neural network grammars. In *Proc. of NAACL*, 2016.

[9] Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. Convolutional sequence to sequence learning. *arXiv preprint arXiv:1705.03122v2*, 2017.

[10] Alex Graves. Generating sequences with recurrent neural networks. *arXiv preprint arXiv:1308.0850*, 2013.

[11] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In *Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition*, pages 770–778, 2016.

[12] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber. Gradient flow in recurrent nets: the difficulty of learning long-term dependencies, 2001.

[13] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. *Neural computation*, 9(8):1735–1780, 1997.

[14] Zhongqiang Huang and Mary Harper. Self-training PCFG grammars with latent annotations across languages. In *Proceedings of the 2009 Conference on Empirical Methods in Natural Language Processing*, pages 832–841. ACL, August 2009.

[15] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring the limits of language modeling. *arXiv preprint arXiv:1602.02410*, 2016.

[16] Łukasz Kaiser and Samy Bengio. Can active memory replace attention? In *Advances in Neural Information Processing Systems, (NIPS)*, 2016.

[17] Łukasz Kaiser and Ilya Sutskever. Neural GPUs learn algorithms. In *International Conference on Learning Representations (ICLR)*, 2016.

[18] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Koray Kavukcuoglu. Neural machine translation in linear time. *arXiv preprint arXiv:1610.10099v2*, 2017.

[19] Yoon Kim, Carl Denton, Luong Hoang, and Alexander M. Rush. Structured attention networks. In *International Conference on Learning Representations*, 2017.

[20] Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In *ICLR*, 2015.

[21] Oleksii Kuchaiev and Boris Ginsburg. Factorization tricks for LSTM networks. *arXiv preprint arXiv:1703.10722*, 2017.

[22] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen Zhou, and Yoshua Bengio. A structured self-attentive sentence embedding. *arXiv preprint arXiv:1703.03130*, 2017.

[23] Minh-Thang Luong, Quoc V. Le, Ilya Sutskever, Oriol Vinyals, and Lukasz Kaiser. Multi-task sequence to sequence learning. *arXiv preprint arXiv:1511.06114*, 2015.

[24] Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-based neural machine translation. *arXiv preprint arXiv:1508.04025*, 2015.

---

[5] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk, Yoshua Bengio. 통계적 기계 번역을 위한 RNN 인코더-디코더를 사용한 구문 표현 학습. *CoRR*, abs/1406.1078, 2014.

[6] Francois Chollet. Xception: 심층 separable 합성곱을 이용한 딥러닝. *arXiv 사전 인쇄 arXiv:1610.02357*, 2016.

[7] Junyoung Chung, Çağlar Gülçehre, Kyunghyun Cho, Yoshua Bengio. 순차 모델링에 대한 게이트된 순환 신경망의 경험적 평가. *CoRR*, abs/1412.3555, 2014.

[8] Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, Noah A. Smith. 순환 신경망 문법. In *NAACL 발표록*, 2016.

[9] Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, Yann N. Dauphin. 컨볼루션 순차-순차 학습. *arXiv 사전 인쇄 arXiv:1705.03122v2*, 2017.

[10] Alex Graves. 순환 신경망을 이용한 시퀀스 생성. *arXiv 사전 인쇄 arXiv:1308.0850*, 2013.

[11] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun. 이미지 인식을 위한 심층 잔여 학습. In *IEEE 컴퓨터 비전 및 패턴 인식 회의Proceedings*, 페이지 770–778, 2016.

[12] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, Jürgen Schmidhuber. 순환 네트워크에서의 기울기 흐름: 장기 의존성 학습의 어려움, 2001.

[13] Sepp Hochreiter, Jürgen Schmidhuber. 장기 단기 기억. *신경 계산*, 9(8):1735–1780, 1997.

[14] Zhongqiang Huang, Mary Harper. 언어 간 잠재 주석을 사용한 자기 훈련 PCFG 문법. In *2009 자연어 처리 실험 방법 ConferenceProceedings*, 페이지 832–841. ACL, 2009년 8월.

[15] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, Yonghui Wu. 언어 모델링의 한계 탐색. *arXiv 사전 인쇄 arXiv:1602.02410*, 2016.

[16] Łukasz Kaiser, Samy Bengio. 활성 메모리가 어텐션을 대체할 수 있는가? In *신경 정보 처리 시스템 진보(NIPS)*, 2016.

[17] Łukasz Kaiser, Ilya Sutskever. 뉴럴 GPU 알고리즘 학습. In *학습 표현 국제 회의(ICLR)*, 2016.

[18] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, Koray Kavukcuoglu. 선형 시간의 뉴럴 기계 번역. *arXiv 사전 인쇄 arXiv:1610.10099v2*, 2017.

[19] Yoon Kim, Carl Denton, Luong Hoang, Alexander M. Rush. 구조화된 어텐션 네트워크. In *학습 표현 국제 회의*, 2017.

[20] Diederik Kingma, Jimmy Ba. Adam: 확률적 최적화를 위한 방법. In *ICLR*, 2015.

[21] Oleksii Kuchaiev, Boris Ginsburg. LSTM 네트워크를 위한 인수 분해 트릭. *arXiv 사전 인쇄 arXiv:1703.10722*, 2017.

[22] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen Zhou, Yoshua Bengio. 구조화된 자기 주의 문장 임베딩. *arXiv 사전 인쇄 arXiv:1703.03130*, 2017.

[23] Minh-Thang Luong, Quoc V. Le, Ilya Sutskever, Oriol Vinyals, Lukasz Kaiser. 다작업 순서-순서 학습. *arXiv 사전 인쇄 arXiv:1511.06114*, 2015.

[24] Minh-Thang Luong, Hieu Pham, Christopher D Manning. 어텐션 기반 뉴럴 기계 번역을 위한 효과적인 접근법. *arXiv 사전 인쇄 arXiv:1508.04025*, 2015.

---

[25] Mitchell P Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. Building a large annotated corpus of english: The penn treebank. *Computational linguistics*, 19(2):313–330, 1993.

[26] David McClosky, Eugene Charniak, and Mark Johnson. Effective self-training for parsing. In *Proceedings of the Human Language Technology Conference of the NAACL, Main Conference*, pages 152–159. ACL, June 2006.

[27] Ankur Parikh, Oscar Täckström, Dipanjan Das, and Jakob Uszkoreit. A decomposable attention model. In *Empirical Methods in Natural Language Processing*, 2016.

[28] Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive summarization. *arXiv preprint arXiv:1705.04304*, 2017.

[29] Slav Petrov, Leon Barrett, Romain Thibaux, and Dan Klein. Learning accurate, compact, and interpretable tree annotation. In *Proceedings of the 21st International Conference on Computational Linguistics and 44th Annual Meeting of the ACL*, pages 433–440. ACL, July 2006.

[30] Ofir Press and Lior Wolf. Using the output embedding to improve language models. *arXiv preprint arXiv:1608.05859*, 2016.

[31] Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. *arXiv preprint arXiv:1508.07909*, 2015.

[32] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton, and Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts layer. *arXiv preprint arXiv:1701.06538*, 2017.

[33] Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. *Journal of Machine Learning Research*, 15(1):1929–1958, 2014.

[34] Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory networks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors, *Advances in Neural Information Processing Systems 28*, pages 2440–2448. Curran Associates, Inc., 2015.

[35] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. Sequence to sequence learning with neural networks. In *Advances in Neural Information Processing Systems*, pages 3104–3112, 2014.

[36] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. *CoRR*, abs/1512.00567, 2015.

[37] Vinyals & Kaiser, Koo, Petrov, Sutskever, and Hinton. Grammar as a foreign language. In *Advances in Neural Information Processing Systems*, 2015.

[38] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang Macherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Google’s neural machine translation system: Bridging the gap between human and machine translation. *arXiv preprint arXiv:1609.08144*, 2016.

[39] Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. Deep recurrent models with fast-forward connections for neural machine translation. *CoRR*, abs/1606.04199, 2016.

[40] Muhua Zhu, Yue Zhang, Wenliang Chen, Min Zhang, and Jingbo Zhu. Fast and accurate shift-reduce constituent parsing. In *Proceedings of the 51st Annual Meeting of the ACL (Volume 1: Long Papers)*, pages 434–443. ACL, August 2013.

---

<img src="images/13-1.png" style="zoom:70%; display: block; margin: 0 auto;" />

Figure 3: An example of the attention mechanism following long-distance dependencies in the encoder self-attention in layer 5 of 6. Many of the attention heads attend to a distant dependency of the verb ‘making’, completing the phrase ‘making...more difficult’. Attentions here shown only for the word ‘making’. Different colors represent different heads. Best viewed in color.

---

그림 3: 6층 중 5번째 레이어의 인코더 셀프 어텐션에서 장거리 의존성을 따르는 어텐션 메커니즘의 예. 많은 어텐션 헤드들이 동사 ‘making’의 먼 의존성에 주목하여, 구절 ‘making...more difficult’를 완성합니다. 여기서는 단어 ‘making’에 대한 어텐션만 표시됩니다. 서로 다른 색상은 서로 다른 헤드를 나타냅니다. 색상으로 볼 때 가장 잘 이해할 수 있습니다.

---

<img src="images/14-0.png" style="zoom:70%; display: block; margin: 0 auto;" />

Figure 4: Two attention heads, also in layer 5 of 6, apparently involved in anaphora resolution. Top: Full attentions for head 5. Bottom: Isolated attentions from just the word 'its' for attention heads 5 and 6. Note that the attentions are very sharp for this word.

---

그림 4: 레이어 6 중 5번째 레이어에 위치한 두 개의 어텐션 헤드는 명백히 대명사 해석(anaphora resolution)에 관여하고 있다. 위쪽: 헤드 5의 전체 어텐션. 아래쪽: 어텐션 헤드 5와 6에서 단어 'its'로부터 추출된 고립된 어텐션. 이 단어에 대해 어텐션이 매우 날카롭다는 점에 유의하라.

---

<img src="images/15-0.png" style="zoom:70%; display: block; margin: 0 auto;" />

Figure 5: Many of the attention heads exhibit behaviour that seems related to the structure of the sentence. We give two such examples above, from two different heads from the encoder self-attention at layer 5 of 6. The heads clearly learned to perform different tasks.

---

그림 5: 많은 어텐션 헤드들은 문장의 구조와 관련되어 보이는 행동을 보입니다. 위에서 두 가지 예를 제시했는데, 이는 6층 중 5번째 레이어의 인코더 셀프-어텐션에서 서로 다른 두 개의 헤드에서 나온 것입니다. 이 헤드들은 명확히 서로 다른 작업을 수행하도록 학습한 것으로 보입니다.

---
