論文翻譯——Attention Is All You Need


Attention Is All You Need

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.

我們的模型在2014年WMT英德翻譯任務中達到28.4 BLEU,比現有的最佳結果(包括集成部分)提高了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.

在2014年的WMT英法翻譯任務中,我們的模型在8個GPU上進行了3.5天的培訓后,建立了一個新的單模型——最先進的BLEU評分41.8,這只是文獻中最佳模型培訓成本的一小部分。

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 可以很好地將其推廣到其他任務,並成功地將其應用到具有大量和有限訓練數據的英語選民分析中。

1 Introduction

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 models and transduction problems such as language modes and machine translation [35, 2, 5].

遞歸神經網絡,特別是長短時記憶[13]和門控遞歸[7]神經網絡,已經被牢固地建立為最先進的序列模型方法和轉換問題,如語言模式和機器翻譯[35,2,5]。

Numerous efforts have since continued to push the boundaries of recurrent language models and encoder-decoder architectures [38, 24, 15].

從那以后,無數的努力繼續推動循環語言模型和編解碼器架構的邊界[38,24,15]。

Equal contribution. Listing order is random.

平等的貢獻。列表順序是隨機的。

Jakob proposed replacing RNNs with self-attention and started the effort to evaluate this idea.

Jakob建議用自我關注代替RNNs,並開始努力評估這個想法。

Ashish, with Illia, designed and implemented the first Transformer models and has been crucially involved in every aspect of this work.

Ashish與Illia一起設計並實現了第一個Transformer模型,並參與了這項工作的各個方面。

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.

Noam提出了縮放的點產品注意力、多頭注意力和無參數的位置表示,並成為幾乎涉及每個細節的另一個人。

Niki designed, implemented, tuned and evaluated countless model variants in our original codebase and tensor2tensor.

Niki在我們最初的代碼庫和tensor2tensor中設計、實現、調整和評估了無數的模型變體。

Llion also experimented with novel model variants, was responsible for our initial codebase, and efficient inference and visualizations.

Llion還試驗了新的模型變體,負責我們的初始代碼庫,以及有效的推理和可視化。

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.

Lukasz和Aidan花費了無數漫長的日子來設計和實現tensor2tensor的各個部分,替換我們早期的代碼庫,極大地改進了結果並極大地加速了我們的研究。

Work performed while at Google Brain.

Work performed while at Google Research.

31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA.

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.

將計算時間內的位置與步驟對齊,生成一個隱藏狀態序列h_t,作為前一個隱藏狀態h_t-1和位置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.

最近的工作已經通過因數分解技巧[21]和條件計算[32]在計算效率方面取得了顯著的改進,同時也提高了針對后者的模型性能。

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].

在各種任務中,注意力機制已經成為引人注目的序列建模和轉換模型的組成部分,允許對依賴項進行建模,而不考慮它們在輸入或輸出序列中的距離[2,19]。

In all but a few cases [27], however, such attention mechanisms are used in conjunction with a recurrent network.

然而,除了少數情況外,在所有[27]中,這種注意機制都與一個遞歸網絡一起使用。

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.

在這項工作中,我們提出了Transformer,一種避免遞歸的模型架構,而是完全依賴於一種注意力機制來繪制輸入和輸出之間的全局依賴關系。

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

Transformer 允許更多的並行化,在8個P100 gpu上訓練12個小時后,可以達到翻譯質量的新水平

2 Background

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.

減少序列計算的目標也構成了擴展神經GPU[16]、ByteNet[18]和ConvS2S[9]的基礎,它們都使用卷積神經網絡作為基本構件,對所有輸入和輸出位置並行計算隱藏表示。

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.

在這些模型中,將兩個任意輸入或輸出位置的信號關聯起來所需的操作數量在位置之間的距離中增長,對於ConvS2S是線性增長,對於ByteNet是對數增長。

This makes it more difficult to learn dependencies between distant positions [12].

這使得學習遠處位置[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.

在Transformer 中,這被簡化為一個恆定的操作數,盡管代價是由於平均注意加權位置而降低了有效分辨率,我們用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,有時也稱為intra-attention,是一種將單個序列的不同位置聯系起來以計算序列表示的注意機制。

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].

Self-attention已經成功地應用於各種任務中,包括閱讀理解、抽象總結、文本蘊涵和學習任務無關的句子表征[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].

端到端記憶網絡基於遞歸注意機制,而不是序列對齊遞歸,在簡單語言問題回答和語言建模任務[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.

然而,就我們所知,Transformer是第一個完全依賴於self-attention來計算其輸入和輸出表示的轉換模型,而不使用序列對齊的RNNs或卷積。

In the following sections, we will describe the Transformer, motivate self-attention and discuss its advantages over models such as [17, 18] and [9].

在接下來的部分中,我們將描述Transformer,激發self-attention,並討論它相對於[17,18]和[9]等模型的優點。

3 Model Architecture

Most competitive neural sequence transduction models have an encoder-decoder structure [5, 2, 35].

大多數競爭性的神經序列轉導模型都具有編解碼器結構[5,2,35]。

Here, the encoder maps an input sequence of symbol representations (x_1, ... , x_n ) to a sequence of continuous representations z = ( z_1, ... , z_n).

這里,編碼器將一個符號表示的輸入序列(x_1 x_n)映射為一個連續表示序列z = (z_1, ... , z_n)。

Given z, the decoder then generates an output sequence ( y_1, ... , y_m) of symbols one element at a time.

給定z,然后解碼器生成符號的輸出序列(y_1 , ... , y_m),每次一個元素。

At each step the model is auto-regressive[10], consuming the previously generated symbols as additional input when generating the next.

在每個步驟中,模型都是自動回歸的[10],在生成下一個步驟時,使用前面生成的符號作為額外的輸入。

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

Encoder: The encoder is composed of a stack of N = 6 identical layers.

Encoder: 編碼器由一組N = 6個相同的層組成。

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].

我們在每兩個子層周圍使用一個殘余連接[11],然后使用層標准化[1]。

That is, the output of each sub-layer is LayerNorm(x + Sublayer(x)), where Sublayer(x) is the function implemented by the sub-layer itself.

即每個子層的輸出是LayerNorm(x + subblayer (x)),其中subblayer (x)是由子層本身實現的函數。

To facilitate these residual connections, all sub-layers in the model, as well as the embedding layers, produce outputs of dimension d_model = 512.

為了方便這些剩余的連接,模型中的所有子層以及嵌入層都產生d_model = 512維的輸出。

Decoder: The decoder is also composed of a stack of N = 6 identical layers.

Decoder: 解碼器也由一組N = 6個相同的層組成。

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.

我們還修改了解碼器堆棧中的self-attention子層,以防止位置對后續位置的注意。

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.

這種掩蔽,加上輸出嵌入被一個位置偏移的事實,確保了對位置 i 的預測只能依賴於小於 i 位置的已知輸出。

3.2 Attention

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 of the values, where the weight assigned to each value is computed by a compatibility function of the query with the corresponding key

輸出計算為值的加權和,其中分配給每個值的權重由查詢的兼容性函數與相應的鍵計算

Figure 2: (left) Scaled Dot-Product Attention.

圖2:(左) Scaled Dot-Product Attention。

(right) Multi-Head Attention consists of several attention layers running in parallel.

(右) Multi-Head Attention由多個平行運行的注意層組成。

![2](C:\Users\jie\Documents\筆記\Paper\Attention Is All You Need\2.png)

3.2.1 Scaled Dot-Product Attention

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.

我們將我們的特別注意稱為“Scaled Dot-Product Attention”(圖2)。輸入由維度d_k的查詢和鍵以及維度d_v的值組成。

We compute the dot products of the query with all keys, divide each by √d_k, and apply a softmax function to obtain the weights on the values.

我們用所有鍵計算查詢的點積,每個點積除以√d_k,然后應用一個softmax函數來獲得這些值的權重。

In practice, we compute the attention function on a set of queries simultaneously, packed together into a matrix Q.

在實踐中,我們同時計算一組查詢的注意函數,並將其打包成一個矩陣Q

The keys and values are also packed together into matrices K and V .We compute the matrix of outputs as:

鍵和值也被打包成矩陣KV。我們計算輸出矩陣為:

The two most commonly used attention functions are additive attention and dot-product (multi-plicative) attention.

兩個最常用的注意力函數是additive attention和dot-product(multi-plicative)。

Dot-product attention is identical to our algorithm, except for the scaling factor of 1/√d_k .

Dot-product attention和我們的算法是一樣的,除了比例因子1/√d_k

Additive attention computes the compatibility function using a feed-forward network with a single hidden layer.

Additive attention使用帶有單隱層的前饋網絡計算兼容性函數。

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.

雖然這兩者在理論上的復雜性相似,但在實踐中,由於可以使用高度優化的矩陣乘法代碼來實現,因此dot-product attention要快得多,也更節省空間。

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.

d_k的值較小時,這兩種機制的表現相似,當d_k的值較大時,additive attention優於dot product attention,而不需要縮放。

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.

我們懷疑對於較大的d_k值,點積的大小會變大,將softmax函數推到其梯度非常小的區域。

To counteract this effect, we scale the dot products by 1/√d_k.

為了抵消這種影響,我們將點積乘以1/√d_k

3.2.2 Multi-Head Attention

Instead of performing a single attention function with d 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.

與使用d維鍵、值和查詢執行單個注意力函數不同,我們發現使用不同的、學習過的線性投影到d**kd**kd v維來線性投影查詢、鍵和值h次是有益的。

On each of these projected versions of queries, keys and values we then perform the attention function in parallel, yielding d v-dimensional output values.

在這些查詢、鍵和值的投影版本中,我們並行執行注意力函數,生成d v維的輸出值。

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

將這些值連接起來並再次投影,得到最終的值,如圖2所示。

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 · k = dki=1 qik i, has mean 0 and variance d k.

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.

Where the projections are parameter matrices

其中投影是參數矩陣 和

In this work we employ h = 8 parallel attention layers, or heads.

在這項工作中,我們使用h = 8個平行的注意力層,或者說是頭部。

For each of these we use 64.

每一個用64。

Due to the reduced dimension of each head, the total computational cost is similar to that of single-head attention with full dimensionality

由於每個頭的維數減少,總的計算成本與全維的單頭注意相似

3.2.3 Applications of Attention in our Model

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].

這模仿了典型的編碼-解碼注意機制的序列-序列模型,如[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.

在一個self-attention層中,所有的鍵、值和查詢都來自同一個地方,在本例中,是編碼器中前一層的輸出。

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 −∞) all values in the input of the softmax which correspond to illegal connections.See Figure 2.

我們通過屏蔽(設置為−∞)softmax輸入中對應於非法連接的所有值來實現這一點。參見圖2。

3.3 Position-wise Feed-Forward Networks

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.

這包括兩個線性變換,中間有一個ReLU激活。

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.

另一種描述它的方法是用內核大小為1的兩個卷積。

The dimensionality of input and output is d = 512, and the inner-layer has dimensionality d f f = 2048.

輸入輸出維度為d= 512,內層維度為d ff = 2048。

3.4 Embeddings and Softmax

Similarly to other sequence transduction models, we use learned embeddings to convert the input tokens and output tokens to vectors of dimension d.

與其他序列轉換模型類似,我們使用了learned embeddings將輸入標記和輸出標記轉換為維度d的向量。

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].

在我們的模型中,我們在兩個嵌入層之間共享相同的權矩陣和pre-softmax線性變換,類似於[30]。

In the embedding layers, we multiply those weights by d.

在嵌入層中,我們將這些權重乘以 d

3.5 Positional Encoding

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 model as the embeddings, so that the two can be summed.

位置編碼與嵌入編碼具有相同的維度d模型,因此可以將二者相加。

There are many choices of positional encodings, learned and fixed [9].

有許多位置編碼的選擇,學習和固定的[9]。

Table 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations for different layer types.

表1:不同層類型的最大路徑長度、每層復雜度和最小順序操作數。

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.

n為序列長度,d為表示維度,k為卷積的核大小,r為受限自注意的鄰域大小。

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

在這項工作中,我們使用不同頻率的正弦和余弦函數:

where pos is the position and i is the dimension.

其中pos為位置,i為維度。

That is, each dimension of the positional encoding corresponds to a sinusoid.

也就是說,位置編碼的每個維度對應一個正弦信號。

The wavelengths form a geometric progression from 2π to 10000 · 2π.

波長組成幾何級數從2 π 10000 * * 2 π

We chose this function because we hypothesized it would allow the model to easily learn to attend by relative positions, since for any fifixed offset k, P E**pos+k can be represented as a linear function of P E pos.

我們選擇了這個函數,因為我們假設它可以讓模型很容易地學習相對位置,因為對於任何固定偏移量kP E pos+k都可以表示為P E**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)).

我們還嘗試使用學習位置嵌入[9],發現這兩個版本產生的結果幾乎相同(見表3行(E))。

We chose the sinusoidal version because it may allow the model to extrapolate to sequence lengths longer than the ones encountered during training.

我們選擇正弦版本,因為它可能允許模型外推序列長度比訓練中遇到的更長。

4 Why 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 Rd, such as a hidden layer in a typical sequence transduction encoder or decoder.

在本節中,我們將self-attention層的各個方面與通常用於映射一個變長符號表示序列(x_1,…, x_n)到另一個長度相等的序列(z_1,…例如在一個典型的序列轉換編碼器或解碼器的隱層。

Motivating our use of self-attention we consider three desiderata.

激勵我們self-attention我們考慮三個欲望。

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].

輸入和輸出序列中任意位置組合之間的這些路徑越短,就越容易學習長期依賴關系[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.

如表1所示,self-attention層將所有位置連接到一個常數數量的連續執行操作,而循環層需要O(n)個連續操作。

In terms of computational complexity, self-attention layers are faster than recurrent layers when the sequence 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.

在計算復雜性方面,self-attention層速度比周期性層當序列長度n小於表示維數d,這是最常使用的情況下與句子表示最先進的機器翻譯模型,如word-piece[38]和byte-pair[31]表示。

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.

為了提高涉及非常長的序列的任務的計算性能,可以將self-attention限制為只考慮輸入序列中以各自的輸出位置為中心的大小為r的鄰域。

This would increase the maximum path length to O(n/r).

這將把最大路徑長度增加到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(logk(n)) in the case of dilated convolutions [18], increasing the length of the longest paths between any two positions in the network.

一個內核寬度為k < n的卷積層並不能連接所有對輸入和輸出位置。這樣做需要O(n/k)卷積層的堆棧(在連續內核的情況下),或者O(logk(n))在擴展卷積[18]的情況下,增加網絡中任意兩個位置之間最長路徑的長度。

Convolutional layers are generally more expensive than recurrent layers, by a factor of k.

卷積層的復雜度通常比遞歸層的復雜度高k倍。

Separable convolutions [6], however, decrease the complexity considerably, to O(k n d + n d2).

可分卷積[6]將復雜度大大降低到O(k n d + n d2)。

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.

然而,即使k = n,可分離卷積的復雜度也等於一個self-attention層和一個point-wise向前饋層的組合,我們在模型中采用的方法。

As side benefit, self-attention could yield more interpretable models.

作為附帶的好處,self-attention可以產生更多可解釋的模型。

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.

個體的注意力不僅能清楚地學習執行不同的任務,而且許多注意力還表現出與句子的句法和語義結構相關的行為。

5 Training

This section describes the training regime for our models.

本節描述我們的模型的訓練機制。

5.1 Training Data and Batching

We trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million sentence pairs.

我們在標准的WMT 2014英德數據集上進行培訓,該數據集包含大約450萬對句子。

Sentences were encoded using byte-pair encoding [3], which has a shared source- target vocabulary of about 37000 tokens.

句子使用字節對編碼[3]進行編碼,它有一個共享的source- target詞匯表,大約37000個標記。

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].

對於英法雙語,我們使用了更大的WMT 2014英法雙語數據集(包含3600萬個句子),並將標記拆分為32000個單詞詞匯表[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.

每個訓練批包含一組句子對,其中包含大約25000個源標記和25000個目標標記。

5.2 Hardware and Schedule

We trained our models on one machine with 8 NVIDIA P100 GPUs.

我們在一台有8台NVIDIA P100 GPU的機器上訓練我們的模型。

For our base models using the hyperparameters described throughout the paper, each training step took about 0.4 seconds.

對於使用本文中描述的超參數的基本模型,每個訓練步驟大約花費0.4秒。

We trained the base models for a total of 100,000 steps or 12 hours.

我們總共訓練了10萬步或12小時的基本模型。

For our big models,(described on the bottom line of table 3), step time was 1.0 seconds.

對於我們的大型模型(見表3的底線),步驟時間為1.0秒。

The big models were trained for 300,000 steps (3.5 days).

大模型們接受了30萬步(3.5天)的訓練。

5.3 Optimizer

We used the Adam optimizer [20] with β1 = 0.9, β2 = 0.98 and s = 10−9.

We varied the learning rate over the course of training, according to the formula:

我們使用了Adam與β1 = 0.9優化器[20],β2 = 0.98和s = 10−9。根據公式,我們在訓練過程中改變了學習率:

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.

這對應於對第一個warmup_steps訓練步驟線性增加學習率,然后按步驟數的平方根的倒數比例減少學習率。

We used warmup_steps = 4000.

我們使用warmup_steps = 4000。

5.4 Regularization

We employ three types of regularization during training:

我們在培訓中采用了三種類型的正規化:

Residual Dropout

We apply dropout [33] to the output of each sub-layer, before it is added to the sub-layer input and normalized.

我們將dropout[33]應用於每個子層的輸出,然后將其添加到子層的輸入並進行規范化。

In addition, we apply dropout to the sums of the embeddings and the positional encodings in both the encoder and decoder stacks.

另外,我們將dropout應用於編碼器和解碼器堆棧中的嵌入和位置編碼。

For the base model, we use a rate of P_drop = 0.1.

對於基本模型,我們使用P_drop = 0.1的速率。

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在2014年的英德、英法新聞測試中,以培訓成本的一小部分獲得了比之前最先進的車型更高的BLEU分數。

Label Smoothing

During training, we employed label smoothing of value_ls = 0.1 [36].

在訓練中,我們使用了value_ls = 0.1[36]的標簽平滑。

This hurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.

這傷害了perplexity,因為模型學會了更不確定,但提高了准確性和BLEU分數。

6 Results

6.1 Machine Translation

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.

在2014年WMT英德翻譯任務中,big transformer模型(表2中的transformer (big))的性能比之前

The configuration of this model is listed in the bottom line of Table 3.

這個模型的配置列在表3的底部。

Training took 3.5 days on 8 P100 GPUs.

訓練時間為3.5天,使用8個P100 gpu。

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.

在2014年的WMT英法翻譯任務中,我們的大模型獲得了BLEU評分41.0,超過了之前發布的所有單個模型,花費不到之前最先進模型的1/4的培訓成本。

The Transformer (big) model trained for English-to-French used dropout rate P = 0.1, instead of 0.3.

接受英法雙語訓練的Transformer (big)模型使用了輟學率P = 0.1,而不是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.

對於基本模型,我們使用了一個單獨的模型,該模型通過平均最后5個檢查點得到,每隔10分鍾寫一次。

For the big models, we averaged the last 20 checkpoints.

對於大型模型,我們平均使用最后20個檢查點。

We used beam search with a beam size of 4 and length penalty α = 0.6 [38].

我們使用定向搜索的梁尺寸4和長度點球α= 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].

這些超參數是在開發集上進行實驗后選擇的。我們將推理時的最大輸出長度設置為輸入長度+ 50,但在可能的情況下提前終止[38]。

Table 2 summarizes our results and compares our translation quality and training costs to other model architectures from the literature.

表2總結了我們的結果,並將我們的翻譯質量和培訓成本與文獻中的其他模型架構進行了比較。

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.

我們通過乘以訓練時間、使用的GPU數量和每個GPU持續單精度浮點運算能力來估計用於訓練模型的浮點運算的數量。

6.2 Model Variations

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 development set, newstest2013.

為了評估Transformer不同組件的重要性,我們以不同的方式改變了我們的基本模型,在開發集newstest2013上測量英語到德語翻譯的性能變化。

We used beam search as described in the previous section, but no checkpoint averaging.

我們使用前一節描述的波束搜索,但沒有檢查點平均。

We present these results in Table 3.

我們在表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.

在表3行(A)中,我們改變了注意頭的數量、注意鍵和值維度,保持計算量不變,如3.2.2節所述。

While single-head attention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.

單頭注意力比最佳設置差0.9個藍,但如果頭太多,質量也會下降。

6.3 English Constituency Parsing

To evaluate if the Transformer can generalize to other tasks we performed experiments on English constituency parsing.

為了評估Transformer是否可以推廣到其他任務,我們進行了英語選民分析的實驗。

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]

此外,RNN序列到序列模型還不能在小數據環境中獲得最新的結果[37]。

We trained a 4-layer transformer with d = 1024 on the Wall Street Journal (WSJ) portion of the Penn Treebank [25], about 40K training sentences.

我們用d = 1024在Penn Treebank的華爾街日報(WSJ)部分訓練了一個4層變壓器,大約40K的訓練語句。

We also trained it in a semi-supervised setting, using the larger high-confidence and BerkleyParser corpora from with approximately 17M sentences [37].

我們還在半監督設置下訓練它,使用更大的高置信度和BerkleyParser語料庫,包含大約1700萬個句子[37]。

We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens for the semi-supervised setting.

我們在華爾街日報的設置中使用了16K的標記詞匯,在半監督設置中使用了32K的標記詞匯。

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.

我們只進行了少量的實驗來選擇dropout,包括注意力和殘差(section [5.4],) (#_bookmark6),在section 22開發集上的學習速率和波束大小,所有其他參數與英德基礎翻譯模型保持不變。

During inference, we increased the maximum output length to input length + 300.

在推理期間,我們將最大輸出長度增加到輸入長度+ 300。

We used a beam size of 21 and α = 0.3 for both WSJ only and the semi-supervised setting.

我們使用光束大小21 和α= 0.3的《華爾街日報》只和semi-supervised設置。

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

我們在表4中的結果表明,盡管缺乏特定於任務的調優,我們的模型執行得非常好,產生的結果比所有先前報告的模型都好,除了遞歸神經網絡語法[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.

與RNN的順序-順序模型[37]相比,即使只在華爾街日報的40K句子訓練集上訓練,Transformer的性能也優於Berkeley- Parser [29]。

Conclusion

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.

在這項工作中,我們提出了Transformer,第一個序列轉換模型完全基於注意,取代了遞歸層最常用的編碼器和解碼器架構與multi-headed self-attention。

For translation tasks, the Transformer can be trained significantly faster than architectures based on recurrent or convolutional layers.

對於翻譯任務,Transformer的訓練速度比基於遞歸或卷積層的架構要快得多。

On both WMT 2014 English-to-German and WMT 2014 English-to-French translation tasks, we achieve a new state of the art.

在2014年WMT英法翻譯任務和2014年WMT英法翻譯任務中,我們都達到了一個新的水平。

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.

我們計划將Transformer擴展到涉及輸入和輸出模式而不是文本的問題,並研究局部的、受限制的注意力機制,以有效地處理大量輸入和輸出,如圖像、音頻和視頻。

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.

我們用來訓練和評估模型的代碼可以在https://github.com/tensorflow / tensor2張量上找到。

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

感謝Nal Kalchbrenner和Stephan Gouws非常有用的評論、更正和靈感。

References

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

層的歸一化

[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.

機器閱讀的長期短期記憶網絡

[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.

使用rnn編解碼器學習短語表示,用於統計機器翻譯

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

深度分離卷積學習

[7] Junyoung Chung, Çaglar 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 diffificulty 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.

具有跨語言隱藏注釋的自訓練PCFG語法

[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.

神經GPUs學習算法

[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.

Adam: 一種隨機最優化的方法

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

LSTM網絡的因數分解技巧

[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.

一個結構化的self-attentive的句子

[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.

注意神經機器翻譯的有效方法

[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.

建立一個大型的英語注釋語料庫:the penn treebank

[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] Ofifir 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.

Dropout:一種防止神經網絡過擬合的簡單方法

[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.

快速而准確的shift-reduce組成解析。

Attention Visualizations

Figure 3: An example of the attention mechanism following long-distance dependencies in the encoder self-attention in layer 5 of 6.

圖3:一個注意機制的例子,它遵循了第5層或第6層中編碼器自我注意的長距離依賴。

Many of the attention heads attend to a distant dependency of the verb ‘making’, completing the phrase ‘making...more diffificult’.

很多人的注意力都集中在動詞“making”與動詞“making…more diffificult’.”的關系上。

Attentions here shown only for the word ‘making’.

這里我們只關注“制造”這個詞。

Different colors represent different heads.

不同的顏色代表不同的頭像。

Best viewed in color.

彩色效果最佳。

Figure 4: Two attention heads, also in layer 5 of 6, apparently involved in anaphora resolution.

圖4:兩個attention heads,也在第5層或第6層,顯然涉及回指分解。

Top: Full attentions for head 5.

上:注意頭5。

Bottom: Isolated attentions from just the word ‘its’ for attention heads 5 and 6.

底部:注意力從“它”這個詞中分離出來,第5個和第6個是注意力。

Note that the attentions are very sharp for this word.

請注意,注意這個詞是非常尖銳的。

Figure 5: Many of the attention heads exhibit behaviour that seems related to the structure of the sentence.

圖5:許多“注意頭”表現出的行為似乎與句子結構有關。

We give two such examples above, from two different heads from the encoder self-attention at layer 5 of 6.

我們給出了兩個這樣的例子,從兩個不同的頭部編碼器的自我注意在第5層6。

The heads clearly learned to perform different tasks.

大腦顯然學會了執行不同的任務。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM