Files
ai-agent-book/chapter5/paper-to-ppt/validation/runs/exp5-4-real-pdf-both-20260730-v4/receipts.checkpoint.json
T
liqiang b119135836
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
2026-08-20 13:12:50 +00:00

3951 lines
775 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
[
{
"meter": "Proposer(纯文本)",
"called_at_utc": "2026-07-30T04:14:48.964116+00:00",
"latency_s": 116.832,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名擅长把学术论文转化为演示文稿的 Proposer Agent。\n你用 Slidev 框架(Markdown + HTML)编写 PPT 源码 slides.md。\n\nSlidev 语法要点:\n- 文件开头是 YAML frontmatter--- 包裹),设置 theme: default。\n- 用单独一行的 `---`(前后空行)分隔每一页幻灯片。\n- 首页通常放标题、作者、会议。\n- 引用图片用 markdown![说明](/图片文件名.png),可用 HTML 控制尺寸,\n 例如 <img src=\"/speedup_bar.png\" class=\"h-60 mx-auto\" />。\n- 可用 Windi/Uno CSS 工具类控制排版(如 text-sm、grid grid-cols-2 gap-4)。\n\n要求:\n- 最终生成 10-20 页,覆盖论文的标题、背景/动机、方法、实验结果、局限与结论。\n- 至少在 3 页中使用提供的图表/表格,且图文匹配。\n- 每页信息量适中、不要塞太多字,宁可拆页也不要溢出。\n- 只输出 slides.md 的完整内容,用 ```markdown 代码块包裹,不要额外解释。"
},
{
"role": "user",
"content": "以下是论文全文(Markdown):\n\n# Attention Is All You Need\n\nAuthors: Ashish Vaswani et al.\n\n\n## PDF page 1\n\nProvided proper attribution is provided, Google hereby grants permission to\nreproduce the tables and figures in this paper solely for use in journalistic or\nscholarly works.\nAttention Is All You Need\nAshish Vaswani\nGoogle Brain\navaswani@google.com\nNoam Shazeer\nGoogle Brain\nnoam@google.com\nNiki Parmar\nGoogle Research\nnikip@google.com\nJakob Uszkoreit\nGoogle Research\nusz@google.com\nLlion Jones\nGoogle Research\nllion@google.com\nAidan N. Gomez∗†\nUniversity of Toronto\naidan@cs.toronto.edu\nŁukasz Kaiser\nGoogle Brain\nlukaszkaiser@google.com\nIllia Polosukhin∗‡\nillia.polosukhin@gmail.com\nAbstract\nThe dominant sequence transduction models are based on complex recurrent or\nconvolutional neural networks that include an encoder and a decoder. The best\nperforming models also connect the encoder and decoder through an attention\nmechanism. We propose a new simple network architecture, the Transformer,\nbased solely on attention mechanisms, dispensing with recurrence and convolutions\nentirely. Experiments on two machine translation tasks show these models to\nbe superior in quality while being more parallelizable and requiring significantly\nless time to train. Our model achieves 28.4 BLEU on the WMT 2014 English-\nto-German translation task, improving over the existing best results, including\nensembles, by over 2 BLEU. On the WMT 2014 English-to-French translation task,\nour model establishes a new single-model state-of-the-art BLEU score of 41.8 after\ntraining for 3.5 days on eight GPUs, a small fraction of the training costs of the\nbest models from the literature. We show that the Transformer generalizes well to\nother tasks by applying it successfully to English constituency parsing both with\nlarge and limited training data.\nEqual contribution. Listing order is random. Jakob proposed replacing RNNs with self-attention and started\nthe effort to evaluate this idea. Ashish, with Illia, designed and implemented the first Transformer models and\nhas been crucially involved in every aspect of this work. Noam proposed scaled dot-product attention, multi-head\nattention and the parameter-free position representation and became the other person involved in nearly every\ndetail. Niki designed, implemented, tuned and evaluated countless model variants in our original codebase and\ntensor2tensor. Llion also experimented with novel model variants, was responsible for our initial codebase, and\nefficient inference and visualizations. Lukasz and Aidan spent countless long days designing various parts of and\nimplementing tensor2tensor, replacing our earlier codebase, greatly improving results and massively accelerating\nour research.\n†Work performed while at Google Brain.\n‡Work performed while at Google Research.\n31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA.\narXiv:1706.03762v7 [cs.CL] 2 Aug 2023\n\n\n## PDF page 2\n\n1\nIntroduction\nRecurrent neural networks, long short-term memory [13] and gated recurrent [7] neural networks\nin particular, have been firmly established as state of the art approaches in sequence modeling and\ntransduction problems such as language modeling and machine translation [35, 2, 5]. Numerous\nefforts have since continued to push the boundaries of recurrent language models and encoder-decoder\narchitectures [38, 24, 15].\nRecurrent models typically factor computation along the symbol positions of the input and output\nsequences. Aligning the positions to steps in computation time, they generate a sequence of hidden\nstates ht, as a function of the previous hidden state ht1 and the input for position t. This inherently\nsequential nature precludes parallelization within training examples, which becomes critical at longer\nsequence lengths, as memory constraints limit batching across examples. Recent work has achieved\nsignificant improvements in computational efficiency through factorization tricks [21] and conditional\ncomputation [32], while also improving model performance in case of the latter. The fundamental\nconstraint of sequential computation, however, remains.\nAttention mechanisms have become an integral part of compelling sequence modeling and transduc-\ntion models in various tasks, allowing modeling of dependencies without regard to their distance in\nthe input or output sequences [2, 19]. In all but a few cases [27], however, such attention mechanisms\nare used in conjunction with a recurrent network.\nIn this work we propose the Transformer, a model architecture eschewing recurrence and instead\nrelying entirely on an attention mechanism to draw global dependencies between input and output.\nThe Transformer allows for significantly more parallelization and can reach a new state of the art in\ntranslation quality after being trained for as little as twelve hours on eight P100 GPUs.\n2\nBackground\nThe goal of reducing sequential computation also forms the foundation of the Extended Neural GPU\n[16], ByteNet [18] and ConvS2S [9], all of which use convolutional neural networks as basic building\nblock, computing hidden representations in parallel for all input and output positions. In these models,\nthe number of operations required to relate signals from two arbitrary input or output positions grows\nin the distance between positions, linearly for ConvS2S and logarithmically for ByteNet. This makes\nit more difficult to learn dependencies between distant positions [12]. In the Transformer this is\nreduced to a constant number of operations, albeit at the cost of reduced effective resolution due\nto averaging attention-weighted positions, an effect we counteract with Multi-Head Attention as\ndescribed in section 3.2.\nSelf-attention, sometimes called intra-attention is an attention mechanism relating different positions\nof a single sequence in order to compute a representation of the sequence. Self-attention has been\nused successfully in a variety of tasks including reading comprehension, abstractive summarization,\ntextual entailment and learning task-independent sentence representations [4, 27, 28, 22].\nEnd-to-end memory networks are based on a recurrent attention mechanism instead of sequence-\naligned recurrence and have been shown to perform well on simple-language question answering and\nlanguage modeling tasks [34].\nTo the best of our knowledge, however, the Transformer is the first transduction model relying\nentirely on self-attention to compute representations of its input and output without using sequence-\naligned RNNs or convolution. In the following sections, we will describe the Transformer, motivate\nself-attention and discuss its advantages over models such as [17, 18] and [9].\n3\nModel Architecture\nMost competitive neural sequence transduction models have an encoder-decoder structure [5, 2, 35].\nHere, the encoder maps an input sequence of symbol representations (x1, ..., xn) to a sequence\nof continuous representations z = (z1, ..., zn). Given z, the decoder then generates an output\nsequence (y1, ..., ym) of symbols one element at a time. At each step the model is auto-regressive\n[10], consuming the previously generated symbols as additional input when generating the next.\n2\n\n\n## PDF page 3\n\nFigure 1: The Transformer - model architecture.\nThe Transformer follows this overall architecture using stacked self-attention and point-wise, fully\nconnected layers for both the encoder and decoder, shown in the left and right halves of Figure 1,\nrespectively.\n3.1\nEncoder and Decoder Stacks\nEncoder:\nThe encoder is composed of a stack of N = 6 identical layers. Each layer has two\nsub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, position-\nwise fully connected feed-forward network. We employ a residual connection [11] around each of\nthe two sub-layers, followed by layer normalization [1]. That is, the output of each sub-layer is\nLayerNorm(x + Sublayer(x)), where Sublayer(x) is the function implemented by the sub-layer\nitself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding\nlayers, produce outputs of dimension dmodel = 512.\nDecoder:\nThe decoder is also composed of a stack of N = 6 identical layers. In addition to the two\nsub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head\nattention over the output of the encoder stack. Similar to the encoder, we employ residual connections\naround each of the sub-layers, followed by layer normalization. We also modify the self-attention\nsub-layer in the decoder stack to prevent positions from attending to subsequent positions. This\nmasking, combined with fact that the output embeddings are offset by one position, ensures that the\npredictions for position i can depend only on the known outputs at positions less than i.\n3.2\nAttention\nAn attention function can be described as mapping a query and a set of key-value pairs to an output,\nwhere the query, keys, values, and output are all vectors. The output is computed as a weighted sum\n3\n\n\n## PDF page 4\n\nScaled Dot-Product Attention\nMulti-Head Attention\nFigure 2: (left) Scaled Dot-Product Attention. (right) Multi-Head Attention consists of several\nattention layers running in parallel.\nof the values, where the weight assigned to each value is computed by a compatibility function of the\nquery with the corresponding key.\n3.2.1\nScaled Dot-Product Attention\nWe call our particular attention \"Scaled Dot-Product Attention\" (Figure 2). The input consists of\nqueries and keys of dimension dk, and values of dimension dv. We compute the dot products of the\nquery with all keys, divide each by √dk, and apply a softmax function to obtain the weights on the\nvalues.\nIn practice, we compute the attention function on a set of queries simultaneously, packed together\ninto a matrix Q. The keys and values are also packed together into matrices K and V . We compute\nthe matrix of outputs as:\nAttention(Q, K, V ) = softmax(QKT\n√dk\n)V\n(1)\nThe two most commonly used attention functions are additive attention [2], and dot-product (multi-\nplicative) attention. Dot-product attention is identical to our algorithm, except for the scaling factor\nof\n1\n√dk . Additive attention computes the compatibility function using a feed-forward network with\na single hidden layer. While the two are similar in theoretical complexity, dot-product attention is\nmuch faster and more space-efficient in practice, since it can be implemented using highly optimized\nmatrix multiplication code.\nWhile for small values of dk the two mechanisms perform similarly, additive attention outperforms\ndot product attention without scaling for larger values of dk [3]. We suspect that for large values of\ndk, the dot products grow large in magnitude, pushing the softmax function into regions where it has\nextremely small gradients 4. To counteract this effect, we scale the dot products by\n1\n√dk .\n3.2.2\nMulti-Head Attention\nInstead of performing a single attention function with dmodel-dimensional keys, values and queries,\nwe found it beneficial to linearly project the queries, keys and values h times with different, learned\nlinear projections to dk, dk and dv dimensions, respectively. On each of these projected versions of\nqueries, keys and values we then perform the attention function in parallel, yielding dv-dimensional\n4To illustrate why the dot products get large, assume that the components of q and k are independent random\nvariables with mean 0 and variance 1. Then their dot product, q · k = Pdk\ni=1 qiki, has mean 0 and variance dk.\n4\n\n\n## PDF page 5\n\noutput values. These are concatenated and once again projected, resulting in the final values, as\ndepicted in Figure 2.\nMulti-head attention allows the model to jointly attend to information from different representation\nsubspaces at different positions. With a single attention head, averaging inhibits this.\nMultiHead(Q, K, V ) = Concat(head1, ..., headh)W O\nwhere headi = Attention(QW Q\ni , KW K\ni , V W V\ni )\nWhere the projections are parameter matrices W Q\ni\n∈Rdmodel×dk, W K\ni\n∈Rdmodel×dk, W V\ni\n∈Rdmodel×dv\nand W O ∈Rhdv×dmodel.\nIn this work we employ h = 8 parallel attention layers, or heads. For each of these we use\ndk = dv = dmodel/h = 64. Due to the reduced dimension of each head, the total computational cost\nis similar to that of single-head attention with full dimensionality.\n3.2.3\nApplications of Attention in our Model\nThe Transformer uses multi-head attention in three different ways:\n• In \"encoder-decoder attention\" layers, the queries come from the previous decoder layer,\nand the memory keys and values come from the output of the encoder. This allows every\nposition in the decoder to attend over all positions in the input sequence. This mimics the\ntypical encoder-decoder attention mechanisms in sequence-to-sequence models such as\n[38, 2, 9].\n• The encoder contains self-attention layers. In a self-attention layer all of the keys, values\nand queries come from the same place, in this case, the output of the previous layer in the\nencoder. Each position in the encoder can attend to all positions in the previous layer of the\nencoder.\n• Similarly, self-attention layers in the decoder allow each position in the decoder to attend to\nall positions in the decoder up to and including that position. We need to prevent leftward\ninformation flow in the decoder to preserve the auto-regressive property. We implement this\ninside of scaled dot-product attention by masking out (setting to −∞) all values in the input\nof the softmax which correspond to illegal connections. See Figure 2.\n3.3\nPosition-wise Feed-Forward Networks\nIn addition to attention sub-layers, each of the layers in our encoder and decoder contains a fully\nconnected feed-forward network, which is applied to each position separately and identically. This\nconsists of two linear transformations with a ReLU activation in between.\nFFN(x) = max(0, xW1 + b1)W2 + b2\n(2)\nWhile the linear transformations are the same across different positions, they use different parameters\nfrom layer to layer. Another way of describing this is as two convolutions with kernel size 1.\nThe dimensionality of input and output is dmodel = 512, and the inner-layer has dimensionality\ndff = 2048.\n3.4\nEmbeddings and Softmax\nSimilarly to other sequence transduction models, we use learned embeddings to convert the input\ntokens and output tokens to vectors of dimension dmodel. We also use the usual learned linear transfor-\nmation and softmax function to convert the decoder output to predicted next-token probabilities. In\nour model, we share the same weight matrix between the two embedding layers and the pre-softmax\nlinear transformation, similar to [30]. In the embedding layers, we multiply those weights by √dmodel.\n5\n\n\n## PDF page 6\n\nTable 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations\nfor different layer types. n is the sequence length, d is the representation dimension, k is the kernel\nsize of convolutions and r the size of the neighborhood in restricted self-attention.\nLayer Type\nComplexity per Layer\nSequential\nMaximum Path Length\nOperations\nSelf-Attention\nO(n2 · d)\nO(1)\nO(1)\nRecurrent\nO(n · d2)\nO(n)\nO(n)\nConvolutional\nO(k · n · d2)\nO(1)\nO(logk(n))\nSelf-Attention (restricted)\nO(r · n · d)\nO(1)\nO(n/r)\n3.5\nPositional Encoding\nSince our model contains no recurrence and no convolution, in order for the model to make use of the\norder of the sequence, we must inject some information about the relative or absolute position of the\ntokens in the sequence. To this end, we add \"positional encodings\" to the input embeddings at the\nbottoms of the encoder and decoder stacks. The positional encodings have the same dimension dmodel\nas the embeddings, so that the two can be summed. There are many choices of positional encodings,\nlearned and fixed [9].\nIn this work, we use sine and cosine functions of different frequencies:\nPE(pos,2i) = sin(pos/100002i/dmodel)\nPE(pos,2i+1) = cos(pos/100002i/dmodel)\nwhere pos is the position and i is the dimension. That is, each dimension of the positional encoding\ncorresponds to a sinusoid. The wavelengths form a geometric progression from 2π to 10000 · 2π. We\nchose this function because we hypothesized it would allow the model to easily learn to attend by\nrelative positions, since for any fixed offset k, PEpos+k can be represented as a linear function of\nPEpos.\nWe also experimented with using learned positional embeddings [9] instead, and found that the two\nversions produced nearly identical results (see Table 3 row (E)). We chose the sinusoidal version\nbecause it may allow the model to extrapolate to sequence lengths longer than the ones encountered\nduring training.\n4\nWhy Self-Attention\nIn this section we compare various aspects of self-attention layers to the recurrent and convolu-\ntional layers commonly used for mapping one variable-length sequence of symbol representations\n(x1, ..., xn) to another sequence of equal length (z1, ..., zn), with xi, zi ∈Rd, such as a hidden\nlayer in a typical sequence transduction encoder or decoder. Motivating our use of self-attention we\nconsider three desiderata.\nOne is the total computational complexity per layer. Another is the amount of computation that can\nbe parallelized, as measured by the minimum number of sequential operations required.\nThe third is the path length between long-range dependencies in the network. Learning long-range\ndependencies is a key challenge in many sequence transduction tasks. One key factor affecting the\nability to learn such dependencies is the length of the paths forward and backward signals have to\ntraverse in the network. The shorter these paths between any combination of positions in the input\nand output sequences, the easier it is to learn long-range dependencies [12]. Hence we also compare\nthe maximum path length between any two input and output positions in networks composed of the\ndifferent layer types.\nAs noted in Table 1, a self-attention layer connects all positions with a constant number of sequentially\nexecuted operations, whereas a recurrent layer requires O(n) sequential operations. In terms of\ncomputational complexity, self-attention layers are faster than recurrent layers when the sequence\n6\n\n\n## PDF page 7\n\nlength n is smaller than the representation dimensionality d, which is most often the case with\nsentence representations used by state-of-the-art models in machine translations, such as word-piece\n[38] and byte-pair [31] representations. To improve computational performance for tasks involving\nvery long sequences, self-attention could be restricted to considering only a neighborhood of size r in\nthe input sequence centered around the respective output position. This would increase the maximum\npath length to O(n/r). We plan to investigate this approach further in future work.\nA single convolutional layer with kernel width k < n does not connect all pairs of input and output\npositions. Doing so requires a stack of O(n/k) convolutional layers in the case of contiguous kernels,\nor O(logk(n)) in the case of dilated convolutions [18], increasing the length of the longest paths\nbetween any two positions in the network. Convolutional layers are generally more expensive than\nrecurrent layers, by a factor of k. Separable convolutions [6], however, decrease the complexity\nconsiderably, to O(k · n · d + n · d2). Even with k = n, however, the complexity of a separable\nconvolution is equal to the combination of a self-attention layer and a point-wise feed-forward layer,\nthe approach we take in our model.\nAs side benefit, self-attention could yield more interpretable models. We inspect attention distributions\nfrom our models and present and discuss examples in the appendix. Not only do individual attention\nheads clearly learn to perform different tasks, many appear to exhibit behavior related to the syntactic\nand semantic structure of the sentences.\n5\nTraining\nThis section describes the training regime for our models.\n5.1\nTraining Data and Batching\nWe trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million\nsentence pairs. Sentences were encoded using byte-pair encoding [3], which has a shared source-\ntarget vocabulary of about 37000 tokens. For English-French, we used the significantly larger WMT\n2014 English-French dataset consisting of 36M sentences and split tokens into a 32000 word-piece\nvocabulary [38]. Sentence pairs were batched together by approximate sequence length. Each training\nbatch contained a set of sentence pairs containing approximately 25000 source tokens and 25000\ntarget tokens.\n5.2\nHardware and Schedule\nWe trained our models on one machine with 8 NVIDIA P100 GPUs. For our base models using\nthe hyperparameters described throughout the paper, each training step took about 0.4 seconds. We\ntrained the base models for a total of 100,000 steps or 12 hours. For our big models,(described on the\nbottom line of table 3), step time was 1.0 seconds. The big models were trained for 300,000 steps\n(3.5 days).\n5.3\nOptimizer\nWe used the Adam optimizer [20] with β1 = 0.9, β2 = 0.98 and ϵ = 109. We varied the learning\nrate over the course of training, according to the formula:\nlrate = d0.5\nmodel · min(step_num0.5, step_num · warmup_steps1.5)\n(3)\nThis corresponds to increasing the learning rate linearly for the first warmup_steps training steps,\nand decreasing it thereafter proportionally to the inverse square root of the step number. We used\nwarmup_steps = 4000.\n5.4\nRegularization\nWe employ three types of regularization during training:\n7\n\n\n## PDF page 8\n\nTable 2: The Transformer achieves better BLEU scores than previous state-of-the-art models on the\nEnglish-to-German and English-to-French newstest2014 tests at a fraction of the training cost.\nModel\nBLEU\nTraining Cost (FLOPs)\nEN-DE\nEN-FR\nEN-DE\nEN-FR\nByteNet [18]\n23.75\nDeep-Att + PosUnk [39]\n39.2\n1.0 · 1020\nGNMT + RL [38]\n24.6\n39.92\n2.3 · 1019\n1.4 · 1020\nConvS2S [9]\n25.16\n40.46\n9.6 · 1018\n1.5 · 1020\nMoE [32]\n26.03\n40.56\n2.0 · 1019\n1.2 · 1020\nDeep-Att + PosUnk Ensemble [39]\n40.4\n8.0 · 1020\nGNMT + RL Ensemble [38]\n26.30\n41.16\n1.8 · 1020\n1.1 · 1021\nConvS2S Ensemble [9]\n26.36\n41.29\n7.7 · 1019\n1.2 · 1021\nTransformer (base model)\n27.3\n38.1\n3.3 · 1018\nTransformer (big)\n28.4\n41.8\n2.3 · 1019\nResidual Dropout\nWe apply dropout [33] to the output of each sub-layer, before it is added to the\nsub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the\npositional encodings in both the encoder and decoder stacks. For the base model, we use a rate of\nPdrop = 0.1.\nLabel Smoothing\nDuring training, we employed label smoothing of value ϵls = 0.1 [36]. This\nhurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.\n6\nResults\n6.1\nMachine Translation\nOn the WMT 2014 English-to-German translation task, the big transformer model (Transformer (big)\nin Table 2) outperforms the best previously reported models (including ensembles) by more than 2.0\nBLEU, establishing a new state-of-the-art BLEU score of 28.4. The configuration of this model is\nlisted in the bottom line of Table 3. Training took 3.5 days on 8 P100 GPUs. Even our base model\nsurpasses all previously published models and ensembles, at a fraction of the training cost of any of\nthe competitive models.\nOn the WMT 2014 English-to-French translation task, our big model achieves a BLEU score of 41.0,\noutperforming all of the previously published single models, at less than 1/4 the training cost of the\nprevious state-of-the-art model. The Transformer (big) model trained for English-to-French used\ndropout rate Pdrop = 0.1, instead of 0.3.\nFor the base models, we used a single model obtained by averaging the last 5 checkpoints, which\nwere written at 10-minute intervals. For the big models, we averaged the last 20 checkpoints. We\nused beam search with a beam size of 4 and length penalty α = 0.6 [38]. These hyperparameters\nwere chosen after experimentation on the development set. We set the maximum output length during\ninference to input length + 50, but terminate early when possible [38].\nTable 2 summarizes our results and compares our translation quality and training costs to other model\narchitectures from the literature. We estimate the number of floating point operations used to train a\nmodel by multiplying the training time, the number of GPUs used, and an estimate of the sustained\nsingle-precision floating-point capacity of each GPU 5.\n6.2\nModel Variations\nTo evaluate the importance of different components of the Transformer, we varied our base model\nin different ways, measuring the change in performance on English-to-German translation on the\n5We used values of 2.8, 3.7, 6.0 and 9.5 TFLOPS for K80, K40, M40 and P100, respectively.\n8\n\n\n## PDF page 9\n\nTable 3: Variations on the Transformer architecture. Unlisted values are identical to those of the base\nmodel. All metrics are on the English-to-German translation development set, newstest2013. Listed\nperplexities are per-wordpiece, according to our byte-pair encoding, and should not be compared to\nper-word perplexities.\nN\ndmodel\ndff\nh\ndk\ndv\nPdrop\nϵls\ntrain\nPPL\nBLEU\nparams\nsteps\n(dev)\n(dev)\n×106\nbase\n6\n512\n2048\n8\n64\n64\n0.1\n0.1\n100K\n4.92\n25.8\n65\n(A)\n1\n512\n512\n5.29\n24.9\n4\n128\n128\n5.00\n25.5\n16\n32\n32\n4.91\n25.8\n32\n16\n16\n5.01\n25.4\n(B)\n16\n5.16\n25.1\n58\n32\n5.01\n25.4\n60\n(C)\n2\n6.11\n23.7\n36\n4\n5.19\n25.3\n50\n8\n4.88\n25.5\n80\n256\n32\n32\n5.75\n24.5\n28\n1024\n128\n128\n4.66\n26.0\n168\n1024\n5.12\n25.4\n53\n4096\n4.75\n26.2\n90\n(D)\n0.0\n5.77\n24.6\n0.2\n4.95\n25.5\n0.0\n4.67\n25.3\n0.2\n5.47\n25.7\n(E)\npositional embedding instead of sinusoids\n4.92\n25.7\nbig\n6\n1024\n4096\n16\n0.3\n300K\n4.33\n26.4\n213\ndevelopment set, newstest2013. We used beam search as described in the previous section, but no\ncheckpoint averaging. We present these results in Table 3.\nIn Table 3 rows (A), we vary the number of attention heads and the attention key and value dimensions,\nkeeping the amount of computation constant, as described in Section 3.2.2. While single-head\nattention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.\nIn Table 3 rows (B), we observe that reducing the attention key size dk hurts model quality. This\nsuggests that determining compatibility is not easy and that a more sophisticated compatibility\nfunction than dot product may be beneficial. We further observe in rows (C) and (D) that, as expected,\nbigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our\nsinusoidal positional encoding with learned positional embeddings [9], and observe nearly identical\nresults to the base model.\n6.3\nEnglish Constituency Parsing\nTo evaluate if the Transformer can generalize to other tasks we performed experiments on English\nconstituency parsing. This task presents specific challenges: the output is subject to strong structural\nconstraints and is significantly longer than the input. Furthermore, RNN sequence-to-sequence\nmodels have not been able to attain state-of-the-art results in small-data regimes [37].\nWe trained a 4-layer transformer with dmodel = 1024 on the Wall Street Journal (WSJ) portion of the\nPenn Treebank [25], about 40K training sentences. We also trained it in a semi-supervised setting,\nusing the larger high-confidence and BerkleyParser corpora from with approximately 17M sentences\n[37]. We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens\nfor the semi-supervised setting.\nWe performed only a small number of experiments to select the dropout, both attention and residual\n(section 5.4), learning rates and beam size on the Section 22 development set, all other parameters\nremained unchanged from the English-to-German base translation model. During inference, we\n9\n\n\n## PDF page 10\n\nTable 4: The Transformer generalizes well to English constituency parsing (Results are on Section 23\nof WSJ)\nParser\nTraining\nWSJ 23 F1\nVinyals & Kaiser el al. (2014) [37]\nWSJ only, discriminative\n88.3\nPetrov et al. (2006) [29]\nWSJ only, discriminative\n90.4\nZhu et al. (2013) [40]\nWSJ only, discriminative\n90.4\nDyer et al. (2016) [8]\nWSJ only, discriminative\n91.7\nTransformer (4 layers)\nWSJ only, discriminative\n91.3\nZhu et al. (2013) [40]\nsemi-supervised\n91.3\nHuang & Harper (2009) [14]\nsemi-supervised\n91.3\nMcClosky et al. (2006) [26]\nsemi-supervised\n92.1\nVinyals & Kaiser el al. (2014) [37]\nsemi-supervised\n92.1\nTransformer (4 layers)\nsemi-supervised\n92.7\nLuong et al. (2015) [23]\nmulti-task\n93.0\nDyer et al. (2016) [8]\ngenerative\n93.3\nincreased the maximum output length to input length + 300. We used a beam size of 21 and α = 0.3\nfor both WSJ only and the semi-supervised setting.\nOur results in Table 4 show that despite the lack of task-specific tuning our model performs sur-\nprisingly well, yielding better results than all previously reported models with the exception of the\nRecurrent Neural Network Grammar [8].\nIn contrast to RNN sequence-to-sequence models [37], the Transformer outperforms the Berkeley-\nParser [29] even when training only on the WSJ training set of 40K sentences.\n7\nConclusion\nIn this work, we presented the Transformer, the first sequence transduction model based entirely on\nattention, replacing the recurrent layers most commonly used in encoder-decoder architectures with\nmulti-headed self-attention.\nFor translation tasks, the Transformer can be trained significantly faster than architectures based\non recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014\nEnglish-to-French translation tasks, we achieve a new state of the art. In the former task our best\nmodel outperforms even all previously reported ensembles.\nWe are excited about the future of attention-based models and plan to apply them to other tasks. We\nplan to extend the Transformer to problems involving input and output modalities other than text and\nto investigate local, restricted attention mechanisms to efficiently handle large inputs and outputs\nsuch as images, audio and video. Making generation less sequential is another research goals of ours.\nThe code we used to train and evaluate our models is available at https://github.com/\ntensorflow/tensor2tensor.\nAcknowledgements\nWe are grateful to Nal Kalchbrenner and Stephan Gouws for their fruitful\ncomments, corrections and inspiration.\nReferences\n[1] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint\narXiv:1607.06450, 2016.\n[2] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly\nlearning to align and translate. CoRR, abs/1409.0473, 2014.\n[3] Denny Britz, Anna Goldie, Minh-Thang Luong, and Quoc V. Le. Massive exploration of neural\nmachine translation architectures. CoRR, abs/1703.03906, 2017.\n[4] Jianpeng Cheng, Li Dong, and Mirella Lapata. Long short-term memory-networks for machine\nreading. arXiv preprint arXiv:1601.06733, 2016.\n10\n\n\n## PDF page 11\n\n[5] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk,\nand Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical\nmachine translation. CoRR, abs/1406.1078, 2014.\n[6] Francois Chollet. Xception: Deep learning with depthwise separable convolutions. arXiv\npreprint arXiv:1610.02357, 2016.\n[7] Junyoung Chung, Çaglar Gülçehre, Kyunghyun Cho, and Yoshua Bengio. Empirical evaluation\nof gated recurrent neural networks on sequence modeling. CoRR, abs/1412.3555, 2014.\n[8] Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, and Noah A. Smith. Recurrent neural\nnetwork grammars. In Proc. of NAACL, 2016.\n[9] Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. Convolu-\ntional sequence to sequence learning. arXiv preprint arXiv:1705.03122v2, 2017.\n[10] Alex Graves.\nGenerating sequences with recurrent neural networks.\narXiv preprint\narXiv:1308.0850, 2013.\n[11] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for im-\nage recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern\nRecognition, pages 770778, 2016.\n[12] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber. Gradient flow in\nrecurrent nets: the difficulty of learning long-term dependencies, 2001.\n[13] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation,\n9(8):17351780, 1997.\n[14] Zhongqiang Huang and Mary Harper. Self-training PCFG grammars with latent annotations\nacross languages. In Proceedings of the 2009 Conference on Empirical Methods in Natural\nLanguage Processing, pages 832841. ACL, August 2009.\n[15] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring\nthe limits of language modeling. arXiv preprint arXiv:1602.02410, 2016.\n[16] Łukasz Kaiser and Samy Bengio. Can active memory replace attention? In Advances in Neural\nInformation Processing Systems, (NIPS), 2016.\n[17] Łukasz Kaiser and Ilya Sutskever. Neural GPUs learn algorithms. In International Conference\non Learning Representations (ICLR), 2016.\n[18] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Ko-\nray Kavukcuoglu. Neural machine translation in linear time. arXiv preprint arXiv:1610.10099v2,\n2017.\n[19] Yoon Kim, Carl Denton, Luong Hoang, and Alexander M. Rush. Structured attention networks.\nIn International Conference on Learning Representations, 2017.\n[20] Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.\n[21] Oleksii Kuchaiev and Boris Ginsburg. Factorization tricks for LSTM networks. arXiv preprint\narXiv:1703.10722, 2017.\n[22] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen\nZhou, and Yoshua Bengio. A structured self-attentive sentence embedding. arXiv preprint\narXiv:1703.03130, 2017.\n[23] Minh-Thang Luong, Quoc V. Le, Ilya Sutskever, Oriol Vinyals, and Lukasz Kaiser. Multi-task\nsequence to sequence learning. arXiv preprint arXiv:1511.06114, 2015.\n[24] Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-\nbased neural machine translation. arXiv preprint arXiv:1508.04025, 2015.\n11\n\n\n## PDF page 12\n\n[25] Mitchell P Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. Building a large annotated\ncorpus of english: The penn treebank. Computational linguistics, 19(2):313330, 1993.\n[26] David McClosky, Eugene Charniak, and Mark Johnson. Effective self-training for parsing. In\nProceedings of the Human Language Technology Conference of the NAACL, Main Conference,\npages 152159. ACL, June 2006.\n[27] Ankur Parikh, Oscar Täckström, Dipanjan Das, and Jakob Uszkoreit. A decomposable attention\nmodel. In Empirical Methods in Natural Language Processing, 2016.\n[28] Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive\nsummarization. arXiv preprint arXiv:1705.04304, 2017.\n[29] Slav Petrov, Leon Barrett, Romain Thibaux, and Dan Klein. Learning accurate, compact,\nand interpretable tree annotation. In Proceedings of the 21st International Conference on\nComputational Linguistics and 44th Annual Meeting of the ACL, pages 433440. ACL, July\n2006.\n[30] Ofir Press and Lior Wolf. Using the output embedding to improve language models. arXiv\npreprint arXiv:1608.05859, 2016.\n[31] Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words\nwith subword units. arXiv preprint arXiv:1508.07909, 2015.\n[32] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton,\nand Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts\nlayer. arXiv preprint arXiv:1701.06538, 2017.\n[33] Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdi-\nnov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine\nLearning Research, 15(1):19291958, 2014.\n[34] Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory\nnetworks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors,\nAdvances in Neural Information Processing Systems 28, pages 24402448. Curran Associates,\nInc., 2015.\n[35] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. Sequence to sequence learning with neural\nnetworks. In Advances in Neural Information Processing Systems, pages 31043112, 2014.\n[36] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna.\nRethinking the inception architecture for computer vision. CoRR, abs/1512.00567, 2015.\n[37] Vinyals & Kaiser, Koo, Petrov, Sutskever, and Hinton. Grammar as a foreign language. In\nAdvances in Neural Information Processing Systems, 2015.\n[38] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang\nMacherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Googles neural machine\ntranslation system: Bridging the gap between human and machine translation. arXiv preprint\narXiv:1609.08144, 2016.\n[39] Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. Deep recurrent models with\nfast-forward connections for neural machine translation. CoRR, abs/1606.04199, 2016.\n[40] Muhua Zhu, Yue Zhang, Wenliang Chen, Min Zhang, and Jingbo Zhu. Fast and accurate\nshift-reduce constituent parsing. In Proceedings of the 51st Annual Meeting of the ACL (Volume\n1: Long Papers), pages 434443. ACL, August 2013.\n12\n\n\n## PDF page 13\n\nAttention Visualizations\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nFigure 3: An example of the attention mechanism following long-distance dependencies in the\nencoder self-attention in layer 5 of 6. Many of the attention heads attend to a distant dependency of\nthe verb making, completing the phrase making...more difficult. Attentions here shown only for\nthe word making. Different colors represent different heads. Best viewed in color.\n13\n\n\n## PDF page 14\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 4: Two attention heads, also in layer 5 of 6, apparently involved in anaphora resolution. Top:\nFull attentions for head 5. Bottom: Isolated attentions from just the word its for attention heads 5\nand 6. Note that the attentions are very sharp for this word.\n14\n\n\n## PDF page 15\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 5: Many of the attention heads exhibit behaviour that seems related to the structure of the\nsentence. We give two such examples above, from two different heads from the encoder self-attention\nat layer 5 of 6. The heads clearly learned to perform different tasks.\n15\n\n\n可直接引用的图表文件(放在 Slidev public 目录,用 /文件名 引用):\n- paper_figure_1_transformer.pngFigure 1 from PDF page 3: The Transformer model architecture.\n- paper_figure_3_long_distance.pngFigure 3 from PDF page 13: Encoder self-attention following long-distance dependencies.\n- paper_figure_4_anaphora.pngFigure 4 from PDF page 14: Attention heads involved in anaphora resolution.\n\n请生成一版 10-20 页的完整初稿。内容必须忠于论文,至少引用上面列出的三张原论文图,并覆盖问题、Transformer 架构、注意力机制、训练、主要实验、局限和结论。不要复制长段原文;每页保持听众可读的信息密度。生成完整的 slides.md。"
}
],
"temperature": 0.3
},
"response": {
"id": "0217853848330121f1c2502e2c4024a5d577df8bf366bf36f7a01",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n- Proposes **Transformer** - a new network architecture based solely on attention mechanisms\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- Achieves state-of-the-art results on machine translation tasks:\n - 28.4 BLEU on WMT 2014 English-to-German\n - 41.8 BLEU on WMT 2014 English-to-French\n- Generalizes well to other tasks like English constituency parsing\n\n---\n\n## Background: Sequence Transduction Challenges\n\n### Traditional Approaches\n- **Recurrent models** (LSTM, GRU) have sequential computation\n- **Convolutional models** have limited long-range dependencies\n- Both have challenges with parallelization and long sequences\n\n### Attention Mechanisms\n- Already used in conjunction with recurrent networks\n- Allows modeling dependencies without regard to distance\n- But not used as the primary architecture... until now\n\n---\n\n## The Transformer: Key Idea\n\nReplace recurrence and convolution with **self-attention** to:\n- Enable more parallelization\n- Reduce sequential computation\n- Capture long-range dependencies more effectively\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n*Encoder (left) and Decoder (right) stacks with self-attention and feed-forward layers*\n\n---\n\n## Encoder Stack\n\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections around each sub-layer\n- Layer normalization after each sub-layer\n- All sub-layers produce outputs of dimension `d_model = 512`\n\n---\n\n## Decoder Stack\n\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward information flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Same residual connections and layer normalization as encoder\n- Output embeddings offset by one position (auto-regressive property)\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-40 mx-auto\" />\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder\n2. **Encoder self-attention**: All positions attend to all positions in previous encoder layer\n3. **Decoder self-attention**: Positions attend to previous positions (masked to preserve auto-regressive property)\n\n---\n\n## Positional Encoding\n\nSince there's no recurrence/convolution, we add positional information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performed similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Details\n\n### Data & Batching\n- WMT 2014 English-German (4.5M sentence pairs)\n- WMT 2014 English-French (36M sentence pairs)\n- Byte-pair encoding with shared vocabulary\n- Batches with ~25,000 source and target tokens\n\n### Hardware & Schedule\n- 8 NVIDIA P100 GPUs\n- Base model: 100,000 steps (12 hours)\n- Big model: 300,000 steps (3.5 days)\n\n---\n\n## Training Details (Cont.)\n\n### Optimizer\n- Adam with $\\beta_1 = 0.9$, $\\beta_2 = 0.98$, $\\epsilon = 10^{-9}$\n- Learning rate schedule:\n $$\\text{lrate} = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step\\_num}^{-0.5}, \\text{step\\_num} \\cdot \\text{warmup\\_steps}^{-1.5})$$\n- Warmup steps = 4000\n\n### Regularization\n- Residual dropout (P_drop = 0.1)\n- Label smoothing ($\\epsilon_{ls} = 0.1$)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n- 2+ BLEU improvement on English-to-German\n\n---\n\n## Model Architecture Ablations\n\n| Variation | Dev PPL | Dev BLEU |\n|-----------|---------|----------|\n| Base model | 4.92 | 25.8 |\n| (A) 1 attention head | 5.29 | 24.9 |\n| (B) d_k = 16 | 5.75 | 24.5 |\n| (C) 2 layers | 6.11 | 23.7 |\n| (D) No dropout | 5.77 | 24.6 |\n| (E) Learned positional embeddings | 4.92 | 25.7 |\n\n- Multi-head attention improves performance\n- Dropout is crucial for avoiding overfitting\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. (2014) | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Performs comparably to state-of-the-art parsers\n- Better than RNN models in small-data regimes\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion\n\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution\n- Achieved new state-of-the-art in machine translation:\n - 28.4 BLEU on English-to-German\n - 41.8 BLEU on English-to-French\n- More parallelizable and faster to train\n- Generalizes well to other tasks like constituency parsing\n\n---\n\n## Future Work\n\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
"usage": {
"prompt_tokens": 11719,
"completion_tokens": 2622,
"total_tokens": 14341,
"cached_prompt_tokens": 0
}
},
{
"meter": "Proposer(纯文本)",
"called_at_utc": "2026-07-30T04:15:44.666296+00:00",
"latency_s": 55.701,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名擅长把学术论文转化为演示文稿的 Proposer Agent。\n你用 Slidev 框架(Markdown + HTML)编写 PPT 源码 slides.md。\n\nSlidev 语法要点:\n- 文件开头是 YAML frontmatter--- 包裹),设置 theme: default。\n- 用单独一行的 `---`(前后空行)分隔每一页幻灯片。\n- 首页通常放标题、作者、会议。\n- 引用图片用 markdown![说明](/图片文件名.png),可用 HTML 控制尺寸,\n 例如 <img src=\"/speedup_bar.png\" class=\"h-60 mx-auto\" />。\n- 可用 Windi/Uno CSS 工具类控制排版(如 text-sm、grid grid-cols-2 gap-4)。\n\n要求:\n- 最终生成 10-20 页,覆盖论文的标题、背景/动机、方法、实验结果、局限与结论。\n- 至少在 3 页中使用提供的图表/表格,且图文匹配。\n- 每页信息量适中、不要塞太多字,宁可拆页也不要溢出。\n- 只输出 slides.md 的完整内容,用 ```markdown 代码块包裹,不要额外解释。"
},
{
"role": "user",
"content": "以下是论文全文(Markdown):\n\n# Attention Is All You Need\n\nAuthors: Ashish Vaswani et al.\n\n\n## PDF page 1\n\nProvided proper attribution is provided, Google hereby grants permission to\nreproduce the tables and figures in this paper solely for use in journalistic or\nscholarly works.\nAttention Is All You Need\nAshish Vaswani\nGoogle Brain\navaswani@google.com\nNoam Shazeer\nGoogle Brain\nnoam@google.com\nNiki Parmar\nGoogle Research\nnikip@google.com\nJakob Uszkoreit\nGoogle Research\nusz@google.com\nLlion Jones\nGoogle Research\nllion@google.com\nAidan N. Gomez∗†\nUniversity of Toronto\naidan@cs.toronto.edu\nŁukasz Kaiser\nGoogle Brain\nlukaszkaiser@google.com\nIllia Polosukhin∗‡\nillia.polosukhin@gmail.com\nAbstract\nThe dominant sequence transduction models are based on complex recurrent or\nconvolutional neural networks that include an encoder and a decoder. The best\nperforming models also connect the encoder and decoder through an attention\nmechanism. We propose a new simple network architecture, the Transformer,\nbased solely on attention mechanisms, dispensing with recurrence and convolutions\nentirely. Experiments on two machine translation tasks show these models to\nbe superior in quality while being more parallelizable and requiring significantly\nless time to train. Our model achieves 28.4 BLEU on the WMT 2014 English-\nto-German translation task, improving over the existing best results, including\nensembles, by over 2 BLEU. On the WMT 2014 English-to-French translation task,\nour model establishes a new single-model state-of-the-art BLEU score of 41.8 after\ntraining for 3.5 days on eight GPUs, a small fraction of the training costs of the\nbest models from the literature. We show that the Transformer generalizes well to\nother tasks by applying it successfully to English constituency parsing both with\nlarge and limited training data.\nEqual contribution. Listing order is random. Jakob proposed replacing RNNs with self-attention and started\nthe effort to evaluate this idea. Ashish, with Illia, designed and implemented the first Transformer models and\nhas been crucially involved in every aspect of this work. Noam proposed scaled dot-product attention, multi-head\nattention and the parameter-free position representation and became the other person involved in nearly every\ndetail. Niki designed, implemented, tuned and evaluated countless model variants in our original codebase and\ntensor2tensor. Llion also experimented with novel model variants, was responsible for our initial codebase, and\nefficient inference and visualizations. Lukasz and Aidan spent countless long days designing various parts of and\nimplementing tensor2tensor, replacing our earlier codebase, greatly improving results and massively accelerating\nour research.\n†Work performed while at Google Brain.\n‡Work performed while at Google Research.\n31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA.\narXiv:1706.03762v7 [cs.CL] 2 Aug 2023\n\n\n## PDF page 2\n\n1\nIntroduction\nRecurrent neural networks, long short-term memory [13] and gated recurrent [7] neural networks\nin particular, have been firmly established as state of the art approaches in sequence modeling and\ntransduction problems such as language modeling and machine translation [35, 2, 5]. Numerous\nefforts have since continued to push the boundaries of recurrent language models and encoder-decoder\narchitectures [38, 24, 15].\nRecurrent models typically factor computation along the symbol positions of the input and output\nsequences. Aligning the positions to steps in computation time, they generate a sequence of hidden\nstates ht, as a function of the previous hidden state ht1 and the input for position t. This inherently\nsequential nature precludes parallelization within training examples, which becomes critical at longer\nsequence lengths, as memory constraints limit batching across examples. Recent work has achieved\nsignificant improvements in computational efficiency through factorization tricks [21] and conditional\ncomputation [32], while also improving model performance in case of the latter. The fundamental\nconstraint of sequential computation, however, remains.\nAttention mechanisms have become an integral part of compelling sequence modeling and transduc-\ntion models in various tasks, allowing modeling of dependencies without regard to their distance in\nthe input or output sequences [2, 19]. In all but a few cases [27], however, such attention mechanisms\nare used in conjunction with a recurrent network.\nIn this work we propose the Transformer, a model architecture eschewing recurrence and instead\nrelying entirely on an attention mechanism to draw global dependencies between input and output.\nThe Transformer allows for significantly more parallelization and can reach a new state of the art in\ntranslation quality after being trained for as little as twelve hours on eight P100 GPUs.\n2\nBackground\nThe goal of reducing sequential computation also forms the foundation of the Extended Neural GPU\n[16], ByteNet [18] and ConvS2S [9], all of which use convolutional neural networks as basic building\nblock, computing hidden representations in parallel for all input and output positions. In these models,\nthe number of operations required to relate signals from two arbitrary input or output positions grows\nin the distance between positions, linearly for ConvS2S and logarithmically for ByteNet. This makes\nit more difficult to learn dependencies between distant positions [12]. In the Transformer this is\nreduced to a constant number of operations, albeit at the cost of reduced effective resolution due\nto averaging attention-weighted positions, an effect we counteract with Multi-Head Attention as\ndescribed in section 3.2.\nSelf-attention, sometimes called intra-attention is an attention mechanism relating different positions\nof a single sequence in order to compute a representation of the sequence. Self-attention has been\nused successfully in a variety of tasks including reading comprehension, abstractive summarization,\ntextual entailment and learning task-independent sentence representations [4, 27, 28, 22].\nEnd-to-end memory networks are based on a recurrent attention mechanism instead of sequence-\naligned recurrence and have been shown to perform well on simple-language question answering and\nlanguage modeling tasks [34].\nTo the best of our knowledge, however, the Transformer is the first transduction model relying\nentirely on self-attention to compute representations of its input and output without using sequence-\naligned RNNs or convolution. In the following sections, we will describe the Transformer, motivate\nself-attention and discuss its advantages over models such as [17, 18] and [9].\n3\nModel Architecture\nMost competitive neural sequence transduction models have an encoder-decoder structure [5, 2, 35].\nHere, the encoder maps an input sequence of symbol representations (x1, ..., xn) to a sequence\nof continuous representations z = (z1, ..., zn). Given z, the decoder then generates an output\nsequence (y1, ..., ym) of symbols one element at a time. At each step the model is auto-regressive\n[10], consuming the previously generated symbols as additional input when generating the next.\n2\n\n\n## PDF page 3\n\nFigure 1: The Transformer - model architecture.\nThe Transformer follows this overall architecture using stacked self-attention and point-wise, fully\nconnected layers for both the encoder and decoder, shown in the left and right halves of Figure 1,\nrespectively.\n3.1\nEncoder and Decoder Stacks\nEncoder:\nThe encoder is composed of a stack of N = 6 identical layers. Each layer has two\nsub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, position-\nwise fully connected feed-forward network. We employ a residual connection [11] around each of\nthe two sub-layers, followed by layer normalization [1]. That is, the output of each sub-layer is\nLayerNorm(x + Sublayer(x)), where Sublayer(x) is the function implemented by the sub-layer\nitself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding\nlayers, produce outputs of dimension dmodel = 512.\nDecoder:\nThe decoder is also composed of a stack of N = 6 identical layers. In addition to the two\nsub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head\nattention over the output of the encoder stack. Similar to the encoder, we employ residual connections\naround each of the sub-layers, followed by layer normalization. We also modify the self-attention\nsub-layer in the decoder stack to prevent positions from attending to subsequent positions. This\nmasking, combined with fact that the output embeddings are offset by one position, ensures that the\npredictions for position i can depend only on the known outputs at positions less than i.\n3.2\nAttention\nAn attention function can be described as mapping a query and a set of key-value pairs to an output,\nwhere the query, keys, values, and output are all vectors. The output is computed as a weighted sum\n3\n\n\n## PDF page 4\n\nScaled Dot-Product Attention\nMulti-Head Attention\nFigure 2: (left) Scaled Dot-Product Attention. (right) Multi-Head Attention consists of several\nattention layers running in parallel.\nof the values, where the weight assigned to each value is computed by a compatibility function of the\nquery with the corresponding key.\n3.2.1\nScaled Dot-Product Attention\nWe call our particular attention \"Scaled Dot-Product Attention\" (Figure 2). The input consists of\nqueries and keys of dimension dk, and values of dimension dv. We compute the dot products of the\nquery with all keys, divide each by √dk, and apply a softmax function to obtain the weights on the\nvalues.\nIn practice, we compute the attention function on a set of queries simultaneously, packed together\ninto a matrix Q. The keys and values are also packed together into matrices K and V . We compute\nthe matrix of outputs as:\nAttention(Q, K, V ) = softmax(QKT\n√dk\n)V\n(1)\nThe two most commonly used attention functions are additive attention [2], and dot-product (multi-\nplicative) attention. Dot-product attention is identical to our algorithm, except for the scaling factor\nof\n1\n√dk . Additive attention computes the compatibility function using a feed-forward network with\na single hidden layer. While the two are similar in theoretical complexity, dot-product attention is\nmuch faster and more space-efficient in practice, since it can be implemented using highly optimized\nmatrix multiplication code.\nWhile for small values of dk the two mechanisms perform similarly, additive attention outperforms\ndot product attention without scaling for larger values of dk [3]. We suspect that for large values of\ndk, the dot products grow large in magnitude, pushing the softmax function into regions where it has\nextremely small gradients 4. To counteract this effect, we scale the dot products by\n1\n√dk .\n3.2.2\nMulti-Head Attention\nInstead of performing a single attention function with dmodel-dimensional keys, values and queries,\nwe found it beneficial to linearly project the queries, keys and values h times with different, learned\nlinear projections to dk, dk and dv dimensions, respectively. On each of these projected versions of\nqueries, keys and values we then perform the attention function in parallel, yielding dv-dimensional\n4To illustrate why the dot products get large, assume that the components of q and k are independent random\nvariables with mean 0 and variance 1. Then their dot product, q · k = Pdk\ni=1 qiki, has mean 0 and variance dk.\n4\n\n\n## PDF page 5\n\noutput values. These are concatenated and once again projected, resulting in the final values, as\ndepicted in Figure 2.\nMulti-head attention allows the model to jointly attend to information from different representation\nsubspaces at different positions. With a single attention head, averaging inhibits this.\nMultiHead(Q, K, V ) = Concat(head1, ..., headh)W O\nwhere headi = Attention(QW Q\ni , KW K\ni , V W V\ni )\nWhere the projections are parameter matrices W Q\ni\n∈Rdmodel×dk, W K\ni\n∈Rdmodel×dk, W V\ni\n∈Rdmodel×dv\nand W O ∈Rhdv×dmodel.\nIn this work we employ h = 8 parallel attention layers, or heads. For each of these we use\ndk = dv = dmodel/h = 64. Due to the reduced dimension of each head, the total computational cost\nis similar to that of single-head attention with full dimensionality.\n3.2.3\nApplications of Attention in our Model\nThe Transformer uses multi-head attention in three different ways:\n• In \"encoder-decoder attention\" layers, the queries come from the previous decoder layer,\nand the memory keys and values come from the output of the encoder. This allows every\nposition in the decoder to attend over all positions in the input sequence. This mimics the\ntypical encoder-decoder attention mechanisms in sequence-to-sequence models such as\n[38, 2, 9].\n• The encoder contains self-attention layers. In a self-attention layer all of the keys, values\nand queries come from the same place, in this case, the output of the previous layer in the\nencoder. Each position in the encoder can attend to all positions in the previous layer of the\nencoder.\n• Similarly, self-attention layers in the decoder allow each position in the decoder to attend to\nall positions in the decoder up to and including that position. We need to prevent leftward\ninformation flow in the decoder to preserve the auto-regressive property. We implement this\ninside of scaled dot-product attention by masking out (setting to −∞) all values in the input\nof the softmax which correspond to illegal connections. See Figure 2.\n3.3\nPosition-wise Feed-Forward Networks\nIn addition to attention sub-layers, each of the layers in our encoder and decoder contains a fully\nconnected feed-forward network, which is applied to each position separately and identically. This\nconsists of two linear transformations with a ReLU activation in between.\nFFN(x) = max(0, xW1 + b1)W2 + b2\n(2)\nWhile the linear transformations are the same across different positions, they use different parameters\nfrom layer to layer. Another way of describing this is as two convolutions with kernel size 1.\nThe dimensionality of input and output is dmodel = 512, and the inner-layer has dimensionality\ndff = 2048.\n3.4\nEmbeddings and Softmax\nSimilarly to other sequence transduction models, we use learned embeddings to convert the input\ntokens and output tokens to vectors of dimension dmodel. We also use the usual learned linear transfor-\nmation and softmax function to convert the decoder output to predicted next-token probabilities. In\nour model, we share the same weight matrix between the two embedding layers and the pre-softmax\nlinear transformation, similar to [30]. In the embedding layers, we multiply those weights by √dmodel.\n5\n\n\n## PDF page 6\n\nTable 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations\nfor different layer types. n is the sequence length, d is the representation dimension, k is the kernel\nsize of convolutions and r the size of the neighborhood in restricted self-attention.\nLayer Type\nComplexity per Layer\nSequential\nMaximum Path Length\nOperations\nSelf-Attention\nO(n2 · d)\nO(1)\nO(1)\nRecurrent\nO(n · d2)\nO(n)\nO(n)\nConvolutional\nO(k · n · d2)\nO(1)\nO(logk(n))\nSelf-Attention (restricted)\nO(r · n · d)\nO(1)\nO(n/r)\n3.5\nPositional Encoding\nSince our model contains no recurrence and no convolution, in order for the model to make use of the\norder of the sequence, we must inject some information about the relative or absolute position of the\ntokens in the sequence. To this end, we add \"positional encodings\" to the input embeddings at the\nbottoms of the encoder and decoder stacks. The positional encodings have the same dimension dmodel\nas the embeddings, so that the two can be summed. There are many choices of positional encodings,\nlearned and fixed [9].\nIn this work, we use sine and cosine functions of different frequencies:\nPE(pos,2i) = sin(pos/100002i/dmodel)\nPE(pos,2i+1) = cos(pos/100002i/dmodel)\nwhere pos is the position and i is the dimension. That is, each dimension of the positional encoding\ncorresponds to a sinusoid. The wavelengths form a geometric progression from 2π to 10000 · 2π. We\nchose this function because we hypothesized it would allow the model to easily learn to attend by\nrelative positions, since for any fixed offset k, PEpos+k can be represented as a linear function of\nPEpos.\nWe also experimented with using learned positional embeddings [9] instead, and found that the two\nversions produced nearly identical results (see Table 3 row (E)). We chose the sinusoidal version\nbecause it may allow the model to extrapolate to sequence lengths longer than the ones encountered\nduring training.\n4\nWhy Self-Attention\nIn this section we compare various aspects of self-attention layers to the recurrent and convolu-\ntional layers commonly used for mapping one variable-length sequence of symbol representations\n(x1, ..., xn) to another sequence of equal length (z1, ..., zn), with xi, zi ∈Rd, such as a hidden\nlayer in a typical sequence transduction encoder or decoder. Motivating our use of self-attention we\nconsider three desiderata.\nOne is the total computational complexity per layer. Another is the amount of computation that can\nbe parallelized, as measured by the minimum number of sequential operations required.\nThe third is the path length between long-range dependencies in the network. Learning long-range\ndependencies is a key challenge in many sequence transduction tasks. One key factor affecting the\nability to learn such dependencies is the length of the paths forward and backward signals have to\ntraverse in the network. The shorter these paths between any combination of positions in the input\nand output sequences, the easier it is to learn long-range dependencies [12]. Hence we also compare\nthe maximum path length between any two input and output positions in networks composed of the\ndifferent layer types.\nAs noted in Table 1, a self-attention layer connects all positions with a constant number of sequentially\nexecuted operations, whereas a recurrent layer requires O(n) sequential operations. In terms of\ncomputational complexity, self-attention layers are faster than recurrent layers when the sequence\n6\n\n\n## PDF page 7\n\nlength n is smaller than the representation dimensionality d, which is most often the case with\nsentence representations used by state-of-the-art models in machine translations, such as word-piece\n[38] and byte-pair [31] representations. To improve computational performance for tasks involving\nvery long sequences, self-attention could be restricted to considering only a neighborhood of size r in\nthe input sequence centered around the respective output position. This would increase the maximum\npath length to O(n/r). We plan to investigate this approach further in future work.\nA single convolutional layer with kernel width k < n does not connect all pairs of input and output\npositions. Doing so requires a stack of O(n/k) convolutional layers in the case of contiguous kernels,\nor O(logk(n)) in the case of dilated convolutions [18], increasing the length of the longest paths\nbetween any two positions in the network. Convolutional layers are generally more expensive than\nrecurrent layers, by a factor of k. Separable convolutions [6], however, decrease the complexity\nconsiderably, to O(k · n · d + n · d2). Even with k = n, however, the complexity of a separable\nconvolution is equal to the combination of a self-attention layer and a point-wise feed-forward layer,\nthe approach we take in our model.\nAs side benefit, self-attention could yield more interpretable models. We inspect attention distributions\nfrom our models and present and discuss examples in the appendix. Not only do individual attention\nheads clearly learn to perform different tasks, many appear to exhibit behavior related to the syntactic\nand semantic structure of the sentences.\n5\nTraining\nThis section describes the training regime for our models.\n5.1\nTraining Data and Batching\nWe trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million\nsentence pairs. Sentences were encoded using byte-pair encoding [3], which has a shared source-\ntarget vocabulary of about 37000 tokens. For English-French, we used the significantly larger WMT\n2014 English-French dataset consisting of 36M sentences and split tokens into a 32000 word-piece\nvocabulary [38]. Sentence pairs were batched together by approximate sequence length. Each training\nbatch contained a set of sentence pairs containing approximately 25000 source tokens and 25000\ntarget tokens.\n5.2\nHardware and Schedule\nWe trained our models on one machine with 8 NVIDIA P100 GPUs. For our base models using\nthe hyperparameters described throughout the paper, each training step took about 0.4 seconds. We\ntrained the base models for a total of 100,000 steps or 12 hours. For our big models,(described on the\nbottom line of table 3), step time was 1.0 seconds. The big models were trained for 300,000 steps\n(3.5 days).\n5.3\nOptimizer\nWe used the Adam optimizer [20] with β1 = 0.9, β2 = 0.98 and ϵ = 109. We varied the learning\nrate over the course of training, according to the formula:\nlrate = d0.5\nmodel · min(step_num0.5, step_num · warmup_steps1.5)\n(3)\nThis corresponds to increasing the learning rate linearly for the first warmup_steps training steps,\nand decreasing it thereafter proportionally to the inverse square root of the step number. We used\nwarmup_steps = 4000.\n5.4\nRegularization\nWe employ three types of regularization during training:\n7\n\n\n## PDF page 8\n\nTable 2: The Transformer achieves better BLEU scores than previous state-of-the-art models on the\nEnglish-to-German and English-to-French newstest2014 tests at a fraction of the training cost.\nModel\nBLEU\nTraining Cost (FLOPs)\nEN-DE\nEN-FR\nEN-DE\nEN-FR\nByteNet [18]\n23.75\nDeep-Att + PosUnk [39]\n39.2\n1.0 · 1020\nGNMT + RL [38]\n24.6\n39.92\n2.3 · 1019\n1.4 · 1020\nConvS2S [9]\n25.16\n40.46\n9.6 · 1018\n1.5 · 1020\nMoE [32]\n26.03\n40.56\n2.0 · 1019\n1.2 · 1020\nDeep-Att + PosUnk Ensemble [39]\n40.4\n8.0 · 1020\nGNMT + RL Ensemble [38]\n26.30\n41.16\n1.8 · 1020\n1.1 · 1021\nConvS2S Ensemble [9]\n26.36\n41.29\n7.7 · 1019\n1.2 · 1021\nTransformer (base model)\n27.3\n38.1\n3.3 · 1018\nTransformer (big)\n28.4\n41.8\n2.3 · 1019\nResidual Dropout\nWe apply dropout [33] to the output of each sub-layer, before it is added to the\nsub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the\npositional encodings in both the encoder and decoder stacks. For the base model, we use a rate of\nPdrop = 0.1.\nLabel Smoothing\nDuring training, we employed label smoothing of value ϵls = 0.1 [36]. This\nhurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.\n6\nResults\n6.1\nMachine Translation\nOn the WMT 2014 English-to-German translation task, the big transformer model (Transformer (big)\nin Table 2) outperforms the best previously reported models (including ensembles) by more than 2.0\nBLEU, establishing a new state-of-the-art BLEU score of 28.4. The configuration of this model is\nlisted in the bottom line of Table 3. Training took 3.5 days on 8 P100 GPUs. Even our base model\nsurpasses all previously published models and ensembles, at a fraction of the training cost of any of\nthe competitive models.\nOn the WMT 2014 English-to-French translation task, our big model achieves a BLEU score of 41.0,\noutperforming all of the previously published single models, at less than 1/4 the training cost of the\nprevious state-of-the-art model. The Transformer (big) model trained for English-to-French used\ndropout rate Pdrop = 0.1, instead of 0.3.\nFor the base models, we used a single model obtained by averaging the last 5 checkpoints, which\nwere written at 10-minute intervals. For the big models, we averaged the last 20 checkpoints. We\nused beam search with a beam size of 4 and length penalty α = 0.6 [38]. These hyperparameters\nwere chosen after experimentation on the development set. We set the maximum output length during\ninference to input length + 50, but terminate early when possible [38].\nTable 2 summarizes our results and compares our translation quality and training costs to other model\narchitectures from the literature. We estimate the number of floating point operations used to train a\nmodel by multiplying the training time, the number of GPUs used, and an estimate of the sustained\nsingle-precision floating-point capacity of each GPU 5.\n6.2\nModel Variations\nTo evaluate the importance of different components of the Transformer, we varied our base model\nin different ways, measuring the change in performance on English-to-German translation on the\n5We used values of 2.8, 3.7, 6.0 and 9.5 TFLOPS for K80, K40, M40 and P100, respectively.\n8\n\n\n## PDF page 9\n\nTable 3: Variations on the Transformer architecture. Unlisted values are identical to those of the base\nmodel. All metrics are on the English-to-German translation development set, newstest2013. Listed\nperplexities are per-wordpiece, according to our byte-pair encoding, and should not be compared to\nper-word perplexities.\nN\ndmodel\ndff\nh\ndk\ndv\nPdrop\nϵls\ntrain\nPPL\nBLEU\nparams\nsteps\n(dev)\n(dev)\n×106\nbase\n6\n512\n2048\n8\n64\n64\n0.1\n0.1\n100K\n4.92\n25.8\n65\n(A)\n1\n512\n512\n5.29\n24.9\n4\n128\n128\n5.00\n25.5\n16\n32\n32\n4.91\n25.8\n32\n16\n16\n5.01\n25.4\n(B)\n16\n5.16\n25.1\n58\n32\n5.01\n25.4\n60\n(C)\n2\n6.11\n23.7\n36\n4\n5.19\n25.3\n50\n8\n4.88\n25.5\n80\n256\n32\n32\n5.75\n24.5\n28\n1024\n128\n128\n4.66\n26.0\n168\n1024\n5.12\n25.4\n53\n4096\n4.75\n26.2\n90\n(D)\n0.0\n5.77\n24.6\n0.2\n4.95\n25.5\n0.0\n4.67\n25.3\n0.2\n5.47\n25.7\n(E)\npositional embedding instead of sinusoids\n4.92\n25.7\nbig\n6\n1024\n4096\n16\n0.3\n300K\n4.33\n26.4\n213\ndevelopment set, newstest2013. We used beam search as described in the previous section, but no\ncheckpoint averaging. We present these results in Table 3.\nIn Table 3 rows (A), we vary the number of attention heads and the attention key and value dimensions,\nkeeping the amount of computation constant, as described in Section 3.2.2. While single-head\nattention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.\nIn Table 3 rows (B), we observe that reducing the attention key size dk hurts model quality. This\nsuggests that determining compatibility is not easy and that a more sophisticated compatibility\nfunction than dot product may be beneficial. We further observe in rows (C) and (D) that, as expected,\nbigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our\nsinusoidal positional encoding with learned positional embeddings [9], and observe nearly identical\nresults to the base model.\n6.3\nEnglish Constituency Parsing\nTo evaluate if the Transformer can generalize to other tasks we performed experiments on English\nconstituency parsing. This task presents specific challenges: the output is subject to strong structural\nconstraints and is significantly longer than the input. Furthermore, RNN sequence-to-sequence\nmodels have not been able to attain state-of-the-art results in small-data regimes [37].\nWe trained a 4-layer transformer with dmodel = 1024 on the Wall Street Journal (WSJ) portion of the\nPenn Treebank [25], about 40K training sentences. We also trained it in a semi-supervised setting,\nusing the larger high-confidence and BerkleyParser corpora from with approximately 17M sentences\n[37]. We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens\nfor the semi-supervised setting.\nWe performed only a small number of experiments to select the dropout, both attention and residual\n(section 5.4), learning rates and beam size on the Section 22 development set, all other parameters\nremained unchanged from the English-to-German base translation model. During inference, we\n9\n\n\n## PDF page 10\n\nTable 4: The Transformer generalizes well to English constituency parsing (Results are on Section 23\nof WSJ)\nParser\nTraining\nWSJ 23 F1\nVinyals & Kaiser el al. (2014) [37]\nWSJ only, discriminative\n88.3\nPetrov et al. (2006) [29]\nWSJ only, discriminative\n90.4\nZhu et al. (2013) [40]\nWSJ only, discriminative\n90.4\nDyer et al. (2016) [8]\nWSJ only, discriminative\n91.7\nTransformer (4 layers)\nWSJ only, discriminative\n91.3\nZhu et al. (2013) [40]\nsemi-supervised\n91.3\nHuang & Harper (2009) [14]\nsemi-supervised\n91.3\nMcClosky et al. (2006) [26]\nsemi-supervised\n92.1\nVinyals & Kaiser el al. (2014) [37]\nsemi-supervised\n92.1\nTransformer (4 layers)\nsemi-supervised\n92.7\nLuong et al. (2015) [23]\nmulti-task\n93.0\nDyer et al. (2016) [8]\ngenerative\n93.3\nincreased the maximum output length to input length + 300. We used a beam size of 21 and α = 0.3\nfor both WSJ only and the semi-supervised setting.\nOur results in Table 4 show that despite the lack of task-specific tuning our model performs sur-\nprisingly well, yielding better results than all previously reported models with the exception of the\nRecurrent Neural Network Grammar [8].\nIn contrast to RNN sequence-to-sequence models [37], the Transformer outperforms the Berkeley-\nParser [29] even when training only on the WSJ training set of 40K sentences.\n7\nConclusion\nIn this work, we presented the Transformer, the first sequence transduction model based entirely on\nattention, replacing the recurrent layers most commonly used in encoder-decoder architectures with\nmulti-headed self-attention.\nFor translation tasks, the Transformer can be trained significantly faster than architectures based\non recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014\nEnglish-to-French translation tasks, we achieve a new state of the art. In the former task our best\nmodel outperforms even all previously reported ensembles.\nWe are excited about the future of attention-based models and plan to apply them to other tasks. We\nplan to extend the Transformer to problems involving input and output modalities other than text and\nto investigate local, restricted attention mechanisms to efficiently handle large inputs and outputs\nsuch as images, audio and video. Making generation less sequential is another research goals of ours.\nThe code we used to train and evaluate our models is available at https://github.com/\ntensorflow/tensor2tensor.\nAcknowledgements\nWe are grateful to Nal Kalchbrenner and Stephan Gouws for their fruitful\ncomments, corrections and inspiration.\nReferences\n[1] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint\narXiv:1607.06450, 2016.\n[2] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly\nlearning to align and translate. CoRR, abs/1409.0473, 2014.\n[3] Denny Britz, Anna Goldie, Minh-Thang Luong, and Quoc V. Le. Massive exploration of neural\nmachine translation architectures. CoRR, abs/1703.03906, 2017.\n[4] Jianpeng Cheng, Li Dong, and Mirella Lapata. Long short-term memory-networks for machine\nreading. arXiv preprint arXiv:1601.06733, 2016.\n10\n\n\n## PDF page 11\n\n[5] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk,\nand Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical\nmachine translation. CoRR, abs/1406.1078, 2014.\n[6] Francois Chollet. Xception: Deep learning with depthwise separable convolutions. arXiv\npreprint arXiv:1610.02357, 2016.\n[7] Junyoung Chung, Çaglar Gülçehre, Kyunghyun Cho, and Yoshua Bengio. Empirical evaluation\nof gated recurrent neural networks on sequence modeling. CoRR, abs/1412.3555, 2014.\n[8] Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, and Noah A. Smith. Recurrent neural\nnetwork grammars. In Proc. of NAACL, 2016.\n[9] Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. Convolu-\ntional sequence to sequence learning. arXiv preprint arXiv:1705.03122v2, 2017.\n[10] Alex Graves.\nGenerating sequences with recurrent neural networks.\narXiv preprint\narXiv:1308.0850, 2013.\n[11] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for im-\nage recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern\nRecognition, pages 770778, 2016.\n[12] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber. Gradient flow in\nrecurrent nets: the difficulty of learning long-term dependencies, 2001.\n[13] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation,\n9(8):17351780, 1997.\n[14] Zhongqiang Huang and Mary Harper. Self-training PCFG grammars with latent annotations\nacross languages. In Proceedings of the 2009 Conference on Empirical Methods in Natural\nLanguage Processing, pages 832841. ACL, August 2009.\n[15] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring\nthe limits of language modeling. arXiv preprint arXiv:1602.02410, 2016.\n[16] Łukasz Kaiser and Samy Bengio. Can active memory replace attention? In Advances in Neural\nInformation Processing Systems, (NIPS), 2016.\n[17] Łukasz Kaiser and Ilya Sutskever. Neural GPUs learn algorithms. In International Conference\non Learning Representations (ICLR), 2016.\n[18] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Ko-\nray Kavukcuoglu. Neural machine translation in linear time. arXiv preprint arXiv:1610.10099v2,\n2017.\n[19] Yoon Kim, Carl Denton, Luong Hoang, and Alexander M. Rush. Structured attention networks.\nIn International Conference on Learning Representations, 2017.\n[20] Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.\n[21] Oleksii Kuchaiev and Boris Ginsburg. Factorization tricks for LSTM networks. arXiv preprint\narXiv:1703.10722, 2017.\n[22] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen\nZhou, and Yoshua Bengio. A structured self-attentive sentence embedding. arXiv preprint\narXiv:1703.03130, 2017.\n[23] Minh-Thang Luong, Quoc V. Le, Ilya Sutskever, Oriol Vinyals, and Lukasz Kaiser. Multi-task\nsequence to sequence learning. arXiv preprint arXiv:1511.06114, 2015.\n[24] Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-\nbased neural machine translation. arXiv preprint arXiv:1508.04025, 2015.\n11\n\n\n## PDF page 12\n\n[25] Mitchell P Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. Building a large annotated\ncorpus of english: The penn treebank. Computational linguistics, 19(2):313330, 1993.\n[26] David McClosky, Eugene Charniak, and Mark Johnson. Effective self-training for parsing. In\nProceedings of the Human Language Technology Conference of the NAACL, Main Conference,\npages 152159. ACL, June 2006.\n[27] Ankur Parikh, Oscar Täckström, Dipanjan Das, and Jakob Uszkoreit. A decomposable attention\nmodel. In Empirical Methods in Natural Language Processing, 2016.\n[28] Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive\nsummarization. arXiv preprint arXiv:1705.04304, 2017.\n[29] Slav Petrov, Leon Barrett, Romain Thibaux, and Dan Klein. Learning accurate, compact,\nand interpretable tree annotation. In Proceedings of the 21st International Conference on\nComputational Linguistics and 44th Annual Meeting of the ACL, pages 433440. ACL, July\n2006.\n[30] Ofir Press and Lior Wolf. Using the output embedding to improve language models. arXiv\npreprint arXiv:1608.05859, 2016.\n[31] Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words\nwith subword units. arXiv preprint arXiv:1508.07909, 2015.\n[32] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton,\nand Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts\nlayer. arXiv preprint arXiv:1701.06538, 2017.\n[33] Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdi-\nnov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine\nLearning Research, 15(1):19291958, 2014.\n[34] Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory\nnetworks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors,\nAdvances in Neural Information Processing Systems 28, pages 24402448. Curran Associates,\nInc., 2015.\n[35] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. Sequence to sequence learning with neural\nnetworks. In Advances in Neural Information Processing Systems, pages 31043112, 2014.\n[36] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna.\nRethinking the inception architecture for computer vision. CoRR, abs/1512.00567, 2015.\n[37] Vinyals & Kaiser, Koo, Petrov, Sutskever, and Hinton. Grammar as a foreign language. In\nAdvances in Neural Information Processing Systems, 2015.\n[38] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang\nMacherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Googles neural machine\ntranslation system: Bridging the gap between human and machine translation. arXiv preprint\narXiv:1609.08144, 2016.\n[39] Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. Deep recurrent models with\nfast-forward connections for neural machine translation. CoRR, abs/1606.04199, 2016.\n[40] Muhua Zhu, Yue Zhang, Wenliang Chen, Min Zhang, and Jingbo Zhu. Fast and accurate\nshift-reduce constituent parsing. In Proceedings of the 51st Annual Meeting of the ACL (Volume\n1: Long Papers), pages 434443. ACL, August 2013.\n12\n\n\n## PDF page 13\n\nAttention Visualizations\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nFigure 3: An example of the attention mechanism following long-distance dependencies in the\nencoder self-attention in layer 5 of 6. Many of the attention heads attend to a distant dependency of\nthe verb making, completing the phrase making...more difficult. Attentions here shown only for\nthe word making. Different colors represent different heads. Best viewed in color.\n13\n\n\n## PDF page 14\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 4: Two attention heads, also in layer 5 of 6, apparently involved in anaphora resolution. Top:\nFull attentions for head 5. Bottom: Isolated attentions from just the word its for attention heads 5\nand 6. Note that the attentions are very sharp for this word.\n14\n\n\n## PDF page 15\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 5: Many of the attention heads exhibit behaviour that seems related to the structure of the\nsentence. We give two such examples above, from two different heads from the encoder self-attention\nat layer 5 of 6. The heads clearly learned to perform different tasks.\n15\n\n\n可直接引用的图表文件(放在 Slidev public 目录,用 /文件名 引用):\n- paper_figure_1_transformer.pngFigure 1 from PDF page 3: The Transformer model architecture.\n- paper_figure_3_long_distance.pngFigure 3 from PDF page 13: Encoder self-attention following long-distance dependencies.\n- paper_figure_4_anaphora.pngFigure 4 from PDF page 14: Attention heads involved in anaphora resolution.\n\n请生成一版 10-20 页的完整初稿。内容必须忠于论文,至少引用上面列出的三张原论文图,并覆盖问题、Transformer 架构、注意力机制、训练、主要实验、局限和结论。不要复制长段原文;每页保持听众可读的信息密度。生成完整的 slides.md。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n- Proposes **Transformer** - a new network architecture based solely on attention mechanisms\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- Achieves state-of-the-art results on machine translation tasks:\n - 28.4 BLEU on WMT 2014 English-to-German\n - 41.8 BLEU on WMT 2014 English-to-French\n- Generalizes well to other tasks like English constituency parsing\n\n---\n\n## Background: Sequence Transduction Challenges\n\n### Traditional Approaches\n- **Recurrent models** (LSTM, GRU) have sequential computation\n- **Convolutional models** have limited long-range dependencies\n- Both have challenges with parallelization and long sequences\n\n### Attention Mechanisms\n- Already used in conjunction with recurrent networks\n- Allows modeling dependencies without regard to distance\n- But not used as the primary architecture... until now\n\n---\n\n## The Transformer: Key Idea\n\nReplace recurrence and convolution with **self-attention** to:\n- Enable more parallelization\n- Reduce sequential computation\n- Capture long-range dependencies more effectively\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n*Encoder (left) and Decoder (right) stacks with self-attention and feed-forward layers*\n\n---\n\n## Encoder Stack\n\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections around each sub-layer\n- Layer normalization after each sub-layer\n- All sub-layers produce outputs of dimension `d_model = 512`\n\n---\n\n## Decoder Stack\n\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward information flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Same residual connections and layer normalization as encoder\n- Output embeddings offset by one position (auto-regressive property)\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-40 mx-auto\" />\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder\n2. **Encoder self-attention**: All positions attend to all positions in previous encoder layer\n3. **Decoder self-attention**: Positions attend to previous positions (masked to preserve auto-regressive property)\n\n---\n\n## Positional Encoding\n\nSince there's no recurrence/convolution, we add positional information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performed similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Details\n\n### Data & Batching\n- WMT 2014 English-German (4.5M sentence pairs)\n- WMT 2014 English-French (36M sentence pairs)\n- Byte-pair encoding with shared vocabulary\n- Batches with ~25,000 source and target tokens\n\n### Hardware & Schedule\n- 8 NVIDIA P100 GPUs\n- Base model: 100,000 steps (12 hours)\n- Big model: 300,000 steps (3.5 days)\n\n---\n\n## Training Details (Cont.)\n\n### Optimizer\n- Adam with $\\beta_1 = 0.9$, $\\beta_2 = 0.98$, $\\epsilon = 10^{-9}$\n- Learning rate schedule:\n $$\\text{lrate} = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step\\_num}^{-0.5}, \\text{step\\_num} \\cdot \\text{warmup\\_steps}^{-1.5})$$\n- Warmup steps = 4000\n\n### Regularization\n- Residual dropout (P_drop = 0.1)\n- Label smoothing ($\\epsilon_{ls} = 0.1$)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n- 2+ BLEU improvement on English-to-German\n\n---\n\n## Model Architecture Ablations\n\n| Variation | Dev PPL | Dev BLEU |\n|-----------|---------|----------|\n| Base model | 4.92 | 25.8 |\n| (A) 1 attention head | 5.29 | 24.9 |\n| (B) d_k = 16 | 5.75 | 24.5 |\n| (C) 2 layers | 6.11 | 23.7 |\n| (D) No dropout | 5.77 | 24.6 |\n| (E) Learned positional embeddings | 4.92 | 25.7 |\n\n- Multi-head attention improves performance\n- Dropout is crucial for avoiding overfitting\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. (2014) | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Performs comparably to state-of-the-art parsers\n- Better than RNN models in small-data regimes\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion\n\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution\n- Achieved new state-of-the-art in machine translation:\n - 28.4 BLEU on English-to-German\n - 41.8 BLEU on English-to-French\n- More parallelizable and faster to train\n- Generalizes well to other tasks like constituency parsing\n\n---\n\n## Future Work\n\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "硬性验收失败:你刚才生成了 21 页,必须是 10–20 页。请在不删除三张原论文图、不丢失主要贡献的前提下合并或拆分内容,重新输出完整 slides.md;不得超过 20 页。"
}
],
"temperature": 0.3
},
"response": {
"id": "0217853848891531f1c2502e2c4024a5d577df8bf366bf3b57449",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n- Proposes **Transformer** - a new network architecture based solely on attention\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- State-of-the-art results:\n - 28.4 BLEU on WMT 2014 English-to-German\n - 41.8 BLEU on WMT 2014 English-to-French\n- Generalizes well to other tasks like English constituency parsing\n\n---\n\n## Background & Key Idea\n\n### Traditional Sequence Models\n- **Recurrent models** (LSTM, GRU): Sequential computation, limited parallelization\n- **Convolutional models**: Limited long-range dependencies\n\n### Attention Mechanism\n- Already used with recurrent networks\n- Allows modeling dependencies without regard to distance\n\n### The Transformer\n- **Key innovation**: Replace recurrence and convolution with self-attention\n- Enables more parallelization and better long-range dependencies\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n*Encoder (left) and Decoder (right) stacks with self-attention and feed-forward layers*\n\n---\n\n## Encoder & Decoder Stacks\n\n### Encoder\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Output dimension: `d_model = 512`\n\n### Decoder\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise feed-forward network\n- Same residual connections and layer normalization\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n### Applications\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder\n2. **Encoder self-attention**: All positions attend to all positions\n3. **Decoder self-attention**: Positions attend to previous positions (masked)\n\n---\n\n## Positional Encoding\n\nSince there's no recurrence/convolution, we add positional information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performed similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Details\n\n### Data & Batching\n- WMT 2014 English-German (4.5M pairs), English-French (36M pairs)\n- Byte-pair encoding with shared vocabulary\n- Batches with ~25,000 source and target tokens\n\n### Hardware & Schedule\n- 8 NVIDIA P100 GPUs\n- Base model: 100,000 steps (12 hours)\n- Big model: 300,000 steps (3.5 days)\n\n### Optimizer & Regularization\n- Adam with $\\beta_1=0.9$, $\\beta_2=0.98$, $\\epsilon=10^{-9}$\n- Learning rate schedule with warmup steps=4000\n- Residual dropout (P_drop=0.1) and label smoothing ($\\epsilon_{ls}=0.1$)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n- 2+ BLEU improvement on English-to-German\n\n---\n\n## Model Architecture Ablations\n\n| Variation | Dev PPL | Dev BLEU |\n|-----------|---------|----------|\n| Base model | 4.92 | 25.8 |\n| (A) 1 attention head | 5.29 | 24.9 |\n| (B) d_k = 16 | 5.75 | 24.5 |\n| (C) 2 layers | 6.11 | 23.7 |\n| (D) No dropout | 5.77 | 24.6 |\n| (E) Learned positional embeddings | 4.92 | 25.7 |\n\n- Multi-head attention improves performance\n- Dropout is crucial for avoiding overfitting\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. (2014) | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Performs comparably to state-of-the-art parsers\n- Better than RNN models in small-data regimes\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion & Future Work\n\n### Contributions\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution\n- Achieved new state-of-the-art in machine translation\n- More parallelizable and faster to train\n- Generalizes well to other tasks\n\n### Future Work\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
"usage": {
"prompt_tokens": 14039,
"completion_tokens": 2498,
"total_tokens": 16537,
"cached_prompt_tokens": 0
}
},
{
"meter": "Reviewer(每轮只看最新截图)",
"called_at_utc": "2026-07-30T04:16:32.803262+00:00",
"latency_s": 36.791,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名严格的演示文稿质量审核员(Reviewer)。你会看到一份由 Slidev 渲染出的 PPT,\n每张图对应一页幻灯片(按顺序编号,从第 1 页开始)。请逐页检查以下问题:\n\n- text_overflow(文字溢出/被裁切超出页面边界)\n- overcrowded(内容过多/过于拥挤/留白不足)\n- image_size(图片过大顶出布局,或过小看不清)\n- readability(字号过小、对比度差、代码块难读)\n- layout(对齐混乱、标题与正文比例失衡、空页)\n\n请以**目标用户是听众**的严格标准审查——一页幻灯片若要点超过约 5 条、或正文文字块偏长、\n或图片挤压了文字空间,都应视为 overcrowded/image_size 问题。报告真实存在的问题,\n但不要放过\"塞得太满\"。对每个问题给出:page(页码,整数)、\nissue_type(上面之一)、severityhigh/medium/low)、suggestion(具体、可执行的修改建议,中文)。\n\n同时给出:\n- overall_score0-100 的整体质量分(越高越好)\n- pass:布尔值,仅当整份 PPT **既无 high 也无 medium 级问题**、排版干净可读时才为 true\n\n严格输出如下 JSON(不要输出任何多余文字):\n{\n \"overall_score\": <int>,\n \"pass\": <bool>,\n \"issues\": [\n {\"page\": <int>, \"issue_type\": \"<type>\", \"severity\": \"<high|medium|low>\", \"suggestion\": \"<中文建议>\"}\n ]\n}"
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "这份 PPT 共 16 页,下面按页码顺序给出每一页的渲染截图。请审查。"
},
{
"type": "text",
"text": "第 1 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9d3c8d02979b8658be4dc98b1b914e4daf9ca6900e251a9c0d0c1225010ef208",
"characters": 61854,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 2 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "0237ef4a61a66c16e86fd2880d39d15aaecaee5a6eff36af9bd4e8eb9b10b609",
"characters": 141246,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 3 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "7bafd64b94888d1065a090f683a9be21b614e1bba5f293981577fe452ebe6847",
"characters": 183038,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 4 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "0f1e3f10d313881be2477aa0b1b8e7329625ed4a834e38ec12dde5c7273eb0e8",
"characters": 145738,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 5 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "3283184771a44ffa9aa34f231285f249e6116228f0cea33c67f6d52b6de3f546",
"characters": 182262,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 6 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "f70e0bd47cf494ba303dfe7f88cb8d219283630c8cb4baeac037da04491d3638",
"characters": 114878,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 7 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "5980aa7f94c3bb3104a6c73e5c261874ef30920272920db802816eef76d45679",
"characters": 194178,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 8 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "442651517bfe5d6e1e5266fab3860528d49fdec1adb8fa6f34c39c66815dfd36",
"characters": 134418,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 9 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "5efd2fcc4a905174a08f7b9096088f49e8c4e2108657f8ae31727fe06d7cd04d",
"characters": 137378,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 10 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "709824d31e940f80ba2bfe8450b87d3df9e99357691f3fa852e861d11b8903f8",
"characters": 206530,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 11 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "8d88a78345090d1f6c3b0002bd39cd29d1c952a52ac9a3053406115bbea25f53",
"characters": 148510,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 12 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "8e0fd326253c789830e85354294a4f82eafaaa74bad9a64251db5e06167aa1e2",
"characters": 151446,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 13 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "80e1b509b63763b2ef0356e2bcd261b9ce5ff04cd539ff51ced00ab71c91e932",
"characters": 163506,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 14 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "02448d527b957a87357b45ab823fda227379453f89ea260fb85c32a2449b831d",
"characters": 156810,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 15 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a9f429f56faab7207465334d8d0a2e58fe5c6bc29082a221cdf5b507a8879fb8",
"characters": 148794,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 16 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "2462762e83a47b119f3ba3ea283a73ffa89191b8521370a2becaaad864b5c109",
"characters": 206538,
"media_type": "image/png"
},
"detail": "high"
}
}
]
}
],
"temperature": 0.2
},
"response": {
"id": "021785384956257355cac89e6d983ae8d30678a5b54f9af7f572e",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "{\n \"overall_score\": 65,\n \"pass\": false,\n \"issues\": [\n {\"page\": 2, \"issue_type\": \"overcrowded\", \"severity\": \"medium\", \"suggestion\": \"将要点拆分为2页,例如将State-of-the-art results单独作为一页展示\"},\n {\"page\": 3, \"issue_type\": \"overcrowded\", \"severity\": \"medium\", \"suggestion\": \"将三个部分拆分为独立页面,每个部分单独一页详细说明\"},\n {\"page\": 4, \"issue_type\": \"image_size\", \"severity\": \"high\", \"suggestion\": \"放大架构图至占页面2/3空间,删除图片下方的文字说明或将其移至下一页\"},\n {\"page\": 4, \"issue_type\": \"overcrowded\", \"severity\": \"medium\", \"suggestion\": \"删除图片下方的长段文字,仅保留标题和简短说明\"},\n {\"page\": 5, \"issue_type\": \"overcrowded\", \"severity\": \"medium\", \"suggestion\": \"将Encoder和Decoder分拆为两页,每页单独详细说明其结构\"},\n {\"page\": 7, \"issue_type\": \"overcrowded\", \"severity\": \"medium\", \"suggestion\": \"将Multi-Head Attention原理和Applications分拆为两页\"},\n {\"page\": 10, \"issue_type\": \"overcrowded\", \"severity\": \"high\", \"suggestion\": \"将Data & Batching、Hardware & Schedule、Optimizer & Regularization三个部分拆分为3页\"},\n {\"page\": 14, \"issue_type\": \"image_size\", \"severity\": \"high\", \"suggestion\": \"放大注意力可视化图,使其占满页面,确保文字和连线清晰可见\"},\n {\"page\": 15, \"issue_type\": \"image_size\", \"severity\": \"high\", \"suggestion\": \"放大注意力可视化图,增加对比度,确保不同颜色的注意力头可区分\"},\n {\"page\": 16, \"issue_type\": \"overcrowded\", \"severity\": \"medium\", \"suggestion\": \"将Contributions和Future Work分拆为两页,每部分保留3-4个要点\"}\n ]\n}"
},
"usage": {
"prompt_tokens": 19426,
"completion_tokens": 1597,
"total_tokens": 21023,
"cached_prompt_tokens": 0
}
},
{
"meter": "Proposer(纯文本)",
"called_at_utc": "2026-07-30T04:17:23.402701+00:00",
"latency_s": 50.599,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名擅长把学术论文转化为演示文稿的 Proposer Agent。\n你用 Slidev 框架(Markdown + HTML)编写 PPT 源码 slides.md。\n\nSlidev 语法要点:\n- 文件开头是 YAML frontmatter--- 包裹),设置 theme: default。\n- 用单独一行的 `---`(前后空行)分隔每一页幻灯片。\n- 首页通常放标题、作者、会议。\n- 引用图片用 markdown![说明](/图片文件名.png),可用 HTML 控制尺寸,\n 例如 <img src=\"/speedup_bar.png\" class=\"h-60 mx-auto\" />。\n- 可用 Windi/Uno CSS 工具类控制排版(如 text-sm、grid grid-cols-2 gap-4)。\n\n要求:\n- 最终生成 10-20 页,覆盖论文的标题、背景/动机、方法、实验结果、局限与结论。\n- 至少在 3 页中使用提供的图表/表格,且图文匹配。\n- 每页信息量适中、不要塞太多字,宁可拆页也不要溢出。\n- 只输出 slides.md 的完整内容,用 ```markdown 代码块包裹,不要额外解释。"
},
{
"role": "user",
"content": "以下是论文全文(Markdown):\n\n# Attention Is All You Need\n\nAuthors: Ashish Vaswani et al.\n\n\n## PDF page 1\n\nProvided proper attribution is provided, Google hereby grants permission to\nreproduce the tables and figures in this paper solely for use in journalistic or\nscholarly works.\nAttention Is All You Need\nAshish Vaswani\nGoogle Brain\navaswani@google.com\nNoam Shazeer\nGoogle Brain\nnoam@google.com\nNiki Parmar\nGoogle Research\nnikip@google.com\nJakob Uszkoreit\nGoogle Research\nusz@google.com\nLlion Jones\nGoogle Research\nllion@google.com\nAidan N. Gomez∗†\nUniversity of Toronto\naidan@cs.toronto.edu\nŁukasz Kaiser\nGoogle Brain\nlukaszkaiser@google.com\nIllia Polosukhin∗‡\nillia.polosukhin@gmail.com\nAbstract\nThe dominant sequence transduction models are based on complex recurrent or\nconvolutional neural networks that include an encoder and a decoder. The best\nperforming models also connect the encoder and decoder through an attention\nmechanism. We propose a new simple network architecture, the Transformer,\nbased solely on attention mechanisms, dispensing with recurrence and convolutions\nentirely. Experiments on two machine translation tasks show these models to\nbe superior in quality while being more parallelizable and requiring significantly\nless time to train. Our model achieves 28.4 BLEU on the WMT 2014 English-\nto-German translation task, improving over the existing best results, including\nensembles, by over 2 BLEU. On the WMT 2014 English-to-French translation task,\nour model establishes a new single-model state-of-the-art BLEU score of 41.8 after\ntraining for 3.5 days on eight GPUs, a small fraction of the training costs of the\nbest models from the literature. We show that the Transformer generalizes well to\nother tasks by applying it successfully to English constituency parsing both with\nlarge and limited training data.\nEqual contribution. Listing order is random. Jakob proposed replacing RNNs with self-attention and started\nthe effort to evaluate this idea. Ashish, with Illia, designed and implemented the first Transformer models and\nhas been crucially involved in every aspect of this work. Noam proposed scaled dot-product attention, multi-head\nattention and the parameter-free position representation and became the other person involved in nearly every\ndetail. Niki designed, implemented, tuned and evaluated countless model variants in our original codebase and\ntensor2tensor. Llion also experimented with novel model variants, was responsible for our initial codebase, and\nefficient inference and visualizations. Lukasz and Aidan spent countless long days designing various parts of and\nimplementing tensor2tensor, replacing our earlier codebase, greatly improving results and massively accelerating\nour research.\n†Work performed while at Google Brain.\n‡Work performed while at Google Research.\n31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA.\narXiv:1706.03762v7 [cs.CL] 2 Aug 2023\n\n\n## PDF page 2\n\n1\nIntroduction\nRecurrent neural networks, long short-term memory [13] and gated recurrent [7] neural networks\nin particular, have been firmly established as state of the art approaches in sequence modeling and\ntransduction problems such as language modeling and machine translation [35, 2, 5]. Numerous\nefforts have since continued to push the boundaries of recurrent language models and encoder-decoder\narchitectures [38, 24, 15].\nRecurrent models typically factor computation along the symbol positions of the input and output\nsequences. Aligning the positions to steps in computation time, they generate a sequence of hidden\nstates ht, as a function of the previous hidden state ht1 and the input for position t. This inherently\nsequential nature precludes parallelization within training examples, which becomes critical at longer\nsequence lengths, as memory constraints limit batching across examples. Recent work has achieved\nsignificant improvements in computational efficiency through factorization tricks [21] and conditional\ncomputation [32], while also improving model performance in case of the latter. The fundamental\nconstraint of sequential computation, however, remains.\nAttention mechanisms have become an integral part of compelling sequence modeling and transduc-\ntion models in various tasks, allowing modeling of dependencies without regard to their distance in\nthe input or output sequences [2, 19]. In all but a few cases [27], however, such attention mechanisms\nare used in conjunction with a recurrent network.\nIn this work we propose the Transformer, a model architecture eschewing recurrence and instead\nrelying entirely on an attention mechanism to draw global dependencies between input and output.\nThe Transformer allows for significantly more parallelization and can reach a new state of the art in\ntranslation quality after being trained for as little as twelve hours on eight P100 GPUs.\n2\nBackground\nThe goal of reducing sequential computation also forms the foundation of the Extended Neural GPU\n[16], ByteNet [18] and ConvS2S [9], all of which use convolutional neural networks as basic building\nblock, computing hidden representations in parallel for all input and output positions. In these models,\nthe number of operations required to relate signals from two arbitrary input or output positions grows\nin the distance between positions, linearly for ConvS2S and logarithmically for ByteNet. This makes\nit more difficult to learn dependencies between distant positions [12]. In the Transformer this is\nreduced to a constant number of operations, albeit at the cost of reduced effective resolution due\nto averaging attention-weighted positions, an effect we counteract with Multi-Head Attention as\ndescribed in section 3.2.\nSelf-attention, sometimes called intra-attention is an attention mechanism relating different positions\nof a single sequence in order to compute a representation of the sequence. Self-attention has been\nused successfully in a variety of tasks including reading comprehension, abstractive summarization,\ntextual entailment and learning task-independent sentence representations [4, 27, 28, 22].\nEnd-to-end memory networks are based on a recurrent attention mechanism instead of sequence-\naligned recurrence and have been shown to perform well on simple-language question answering and\nlanguage modeling tasks [34].\nTo the best of our knowledge, however, the Transformer is the first transduction model relying\nentirely on self-attention to compute representations of its input and output without using sequence-\naligned RNNs or convolution. In the following sections, we will describe the Transformer, motivate\nself-attention and discuss its advantages over models such as [17, 18] and [9].\n3\nModel Architecture\nMost competitive neural sequence transduction models have an encoder-decoder structure [5, 2, 35].\nHere, the encoder maps an input sequence of symbol representations (x1, ..., xn) to a sequence\nof continuous representations z = (z1, ..., zn). Given z, the decoder then generates an output\nsequence (y1, ..., ym) of symbols one element at a time. At each step the model is auto-regressive\n[10], consuming the previously generated symbols as additional input when generating the next.\n2\n\n\n## PDF page 3\n\nFigure 1: The Transformer - model architecture.\nThe Transformer follows this overall architecture using stacked self-attention and point-wise, fully\nconnected layers for both the encoder and decoder, shown in the left and right halves of Figure 1,\nrespectively.\n3.1\nEncoder and Decoder Stacks\nEncoder:\nThe encoder is composed of a stack of N = 6 identical layers. Each layer has two\nsub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, position-\nwise fully connected feed-forward network. We employ a residual connection [11] around each of\nthe two sub-layers, followed by layer normalization [1]. That is, the output of each sub-layer is\nLayerNorm(x + Sublayer(x)), where Sublayer(x) is the function implemented by the sub-layer\nitself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding\nlayers, produce outputs of dimension dmodel = 512.\nDecoder:\nThe decoder is also composed of a stack of N = 6 identical layers. In addition to the two\nsub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head\nattention over the output of the encoder stack. Similar to the encoder, we employ residual connections\naround each of the sub-layers, followed by layer normalization. We also modify the self-attention\nsub-layer in the decoder stack to prevent positions from attending to subsequent positions. This\nmasking, combined with fact that the output embeddings are offset by one position, ensures that the\npredictions for position i can depend only on the known outputs at positions less than i.\n3.2\nAttention\nAn attention function can be described as mapping a query and a set of key-value pairs to an output,\nwhere the query, keys, values, and output are all vectors. The output is computed as a weighted sum\n3\n\n\n## PDF page 4\n\nScaled Dot-Product Attention\nMulti-Head Attention\nFigure 2: (left) Scaled Dot-Product Attention. (right) Multi-Head Attention consists of several\nattention layers running in parallel.\nof the values, where the weight assigned to each value is computed by a compatibility function of the\nquery with the corresponding key.\n3.2.1\nScaled Dot-Product Attention\nWe call our particular attention \"Scaled Dot-Product Attention\" (Figure 2). The input consists of\nqueries and keys of dimension dk, and values of dimension dv. We compute the dot products of the\nquery with all keys, divide each by √dk, and apply a softmax function to obtain the weights on the\nvalues.\nIn practice, we compute the attention function on a set of queries simultaneously, packed together\ninto a matrix Q. The keys and values are also packed together into matrices K and V . We compute\nthe matrix of outputs as:\nAttention(Q, K, V ) = softmax(QKT\n√dk\n)V\n(1)\nThe two most commonly used attention functions are additive attention [2], and dot-product (multi-\nplicative) attention. Dot-product attention is identical to our algorithm, except for the scaling factor\nof\n1\n√dk . Additive attention computes the compatibility function using a feed-forward network with\na single hidden layer. While the two are similar in theoretical complexity, dot-product attention is\nmuch faster and more space-efficient in practice, since it can be implemented using highly optimized\nmatrix multiplication code.\nWhile for small values of dk the two mechanisms perform similarly, additive attention outperforms\ndot product attention without scaling for larger values of dk [3]. We suspect that for large values of\ndk, the dot products grow large in magnitude, pushing the softmax function into regions where it has\nextremely small gradients 4. To counteract this effect, we scale the dot products by\n1\n√dk .\n3.2.2\nMulti-Head Attention\nInstead of performing a single attention function with dmodel-dimensional keys, values and queries,\nwe found it beneficial to linearly project the queries, keys and values h times with different, learned\nlinear projections to dk, dk and dv dimensions, respectively. On each of these projected versions of\nqueries, keys and values we then perform the attention function in parallel, yielding dv-dimensional\n4To illustrate why the dot products get large, assume that the components of q and k are independent random\nvariables with mean 0 and variance 1. Then their dot product, q · k = Pdk\ni=1 qiki, has mean 0 and variance dk.\n4\n\n\n## PDF page 5\n\noutput values. These are concatenated and once again projected, resulting in the final values, as\ndepicted in Figure 2.\nMulti-head attention allows the model to jointly attend to information from different representation\nsubspaces at different positions. With a single attention head, averaging inhibits this.\nMultiHead(Q, K, V ) = Concat(head1, ..., headh)W O\nwhere headi = Attention(QW Q\ni , KW K\ni , V W V\ni )\nWhere the projections are parameter matrices W Q\ni\n∈Rdmodel×dk, W K\ni\n∈Rdmodel×dk, W V\ni\n∈Rdmodel×dv\nand W O ∈Rhdv×dmodel.\nIn this work we employ h = 8 parallel attention layers, or heads. For each of these we use\ndk = dv = dmodel/h = 64. Due to the reduced dimension of each head, the total computational cost\nis similar to that of single-head attention with full dimensionality.\n3.2.3\nApplications of Attention in our Model\nThe Transformer uses multi-head attention in three different ways:\n• In \"encoder-decoder attention\" layers, the queries come from the previous decoder layer,\nand the memory keys and values come from the output of the encoder. This allows every\nposition in the decoder to attend over all positions in the input sequence. This mimics the\ntypical encoder-decoder attention mechanisms in sequence-to-sequence models such as\n[38, 2, 9].\n• The encoder contains self-attention layers. In a self-attention layer all of the keys, values\nand queries come from the same place, in this case, the output of the previous layer in the\nencoder. Each position in the encoder can attend to all positions in the previous layer of the\nencoder.\n• Similarly, self-attention layers in the decoder allow each position in the decoder to attend to\nall positions in the decoder up to and including that position. We need to prevent leftward\ninformation flow in the decoder to preserve the auto-regressive property. We implement this\ninside of scaled dot-product attention by masking out (setting to −∞) all values in the input\nof the softmax which correspond to illegal connections. See Figure 2.\n3.3\nPosition-wise Feed-Forward Networks\nIn addition to attention sub-layers, each of the layers in our encoder and decoder contains a fully\nconnected feed-forward network, which is applied to each position separately and identically. This\nconsists of two linear transformations with a ReLU activation in between.\nFFN(x) = max(0, xW1 + b1)W2 + b2\n(2)\nWhile the linear transformations are the same across different positions, they use different parameters\nfrom layer to layer. Another way of describing this is as two convolutions with kernel size 1.\nThe dimensionality of input and output is dmodel = 512, and the inner-layer has dimensionality\ndff = 2048.\n3.4\nEmbeddings and Softmax\nSimilarly to other sequence transduction models, we use learned embeddings to convert the input\ntokens and output tokens to vectors of dimension dmodel. We also use the usual learned linear transfor-\nmation and softmax function to convert the decoder output to predicted next-token probabilities. In\nour model, we share the same weight matrix between the two embedding layers and the pre-softmax\nlinear transformation, similar to [30]. In the embedding layers, we multiply those weights by √dmodel.\n5\n\n\n## PDF page 6\n\nTable 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations\nfor different layer types. n is the sequence length, d is the representation dimension, k is the kernel\nsize of convolutions and r the size of the neighborhood in restricted self-attention.\nLayer Type\nComplexity per Layer\nSequential\nMaximum Path Length\nOperations\nSelf-Attention\nO(n2 · d)\nO(1)\nO(1)\nRecurrent\nO(n · d2)\nO(n)\nO(n)\nConvolutional\nO(k · n · d2)\nO(1)\nO(logk(n))\nSelf-Attention (restricted)\nO(r · n · d)\nO(1)\nO(n/r)\n3.5\nPositional Encoding\nSince our model contains no recurrence and no convolution, in order for the model to make use of the\norder of the sequence, we must inject some information about the relative or absolute position of the\ntokens in the sequence. To this end, we add \"positional encodings\" to the input embeddings at the\nbottoms of the encoder and decoder stacks. The positional encodings have the same dimension dmodel\nas the embeddings, so that the two can be summed. There are many choices of positional encodings,\nlearned and fixed [9].\nIn this work, we use sine and cosine functions of different frequencies:\nPE(pos,2i) = sin(pos/100002i/dmodel)\nPE(pos,2i+1) = cos(pos/100002i/dmodel)\nwhere pos is the position and i is the dimension. That is, each dimension of the positional encoding\ncorresponds to a sinusoid. The wavelengths form a geometric progression from 2π to 10000 · 2π. We\nchose this function because we hypothesized it would allow the model to easily learn to attend by\nrelative positions, since for any fixed offset k, PEpos+k can be represented as a linear function of\nPEpos.\nWe also experimented with using learned positional embeddings [9] instead, and found that the two\nversions produced nearly identical results (see Table 3 row (E)). We chose the sinusoidal version\nbecause it may allow the model to extrapolate to sequence lengths longer than the ones encountered\nduring training.\n4\nWhy Self-Attention\nIn this section we compare various aspects of self-attention layers to the recurrent and convolu-\ntional layers commonly used for mapping one variable-length sequence of symbol representations\n(x1, ..., xn) to another sequence of equal length (z1, ..., zn), with xi, zi ∈Rd, such as a hidden\nlayer in a typical sequence transduction encoder or decoder. Motivating our use of self-attention we\nconsider three desiderata.\nOne is the total computational complexity per layer. Another is the amount of computation that can\nbe parallelized, as measured by the minimum number of sequential operations required.\nThe third is the path length between long-range dependencies in the network. Learning long-range\ndependencies is a key challenge in many sequence transduction tasks. One key factor affecting the\nability to learn such dependencies is the length of the paths forward and backward signals have to\ntraverse in the network. The shorter these paths between any combination of positions in the input\nand output sequences, the easier it is to learn long-range dependencies [12]. Hence we also compare\nthe maximum path length between any two input and output positions in networks composed of the\ndifferent layer types.\nAs noted in Table 1, a self-attention layer connects all positions with a constant number of sequentially\nexecuted operations, whereas a recurrent layer requires O(n) sequential operations. In terms of\ncomputational complexity, self-attention layers are faster than recurrent layers when the sequence\n6\n\n\n## PDF page 7\n\nlength n is smaller than the representation dimensionality d, which is most often the case with\nsentence representations used by state-of-the-art models in machine translations, such as word-piece\n[38] and byte-pair [31] representations. To improve computational performance for tasks involving\nvery long sequences, self-attention could be restricted to considering only a neighborhood of size r in\nthe input sequence centered around the respective output position. This would increase the maximum\npath length to O(n/r). We plan to investigate this approach further in future work.\nA single convolutional layer with kernel width k < n does not connect all pairs of input and output\npositions. Doing so requires a stack of O(n/k) convolutional layers in the case of contiguous kernels,\nor O(logk(n)) in the case of dilated convolutions [18], increasing the length of the longest paths\nbetween any two positions in the network. Convolutional layers are generally more expensive than\nrecurrent layers, by a factor of k. Separable convolutions [6], however, decrease the complexity\nconsiderably, to O(k · n · d + n · d2). Even with k = n, however, the complexity of a separable\nconvolution is equal to the combination of a self-attention layer and a point-wise feed-forward layer,\nthe approach we take in our model.\nAs side benefit, self-attention could yield more interpretable models. We inspect attention distributions\nfrom our models and present and discuss examples in the appendix. Not only do individual attention\nheads clearly learn to perform different tasks, many appear to exhibit behavior related to the syntactic\nand semantic structure of the sentences.\n5\nTraining\nThis section describes the training regime for our models.\n5.1\nTraining Data and Batching\nWe trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million\nsentence pairs. Sentences were encoded using byte-pair encoding [3], which has a shared source-\ntarget vocabulary of about 37000 tokens. For English-French, we used the significantly larger WMT\n2014 English-French dataset consisting of 36M sentences and split tokens into a 32000 word-piece\nvocabulary [38]. Sentence pairs were batched together by approximate sequence length. Each training\nbatch contained a set of sentence pairs containing approximately 25000 source tokens and 25000\ntarget tokens.\n5.2\nHardware and Schedule\nWe trained our models on one machine with 8 NVIDIA P100 GPUs. For our base models using\nthe hyperparameters described throughout the paper, each training step took about 0.4 seconds. We\ntrained the base models for a total of 100,000 steps or 12 hours. For our big models,(described on the\nbottom line of table 3), step time was 1.0 seconds. The big models were trained for 300,000 steps\n(3.5 days).\n5.3\nOptimizer\nWe used the Adam optimizer [20] with β1 = 0.9, β2 = 0.98 and ϵ = 109. We varied the learning\nrate over the course of training, according to the formula:\nlrate = d0.5\nmodel · min(step_num0.5, step_num · warmup_steps1.5)\n(3)\nThis corresponds to increasing the learning rate linearly for the first warmup_steps training steps,\nand decreasing it thereafter proportionally to the inverse square root of the step number. We used\nwarmup_steps = 4000.\n5.4\nRegularization\nWe employ three types of regularization during training:\n7\n\n\n## PDF page 8\n\nTable 2: The Transformer achieves better BLEU scores than previous state-of-the-art models on the\nEnglish-to-German and English-to-French newstest2014 tests at a fraction of the training cost.\nModel\nBLEU\nTraining Cost (FLOPs)\nEN-DE\nEN-FR\nEN-DE\nEN-FR\nByteNet [18]\n23.75\nDeep-Att + PosUnk [39]\n39.2\n1.0 · 1020\nGNMT + RL [38]\n24.6\n39.92\n2.3 · 1019\n1.4 · 1020\nConvS2S [9]\n25.16\n40.46\n9.6 · 1018\n1.5 · 1020\nMoE [32]\n26.03\n40.56\n2.0 · 1019\n1.2 · 1020\nDeep-Att + PosUnk Ensemble [39]\n40.4\n8.0 · 1020\nGNMT + RL Ensemble [38]\n26.30\n41.16\n1.8 · 1020\n1.1 · 1021\nConvS2S Ensemble [9]\n26.36\n41.29\n7.7 · 1019\n1.2 · 1021\nTransformer (base model)\n27.3\n38.1\n3.3 · 1018\nTransformer (big)\n28.4\n41.8\n2.3 · 1019\nResidual Dropout\nWe apply dropout [33] to the output of each sub-layer, before it is added to the\nsub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the\npositional encodings in both the encoder and decoder stacks. For the base model, we use a rate of\nPdrop = 0.1.\nLabel Smoothing\nDuring training, we employed label smoothing of value ϵls = 0.1 [36]. This\nhurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.\n6\nResults\n6.1\nMachine Translation\nOn the WMT 2014 English-to-German translation task, the big transformer model (Transformer (big)\nin Table 2) outperforms the best previously reported models (including ensembles) by more than 2.0\nBLEU, establishing a new state-of-the-art BLEU score of 28.4. The configuration of this model is\nlisted in the bottom line of Table 3. Training took 3.5 days on 8 P100 GPUs. Even our base model\nsurpasses all previously published models and ensembles, at a fraction of the training cost of any of\nthe competitive models.\nOn the WMT 2014 English-to-French translation task, our big model achieves a BLEU score of 41.0,\noutperforming all of the previously published single models, at less than 1/4 the training cost of the\nprevious state-of-the-art model. The Transformer (big) model trained for English-to-French used\ndropout rate Pdrop = 0.1, instead of 0.3.\nFor the base models, we used a single model obtained by averaging the last 5 checkpoints, which\nwere written at 10-minute intervals. For the big models, we averaged the last 20 checkpoints. We\nused beam search with a beam size of 4 and length penalty α = 0.6 [38]. These hyperparameters\nwere chosen after experimentation on the development set. We set the maximum output length during\ninference to input length + 50, but terminate early when possible [38].\nTable 2 summarizes our results and compares our translation quality and training costs to other model\narchitectures from the literature. We estimate the number of floating point operations used to train a\nmodel by multiplying the training time, the number of GPUs used, and an estimate of the sustained\nsingle-precision floating-point capacity of each GPU 5.\n6.2\nModel Variations\nTo evaluate the importance of different components of the Transformer, we varied our base model\nin different ways, measuring the change in performance on English-to-German translation on the\n5We used values of 2.8, 3.7, 6.0 and 9.5 TFLOPS for K80, K40, M40 and P100, respectively.\n8\n\n\n## PDF page 9\n\nTable 3: Variations on the Transformer architecture. Unlisted values are identical to those of the base\nmodel. All metrics are on the English-to-German translation development set, newstest2013. Listed\nperplexities are per-wordpiece, according to our byte-pair encoding, and should not be compared to\nper-word perplexities.\nN\ndmodel\ndff\nh\ndk\ndv\nPdrop\nϵls\ntrain\nPPL\nBLEU\nparams\nsteps\n(dev)\n(dev)\n×106\nbase\n6\n512\n2048\n8\n64\n64\n0.1\n0.1\n100K\n4.92\n25.8\n65\n(A)\n1\n512\n512\n5.29\n24.9\n4\n128\n128\n5.00\n25.5\n16\n32\n32\n4.91\n25.8\n32\n16\n16\n5.01\n25.4\n(B)\n16\n5.16\n25.1\n58\n32\n5.01\n25.4\n60\n(C)\n2\n6.11\n23.7\n36\n4\n5.19\n25.3\n50\n8\n4.88\n25.5\n80\n256\n32\n32\n5.75\n24.5\n28\n1024\n128\n128\n4.66\n26.0\n168\n1024\n5.12\n25.4\n53\n4096\n4.75\n26.2\n90\n(D)\n0.0\n5.77\n24.6\n0.2\n4.95\n25.5\n0.0\n4.67\n25.3\n0.2\n5.47\n25.7\n(E)\npositional embedding instead of sinusoids\n4.92\n25.7\nbig\n6\n1024\n4096\n16\n0.3\n300K\n4.33\n26.4\n213\ndevelopment set, newstest2013. We used beam search as described in the previous section, but no\ncheckpoint averaging. We present these results in Table 3.\nIn Table 3 rows (A), we vary the number of attention heads and the attention key and value dimensions,\nkeeping the amount of computation constant, as described in Section 3.2.2. While single-head\nattention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.\nIn Table 3 rows (B), we observe that reducing the attention key size dk hurts model quality. This\nsuggests that determining compatibility is not easy and that a more sophisticated compatibility\nfunction than dot product may be beneficial. We further observe in rows (C) and (D) that, as expected,\nbigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our\nsinusoidal positional encoding with learned positional embeddings [9], and observe nearly identical\nresults to the base model.\n6.3\nEnglish Constituency Parsing\nTo evaluate if the Transformer can generalize to other tasks we performed experiments on English\nconstituency parsing. This task presents specific challenges: the output is subject to strong structural\nconstraints and is significantly longer than the input. Furthermore, RNN sequence-to-sequence\nmodels have not been able to attain state-of-the-art results in small-data regimes [37].\nWe trained a 4-layer transformer with dmodel = 1024 on the Wall Street Journal (WSJ) portion of the\nPenn Treebank [25], about 40K training sentences. We also trained it in a semi-supervised setting,\nusing the larger high-confidence and BerkleyParser corpora from with approximately 17M sentences\n[37]. We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens\nfor the semi-supervised setting.\nWe performed only a small number of experiments to select the dropout, both attention and residual\n(section 5.4), learning rates and beam size on the Section 22 development set, all other parameters\nremained unchanged from the English-to-German base translation model. During inference, we\n9\n\n\n## PDF page 10\n\nTable 4: The Transformer generalizes well to English constituency parsing (Results are on Section 23\nof WSJ)\nParser\nTraining\nWSJ 23 F1\nVinyals & Kaiser el al. (2014) [37]\nWSJ only, discriminative\n88.3\nPetrov et al. (2006) [29]\nWSJ only, discriminative\n90.4\nZhu et al. (2013) [40]\nWSJ only, discriminative\n90.4\nDyer et al. (2016) [8]\nWSJ only, discriminative\n91.7\nTransformer (4 layers)\nWSJ only, discriminative\n91.3\nZhu et al. (2013) [40]\nsemi-supervised\n91.3\nHuang & Harper (2009) [14]\nsemi-supervised\n91.3\nMcClosky et al. (2006) [26]\nsemi-supervised\n92.1\nVinyals & Kaiser el al. (2014) [37]\nsemi-supervised\n92.1\nTransformer (4 layers)\nsemi-supervised\n92.7\nLuong et al. (2015) [23]\nmulti-task\n93.0\nDyer et al. (2016) [8]\ngenerative\n93.3\nincreased the maximum output length to input length + 300. We used a beam size of 21 and α = 0.3\nfor both WSJ only and the semi-supervised setting.\nOur results in Table 4 show that despite the lack of task-specific tuning our model performs sur-\nprisingly well, yielding better results than all previously reported models with the exception of the\nRecurrent Neural Network Grammar [8].\nIn contrast to RNN sequence-to-sequence models [37], the Transformer outperforms the Berkeley-\nParser [29] even when training only on the WSJ training set of 40K sentences.\n7\nConclusion\nIn this work, we presented the Transformer, the first sequence transduction model based entirely on\nattention, replacing the recurrent layers most commonly used in encoder-decoder architectures with\nmulti-headed self-attention.\nFor translation tasks, the Transformer can be trained significantly faster than architectures based\non recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014\nEnglish-to-French translation tasks, we achieve a new state of the art. In the former task our best\nmodel outperforms even all previously reported ensembles.\nWe are excited about the future of attention-based models and plan to apply them to other tasks. We\nplan to extend the Transformer to problems involving input and output modalities other than text and\nto investigate local, restricted attention mechanisms to efficiently handle large inputs and outputs\nsuch as images, audio and video. Making generation less sequential is another research goals of ours.\nThe code we used to train and evaluate our models is available at https://github.com/\ntensorflow/tensor2tensor.\nAcknowledgements\nWe are grateful to Nal Kalchbrenner and Stephan Gouws for their fruitful\ncomments, corrections and inspiration.\nReferences\n[1] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint\narXiv:1607.06450, 2016.\n[2] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly\nlearning to align and translate. CoRR, abs/1409.0473, 2014.\n[3] Denny Britz, Anna Goldie, Minh-Thang Luong, and Quoc V. Le. Massive exploration of neural\nmachine translation architectures. CoRR, abs/1703.03906, 2017.\n[4] Jianpeng Cheng, Li Dong, and Mirella Lapata. Long short-term memory-networks for machine\nreading. arXiv preprint arXiv:1601.06733, 2016.\n10\n\n\n## PDF page 11\n\n[5] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk,\nand Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical\nmachine translation. CoRR, abs/1406.1078, 2014.\n[6] Francois Chollet. Xception: Deep learning with depthwise separable convolutions. arXiv\npreprint arXiv:1610.02357, 2016.\n[7] Junyoung Chung, Çaglar Gülçehre, Kyunghyun Cho, and Yoshua Bengio. Empirical evaluation\nof gated recurrent neural networks on sequence modeling. CoRR, abs/1412.3555, 2014.\n[8] Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, and Noah A. Smith. Recurrent neural\nnetwork grammars. In Proc. of NAACL, 2016.\n[9] Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. Convolu-\ntional sequence to sequence learning. arXiv preprint arXiv:1705.03122v2, 2017.\n[10] Alex Graves.\nGenerating sequences with recurrent neural networks.\narXiv preprint\narXiv:1308.0850, 2013.\n[11] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for im-\nage recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern\nRecognition, pages 770778, 2016.\n[12] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber. Gradient flow in\nrecurrent nets: the difficulty of learning long-term dependencies, 2001.\n[13] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation,\n9(8):17351780, 1997.\n[14] Zhongqiang Huang and Mary Harper. Self-training PCFG grammars with latent annotations\nacross languages. In Proceedings of the 2009 Conference on Empirical Methods in Natural\nLanguage Processing, pages 832841. ACL, August 2009.\n[15] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring\nthe limits of language modeling. arXiv preprint arXiv:1602.02410, 2016.\n[16] Łukasz Kaiser and Samy Bengio. Can active memory replace attention? In Advances in Neural\nInformation Processing Systems, (NIPS), 2016.\n[17] Łukasz Kaiser and Ilya Sutskever. Neural GPUs learn algorithms. In International Conference\non Learning Representations (ICLR), 2016.\n[18] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Ko-\nray Kavukcuoglu. Neural machine translation in linear time. arXiv preprint arXiv:1610.10099v2,\n2017.\n[19] Yoon Kim, Carl Denton, Luong Hoang, and Alexander M. Rush. Structured attention networks.\nIn International Conference on Learning Representations, 2017.\n[20] Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.\n[21] Oleksii Kuchaiev and Boris Ginsburg. Factorization tricks for LSTM networks. arXiv preprint\narXiv:1703.10722, 2017.\n[22] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen\nZhou, and Yoshua Bengio. A structured self-attentive sentence embedding. arXiv preprint\narXiv:1703.03130, 2017.\n[23] Minh-Thang Luong, Quoc V. Le, Ilya Sutskever, Oriol Vinyals, and Lukasz Kaiser. Multi-task\nsequence to sequence learning. arXiv preprint arXiv:1511.06114, 2015.\n[24] Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-\nbased neural machine translation. arXiv preprint arXiv:1508.04025, 2015.\n11\n\n\n## PDF page 12\n\n[25] Mitchell P Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. Building a large annotated\ncorpus of english: The penn treebank. Computational linguistics, 19(2):313330, 1993.\n[26] David McClosky, Eugene Charniak, and Mark Johnson. Effective self-training for parsing. In\nProceedings of the Human Language Technology Conference of the NAACL, Main Conference,\npages 152159. ACL, June 2006.\n[27] Ankur Parikh, Oscar Täckström, Dipanjan Das, and Jakob Uszkoreit. A decomposable attention\nmodel. In Empirical Methods in Natural Language Processing, 2016.\n[28] Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive\nsummarization. arXiv preprint arXiv:1705.04304, 2017.\n[29] Slav Petrov, Leon Barrett, Romain Thibaux, and Dan Klein. Learning accurate, compact,\nand interpretable tree annotation. In Proceedings of the 21st International Conference on\nComputational Linguistics and 44th Annual Meeting of the ACL, pages 433440. ACL, July\n2006.\n[30] Ofir Press and Lior Wolf. Using the output embedding to improve language models. arXiv\npreprint arXiv:1608.05859, 2016.\n[31] Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words\nwith subword units. arXiv preprint arXiv:1508.07909, 2015.\n[32] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton,\nand Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts\nlayer. arXiv preprint arXiv:1701.06538, 2017.\n[33] Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdi-\nnov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine\nLearning Research, 15(1):19291958, 2014.\n[34] Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory\nnetworks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors,\nAdvances in Neural Information Processing Systems 28, pages 24402448. Curran Associates,\nInc., 2015.\n[35] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. Sequence to sequence learning with neural\nnetworks. In Advances in Neural Information Processing Systems, pages 31043112, 2014.\n[36] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna.\nRethinking the inception architecture for computer vision. CoRR, abs/1512.00567, 2015.\n[37] Vinyals & Kaiser, Koo, Petrov, Sutskever, and Hinton. Grammar as a foreign language. In\nAdvances in Neural Information Processing Systems, 2015.\n[38] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang\nMacherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Googles neural machine\ntranslation system: Bridging the gap between human and machine translation. arXiv preprint\narXiv:1609.08144, 2016.\n[39] Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. Deep recurrent models with\nfast-forward connections for neural machine translation. CoRR, abs/1606.04199, 2016.\n[40] Muhua Zhu, Yue Zhang, Wenliang Chen, Min Zhang, and Jingbo Zhu. Fast and accurate\nshift-reduce constituent parsing. In Proceedings of the 51st Annual Meeting of the ACL (Volume\n1: Long Papers), pages 434443. ACL, August 2013.\n12\n\n\n## PDF page 13\n\nAttention Visualizations\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nFigure 3: An example of the attention mechanism following long-distance dependencies in the\nencoder self-attention in layer 5 of 6. Many of the attention heads attend to a distant dependency of\nthe verb making, completing the phrase making...more difficult. Attentions here shown only for\nthe word making. Different colors represent different heads. Best viewed in color.\n13\n\n\n## PDF page 14\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 4: Two attention heads, also in layer 5 of 6, apparently involved in anaphora resolution. Top:\nFull attentions for head 5. Bottom: Isolated attentions from just the word its for attention heads 5\nand 6. Note that the attentions are very sharp for this word.\n14\n\n\n## PDF page 15\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 5: Many of the attention heads exhibit behaviour that seems related to the structure of the\nsentence. We give two such examples above, from two different heads from the encoder self-attention\nat layer 5 of 6. The heads clearly learned to perform different tasks.\n15\n\n\n可直接引用的图表文件(放在 Slidev public 目录,用 /文件名 引用):\n- paper_figure_1_transformer.pngFigure 1 from PDF page 3: The Transformer model architecture.\n- paper_figure_3_long_distance.pngFigure 3 from PDF page 13: Encoder self-attention following long-distance dependencies.\n- paper_figure_4_anaphora.pngFigure 4 from PDF page 14: Attention heads involved in anaphora resolution.\n\n请生成一版 10-20 页的完整初稿。内容必须忠于论文,至少引用上面列出的三张原论文图,并覆盖问题、Transformer 架构、注意力机制、训练、主要实验、局限和结论。不要复制长段原文;每页保持听众可读的信息密度。生成完整的 slides.md。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n- Proposes **Transformer** - a new network architecture based solely on attention mechanisms\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- Achieves state-of-the-art results on machine translation tasks:\n - 28.4 BLEU on WMT 2014 English-to-German\n - 41.8 BLEU on WMT 2014 English-to-French\n- Generalizes well to other tasks like English constituency parsing\n\n---\n\n## Background: Sequence Transduction Challenges\n\n### Traditional Approaches\n- **Recurrent models** (LSTM, GRU) have sequential computation\n- **Convolutional models** have limited long-range dependencies\n- Both have challenges with parallelization and long sequences\n\n### Attention Mechanisms\n- Already used in conjunction with recurrent networks\n- Allows modeling dependencies without regard to distance\n- But not used as the primary architecture... until now\n\n---\n\n## The Transformer: Key Idea\n\nReplace recurrence and convolution with **self-attention** to:\n- Enable more parallelization\n- Reduce sequential computation\n- Capture long-range dependencies more effectively\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n*Encoder (left) and Decoder (right) stacks with self-attention and feed-forward layers*\n\n---\n\n## Encoder Stack\n\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections around each sub-layer\n- Layer normalization after each sub-layer\n- All sub-layers produce outputs of dimension `d_model = 512`\n\n---\n\n## Decoder Stack\n\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward information flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Same residual connections and layer normalization as encoder\n- Output embeddings offset by one position (auto-regressive property)\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-40 mx-auto\" />\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder\n2. **Encoder self-attention**: All positions attend to all positions in previous encoder layer\n3. **Decoder self-attention**: Positions attend to previous positions (masked to preserve auto-regressive property)\n\n---\n\n## Positional Encoding\n\nSince there's no recurrence/convolution, we add positional information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performed similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Details\n\n### Data & Batching\n- WMT 2014 English-German (4.5M sentence pairs)\n- WMT 2014 English-French (36M sentence pairs)\n- Byte-pair encoding with shared vocabulary\n- Batches with ~25,000 source and target tokens\n\n### Hardware & Schedule\n- 8 NVIDIA P100 GPUs\n- Base model: 100,000 steps (12 hours)\n- Big model: 300,000 steps (3.5 days)\n\n---\n\n## Training Details (Cont.)\n\n### Optimizer\n- Adam with $\\beta_1 = 0.9$, $\\beta_2 = 0.98$, $\\epsilon = 10^{-9}$\n- Learning rate schedule:\n $$\\text{lrate} = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step\\_num}^{-0.5}, \\text{step\\_num} \\cdot \\text{warmup\\_steps}^{-1.5})$$\n- Warmup steps = 4000\n\n### Regularization\n- Residual dropout (P_drop = 0.1)\n- Label smoothing ($\\epsilon_{ls} = 0.1$)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n- 2+ BLEU improvement on English-to-German\n\n---\n\n## Model Architecture Ablations\n\n| Variation | Dev PPL | Dev BLEU |\n|-----------|---------|----------|\n| Base model | 4.92 | 25.8 |\n| (A) 1 attention head | 5.29 | 24.9 |\n| (B) d_k = 16 | 5.75 | 24.5 |\n| (C) 2 layers | 6.11 | 23.7 |\n| (D) No dropout | 5.77 | 24.6 |\n| (E) Learned positional embeddings | 4.92 | 25.7 |\n\n- Multi-head attention improves performance\n- Dropout is crucial for avoiding overfitting\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. (2014) | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Performs comparably to state-of-the-art parsers\n- Better than RNN models in small-data regimes\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion\n\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution\n- Achieved new state-of-the-art in machine translation:\n - 28.4 BLEU on English-to-German\n - 41.8 BLEU on English-to-French\n- More parallelizable and faster to train\n- Generalizes well to other tasks like constituency parsing\n\n---\n\n## Future Work\n\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "硬性验收失败:你刚才生成了 21 页,必须是 10–20 页。请在不删除三张原论文图、不丢失主要贡献的前提下合并或拆分内容,重新输出完整 slides.md;不得超过 20 页。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n- Proposes **Transformer** - a new network architecture based solely on attention\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- State-of-the-art results:\n - 28.4 BLEU on WMT 2014 English-to-German\n - 41.8 BLEU on WMT 2014 English-to-French\n- Generalizes well to other tasks like English constituency parsing\n\n---\n\n## Background & Key Idea\n\n### Traditional Sequence Models\n- **Recurrent models** (LSTM, GRU): Sequential computation, limited parallelization\n- **Convolutional models**: Limited long-range dependencies\n\n### Attention Mechanism\n- Already used with recurrent networks\n- Allows modeling dependencies without regard to distance\n\n### The Transformer\n- **Key innovation**: Replace recurrence and convolution with self-attention\n- Enables more parallelization and better long-range dependencies\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n*Encoder (left) and Decoder (right) stacks with self-attention and feed-forward layers*\n\n---\n\n## Encoder & Decoder Stacks\n\n### Encoder\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Output dimension: `d_model = 512`\n\n### Decoder\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise feed-forward network\n- Same residual connections and layer normalization\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n### Applications\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder\n2. **Encoder self-attention**: All positions attend to all positions\n3. **Decoder self-attention**: Positions attend to previous positions (masked)\n\n---\n\n## Positional Encoding\n\nSince there's no recurrence/convolution, we add positional information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performed similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Details\n\n### Data & Batching\n- WMT 2014 English-German (4.5M pairs), English-French (36M pairs)\n- Byte-pair encoding with shared vocabulary\n- Batches with ~25,000 source and target tokens\n\n### Hardware & Schedule\n- 8 NVIDIA P100 GPUs\n- Base model: 100,000 steps (12 hours)\n- Big model: 300,000 steps (3.5 days)\n\n### Optimizer & Regularization\n- Adam with $\\beta_1=0.9$, $\\beta_2=0.98$, $\\epsilon=10^{-9}$\n- Learning rate schedule with warmup steps=4000\n- Residual dropout (P_drop=0.1) and label smoothing ($\\epsilon_{ls}=0.1$)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n- 2+ BLEU improvement on English-to-German\n\n---\n\n## Model Architecture Ablations\n\n| Variation | Dev PPL | Dev BLEU |\n|-----------|---------|----------|\n| Base model | 4.92 | 25.8 |\n| (A) 1 attention head | 5.29 | 24.9 |\n| (B) d_k = 16 | 5.75 | 24.5 |\n| (C) 2 layers | 6.11 | 23.7 |\n| (D) No dropout | 5.77 | 24.6 |\n| (E) Learned positional embeddings | 4.92 | 25.7 |\n\n- Multi-head attention improves performance\n- Dropout is crucial for avoiding overfitting\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. (2014) | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Performs comparably to state-of-the-art parsers\n- Better than RNN models in small-data regimes\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion & Future Work\n\n### Contributions\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution\n- Achieved new state-of-the-art in machine translation\n- More parallelizable and faster to train\n- Generalizes well to other tasks\n\n### Future Work\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "审核者(Reviewer)渲染了你上一版 slides.md 的每一页截图,给出如下结构化改进建议(JSON):\n\n{\n \"overall_score\": 65,\n \"pass\": false,\n \"issues\": [\n {\n \"page\": 2,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将要点拆分为2页,例如将State-of-the-art results单独作为一页展示\"\n },\n {\n \"page\": 3,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将三个部分拆分为独立页面,每个部分单独一页详细说明\"\n },\n {\n \"page\": 4,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"放大架构图至占页面2/3空间,删除图片下方的文字说明或将其移至下一页\"\n },\n {\n \"page\": 4,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"删除图片下方的长段文字,仅保留标题和简短说明\"\n },\n {\n \"page\": 5,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Encoder和Decoder分拆为两页,每页单独详细说明其结构\"\n },\n {\n \"page\": 7,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Multi-Head Attention原理和Applications分拆为两页\"\n },\n {\n \"page\": 10,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"high\",\n \"suggestion\": \"将Data & Batching、Hardware & Schedule、Optimizer & Regularization三个部分拆分为3页\"\n },\n {\n \"page\": 14,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"放大注意力可视化图,使其占满页面,确保文字和连线清晰可见\"\n },\n {\n \"page\": 15,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"放大注意力可视化图,增加对比度,确保不同颜色的注意力头可区分\"\n },\n {\n \"page\": 16,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Contributions和Future Work分拆为两页,每部分保留3-4个要点\"\n }\n ]\n}\n\n请理解这些问题并修订 slides.md(可拆页、精简文字、调整图片尺寸等),重新输出完整的 slides.md。修订后仍必须保持 10–20 页;解决拥挤时优先精简与合并,不得用无限拆页规避版面问题。"
}
],
"temperature": 0.3
},
"response": {
"id": "0217853849930443bc9a923998b9a9cbb323528a1d3e323252521",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract: Key Innovation\n\n- Proposes **Transformer** - first network architecture based solely on attention\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- Generalizes well to other tasks beyond machine translation\n\n---\n\n## Abstract: Performance Highlights\n\n- **WMT 2014 English-to-German**: 28.4 BLEU\n - Improves over existing best results by over 2 BLEU\n- **WMT 2014 English-to-French**: 41.8 BLEU\n - New single-model state-of-the-art\n - Trained for 3.5 days on eight GPUs (small fraction of previous costs)\n\n---\n\n## Background: Traditional Sequence Models\n\n### Recurrent Models (LSTM, GRU)\n- Sequential computation inherently limits parallelization\n- Long-range dependencies difficult to learn\n- Computation scales linearly with sequence length\n\n### Convolutional Models\n- Better parallelization but limited receptive field\n- Requires multiple layers to capture long-range dependencies\n- Computational complexity grows with kernel size\n\n---\n\n## Key Idea: The Transformer\n\nReplace recurrence and convolution with **self-attention** to:\n- Enable massive parallelization\n- Capture long-range dependencies directly\n- Reduce training time significantly\n- Maintain or improve model quality\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-96 mx-auto\" />\n\n---\n\n## Architecture Overview\n\n- **Encoder**: Processes input sequence into continuous representation\n- **Decoder**: Generates output sequence based on encoder output\n- Both use stacked self-attention and feed-forward layers\n- Residual connections and layer normalization throughout\n\n---\n\n## Encoder Stack\n\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections around each sub-layer\n- Layer normalization after each sub-layer\n- Output dimension: `d_model = 512`\n\n---\n\n## Decoder Stack\n\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise feed-forward network\n- Same residual connections and layer normalization as encoder\n- Output embeddings offset by one position (auto-regressive property)\n\n---\n\n## Scaled Dot-Product Attention\n\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention with similar performance\n\n---\n\n## Multi-Head Attention\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n---\n\n## Attention Applications\n\n1. **Encoder-decoder attention**: \n - Queries from decoder, keys/values from encoder\n - Enables decoder to attend to all input positions\n\n2. **Encoder self-attention**:\n - All positions attend to all positions in previous encoder layer\n - Captures dependencies within input sequence\n\n3. **Decoder self-attention**:\n - Positions attend to previous positions (masked)\n - Preserves auto-regressive property\n\n---\n\n## Positional Encoding\n\nAdds sequence position information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performs similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Data & Batching\n\n- **Datasets**:\n - WMT 2014 English-German (4.5M sentence pairs)\n - WMT 2014 English-French (36M sentence pairs)\n- **Tokenization**:\n - Byte-pair encoding with shared vocabulary\n - 37,000 tokens (EN-DE), 32,000 tokens (EN-FR)\n- **Batching**:\n - Sentences grouped by approximate length\n - Each batch contains ~25,000 source and target tokens\n\n---\n\n## Training Hardware & Schedule\n\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Base model**:\n - 100,000 training steps\n - ~12 hours total training time\n - 0.4 seconds per step\n- **Big model**:\n - 300,000 training steps\n - ~3.5 days total training time\n - 1.0 seconds per step\n\n---\n\n## Training Optimizer & Regularization\n\n- **Optimizer**: Adam\n - $\\beta_1 = 0.9$, $\\beta_2 = 0.98$, $\\epsilon = 10^{-9}$\n - Learning rate schedule with warmup steps=4000\n\n- **Regularization**:\n - Residual dropout (P_drop = 0.1)\n - Label smoothing ($\\epsilon_{ls} = 0.1$)\n - Dropout on embeddings + positional encodings\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-96 w-full object-contain\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-96 w-full object-contain\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion: Key Contributions\n\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution, enabling better parallelization\n- Achieved new state-of-the-art in machine translation\n- Reduced training time significantly compared to previous approaches\n- Generalized well to other tasks like English constituency parsing\n\n---\n\n## Future Work\n\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n- Extend to larger input/output sequences\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
"usage": {
"prompt_tokens": 16782,
"completion_tokens": 2415,
"total_tokens": 19197,
"cached_prompt_tokens": 0
}
},
{
"meter": "Proposer(纯文本)",
"called_at_utc": "2026-07-30T04:18:05.671638+00:00",
"latency_s": 42.267,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名擅长把学术论文转化为演示文稿的 Proposer Agent。\n你用 Slidev 框架(Markdown + HTML)编写 PPT 源码 slides.md。\n\nSlidev 语法要点:\n- 文件开头是 YAML frontmatter--- 包裹),设置 theme: default。\n- 用单独一行的 `---`(前后空行)分隔每一页幻灯片。\n- 首页通常放标题、作者、会议。\n- 引用图片用 markdown![说明](/图片文件名.png),可用 HTML 控制尺寸,\n 例如 <img src=\"/speedup_bar.png\" class=\"h-60 mx-auto\" />。\n- 可用 Windi/Uno CSS 工具类控制排版(如 text-sm、grid grid-cols-2 gap-4)。\n\n要求:\n- 最终生成 10-20 页,覆盖论文的标题、背景/动机、方法、实验结果、局限与结论。\n- 至少在 3 页中使用提供的图表/表格,且图文匹配。\n- 每页信息量适中、不要塞太多字,宁可拆页也不要溢出。\n- 只输出 slides.md 的完整内容,用 ```markdown 代码块包裹,不要额外解释。"
},
{
"role": "user",
"content": "以下是论文全文(Markdown):\n\n# Attention Is All You Need\n\nAuthors: Ashish Vaswani et al.\n\n\n## PDF page 1\n\nProvided proper attribution is provided, Google hereby grants permission to\nreproduce the tables and figures in this paper solely for use in journalistic or\nscholarly works.\nAttention Is All You Need\nAshish Vaswani\nGoogle Brain\navaswani@google.com\nNoam Shazeer\nGoogle Brain\nnoam@google.com\nNiki Parmar\nGoogle Research\nnikip@google.com\nJakob Uszkoreit\nGoogle Research\nusz@google.com\nLlion Jones\nGoogle Research\nllion@google.com\nAidan N. Gomez∗†\nUniversity of Toronto\naidan@cs.toronto.edu\nŁukasz Kaiser\nGoogle Brain\nlukaszkaiser@google.com\nIllia Polosukhin∗‡\nillia.polosukhin@gmail.com\nAbstract\nThe dominant sequence transduction models are based on complex recurrent or\nconvolutional neural networks that include an encoder and a decoder. The best\nperforming models also connect the encoder and decoder through an attention\nmechanism. We propose a new simple network architecture, the Transformer,\nbased solely on attention mechanisms, dispensing with recurrence and convolutions\nentirely. Experiments on two machine translation tasks show these models to\nbe superior in quality while being more parallelizable and requiring significantly\nless time to train. Our model achieves 28.4 BLEU on the WMT 2014 English-\nto-German translation task, improving over the existing best results, including\nensembles, by over 2 BLEU. On the WMT 2014 English-to-French translation task,\nour model establishes a new single-model state-of-the-art BLEU score of 41.8 after\ntraining for 3.5 days on eight GPUs, a small fraction of the training costs of the\nbest models from the literature. We show that the Transformer generalizes well to\nother tasks by applying it successfully to English constituency parsing both with\nlarge and limited training data.\nEqual contribution. Listing order is random. Jakob proposed replacing RNNs with self-attention and started\nthe effort to evaluate this idea. Ashish, with Illia, designed and implemented the first Transformer models and\nhas been crucially involved in every aspect of this work. Noam proposed scaled dot-product attention, multi-head\nattention and the parameter-free position representation and became the other person involved in nearly every\ndetail. Niki designed, implemented, tuned and evaluated countless model variants in our original codebase and\ntensor2tensor. Llion also experimented with novel model variants, was responsible for our initial codebase, and\nefficient inference and visualizations. Lukasz and Aidan spent countless long days designing various parts of and\nimplementing tensor2tensor, replacing our earlier codebase, greatly improving results and massively accelerating\nour research.\n†Work performed while at Google Brain.\n‡Work performed while at Google Research.\n31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA.\narXiv:1706.03762v7 [cs.CL] 2 Aug 2023\n\n\n## PDF page 2\n\n1\nIntroduction\nRecurrent neural networks, long short-term memory [13] and gated recurrent [7] neural networks\nin particular, have been firmly established as state of the art approaches in sequence modeling and\ntransduction problems such as language modeling and machine translation [35, 2, 5]. Numerous\nefforts have since continued to push the boundaries of recurrent language models and encoder-decoder\narchitectures [38, 24, 15].\nRecurrent models typically factor computation along the symbol positions of the input and output\nsequences. Aligning the positions to steps in computation time, they generate a sequence of hidden\nstates ht, as a function of the previous hidden state ht1 and the input for position t. This inherently\nsequential nature precludes parallelization within training examples, which becomes critical at longer\nsequence lengths, as memory constraints limit batching across examples. Recent work has achieved\nsignificant improvements in computational efficiency through factorization tricks [21] and conditional\ncomputation [32], while also improving model performance in case of the latter. The fundamental\nconstraint of sequential computation, however, remains.\nAttention mechanisms have become an integral part of compelling sequence modeling and transduc-\ntion models in various tasks, allowing modeling of dependencies without regard to their distance in\nthe input or output sequences [2, 19]. In all but a few cases [27], however, such attention mechanisms\nare used in conjunction with a recurrent network.\nIn this work we propose the Transformer, a model architecture eschewing recurrence and instead\nrelying entirely on an attention mechanism to draw global dependencies between input and output.\nThe Transformer allows for significantly more parallelization and can reach a new state of the art in\ntranslation quality after being trained for as little as twelve hours on eight P100 GPUs.\n2\nBackground\nThe goal of reducing sequential computation also forms the foundation of the Extended Neural GPU\n[16], ByteNet [18] and ConvS2S [9], all of which use convolutional neural networks as basic building\nblock, computing hidden representations in parallel for all input and output positions. In these models,\nthe number of operations required to relate signals from two arbitrary input or output positions grows\nin the distance between positions, linearly for ConvS2S and logarithmically for ByteNet. This makes\nit more difficult to learn dependencies between distant positions [12]. In the Transformer this is\nreduced to a constant number of operations, albeit at the cost of reduced effective resolution due\nto averaging attention-weighted positions, an effect we counteract with Multi-Head Attention as\ndescribed in section 3.2.\nSelf-attention, sometimes called intra-attention is an attention mechanism relating different positions\nof a single sequence in order to compute a representation of the sequence. Self-attention has been\nused successfully in a variety of tasks including reading comprehension, abstractive summarization,\ntextual entailment and learning task-independent sentence representations [4, 27, 28, 22].\nEnd-to-end memory networks are based on a recurrent attention mechanism instead of sequence-\naligned recurrence and have been shown to perform well on simple-language question answering and\nlanguage modeling tasks [34].\nTo the best of our knowledge, however, the Transformer is the first transduction model relying\nentirely on self-attention to compute representations of its input and output without using sequence-\naligned RNNs or convolution. In the following sections, we will describe the Transformer, motivate\nself-attention and discuss its advantages over models such as [17, 18] and [9].\n3\nModel Architecture\nMost competitive neural sequence transduction models have an encoder-decoder structure [5, 2, 35].\nHere, the encoder maps an input sequence of symbol representations (x1, ..., xn) to a sequence\nof continuous representations z = (z1, ..., zn). Given z, the decoder then generates an output\nsequence (y1, ..., ym) of symbols one element at a time. At each step the model is auto-regressive\n[10], consuming the previously generated symbols as additional input when generating the next.\n2\n\n\n## PDF page 3\n\nFigure 1: The Transformer - model architecture.\nThe Transformer follows this overall architecture using stacked self-attention and point-wise, fully\nconnected layers for both the encoder and decoder, shown in the left and right halves of Figure 1,\nrespectively.\n3.1\nEncoder and Decoder Stacks\nEncoder:\nThe encoder is composed of a stack of N = 6 identical layers. Each layer has two\nsub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, position-\nwise fully connected feed-forward network. We employ a residual connection [11] around each of\nthe two sub-layers, followed by layer normalization [1]. That is, the output of each sub-layer is\nLayerNorm(x + Sublayer(x)), where Sublayer(x) is the function implemented by the sub-layer\nitself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding\nlayers, produce outputs of dimension dmodel = 512.\nDecoder:\nThe decoder is also composed of a stack of N = 6 identical layers. In addition to the two\nsub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head\nattention over the output of the encoder stack. Similar to the encoder, we employ residual connections\naround each of the sub-layers, followed by layer normalization. We also modify the self-attention\nsub-layer in the decoder stack to prevent positions from attending to subsequent positions. This\nmasking, combined with fact that the output embeddings are offset by one position, ensures that the\npredictions for position i can depend only on the known outputs at positions less than i.\n3.2\nAttention\nAn attention function can be described as mapping a query and a set of key-value pairs to an output,\nwhere the query, keys, values, and output are all vectors. The output is computed as a weighted sum\n3\n\n\n## PDF page 4\n\nScaled Dot-Product Attention\nMulti-Head Attention\nFigure 2: (left) Scaled Dot-Product Attention. (right) Multi-Head Attention consists of several\nattention layers running in parallel.\nof the values, where the weight assigned to each value is computed by a compatibility function of the\nquery with the corresponding key.\n3.2.1\nScaled Dot-Product Attention\nWe call our particular attention \"Scaled Dot-Product Attention\" (Figure 2). The input consists of\nqueries and keys of dimension dk, and values of dimension dv. We compute the dot products of the\nquery with all keys, divide each by √dk, and apply a softmax function to obtain the weights on the\nvalues.\nIn practice, we compute the attention function on a set of queries simultaneously, packed together\ninto a matrix Q. The keys and values are also packed together into matrices K and V . We compute\nthe matrix of outputs as:\nAttention(Q, K, V ) = softmax(QKT\n√dk\n)V\n(1)\nThe two most commonly used attention functions are additive attention [2], and dot-product (multi-\nplicative) attention. Dot-product attention is identical to our algorithm, except for the scaling factor\nof\n1\n√dk . Additive attention computes the compatibility function using a feed-forward network with\na single hidden layer. While the two are similar in theoretical complexity, dot-product attention is\nmuch faster and more space-efficient in practice, since it can be implemented using highly optimized\nmatrix multiplication code.\nWhile for small values of dk the two mechanisms perform similarly, additive attention outperforms\ndot product attention without scaling for larger values of dk [3]. We suspect that for large values of\ndk, the dot products grow large in magnitude, pushing the softmax function into regions where it has\nextremely small gradients 4. To counteract this effect, we scale the dot products by\n1\n√dk .\n3.2.2\nMulti-Head Attention\nInstead of performing a single attention function with dmodel-dimensional keys, values and queries,\nwe found it beneficial to linearly project the queries, keys and values h times with different, learned\nlinear projections to dk, dk and dv dimensions, respectively. On each of these projected versions of\nqueries, keys and values we then perform the attention function in parallel, yielding dv-dimensional\n4To illustrate why the dot products get large, assume that the components of q and k are independent random\nvariables with mean 0 and variance 1. Then their dot product, q · k = Pdk\ni=1 qiki, has mean 0 and variance dk.\n4\n\n\n## PDF page 5\n\noutput values. These are concatenated and once again projected, resulting in the final values, as\ndepicted in Figure 2.\nMulti-head attention allows the model to jointly attend to information from different representation\nsubspaces at different positions. With a single attention head, averaging inhibits this.\nMultiHead(Q, K, V ) = Concat(head1, ..., headh)W O\nwhere headi = Attention(QW Q\ni , KW K\ni , V W V\ni )\nWhere the projections are parameter matrices W Q\ni\n∈Rdmodel×dk, W K\ni\n∈Rdmodel×dk, W V\ni\n∈Rdmodel×dv\nand W O ∈Rhdv×dmodel.\nIn this work we employ h = 8 parallel attention layers, or heads. For each of these we use\ndk = dv = dmodel/h = 64. Due to the reduced dimension of each head, the total computational cost\nis similar to that of single-head attention with full dimensionality.\n3.2.3\nApplications of Attention in our Model\nThe Transformer uses multi-head attention in three different ways:\n• In \"encoder-decoder attention\" layers, the queries come from the previous decoder layer,\nand the memory keys and values come from the output of the encoder. This allows every\nposition in the decoder to attend over all positions in the input sequence. This mimics the\ntypical encoder-decoder attention mechanisms in sequence-to-sequence models such as\n[38, 2, 9].\n• The encoder contains self-attention layers. In a self-attention layer all of the keys, values\nand queries come from the same place, in this case, the output of the previous layer in the\nencoder. Each position in the encoder can attend to all positions in the previous layer of the\nencoder.\n• Similarly, self-attention layers in the decoder allow each position in the decoder to attend to\nall positions in the decoder up to and including that position. We need to prevent leftward\ninformation flow in the decoder to preserve the auto-regressive property. We implement this\ninside of scaled dot-product attention by masking out (setting to −∞) all values in the input\nof the softmax which correspond to illegal connections. See Figure 2.\n3.3\nPosition-wise Feed-Forward Networks\nIn addition to attention sub-layers, each of the layers in our encoder and decoder contains a fully\nconnected feed-forward network, which is applied to each position separately and identically. This\nconsists of two linear transformations with a ReLU activation in between.\nFFN(x) = max(0, xW1 + b1)W2 + b2\n(2)\nWhile the linear transformations are the same across different positions, they use different parameters\nfrom layer to layer. Another way of describing this is as two convolutions with kernel size 1.\nThe dimensionality of input and output is dmodel = 512, and the inner-layer has dimensionality\ndff = 2048.\n3.4\nEmbeddings and Softmax\nSimilarly to other sequence transduction models, we use learned embeddings to convert the input\ntokens and output tokens to vectors of dimension dmodel. We also use the usual learned linear transfor-\nmation and softmax function to convert the decoder output to predicted next-token probabilities. In\nour model, we share the same weight matrix between the two embedding layers and the pre-softmax\nlinear transformation, similar to [30]. In the embedding layers, we multiply those weights by √dmodel.\n5\n\n\n## PDF page 6\n\nTable 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations\nfor different layer types. n is the sequence length, d is the representation dimension, k is the kernel\nsize of convolutions and r the size of the neighborhood in restricted self-attention.\nLayer Type\nComplexity per Layer\nSequential\nMaximum Path Length\nOperations\nSelf-Attention\nO(n2 · d)\nO(1)\nO(1)\nRecurrent\nO(n · d2)\nO(n)\nO(n)\nConvolutional\nO(k · n · d2)\nO(1)\nO(logk(n))\nSelf-Attention (restricted)\nO(r · n · d)\nO(1)\nO(n/r)\n3.5\nPositional Encoding\nSince our model contains no recurrence and no convolution, in order for the model to make use of the\norder of the sequence, we must inject some information about the relative or absolute position of the\ntokens in the sequence. To this end, we add \"positional encodings\" to the input embeddings at the\nbottoms of the encoder and decoder stacks. The positional encodings have the same dimension dmodel\nas the embeddings, so that the two can be summed. There are many choices of positional encodings,\nlearned and fixed [9].\nIn this work, we use sine and cosine functions of different frequencies:\nPE(pos,2i) = sin(pos/100002i/dmodel)\nPE(pos,2i+1) = cos(pos/100002i/dmodel)\nwhere pos is the position and i is the dimension. That is, each dimension of the positional encoding\ncorresponds to a sinusoid. The wavelengths form a geometric progression from 2π to 10000 · 2π. We\nchose this function because we hypothesized it would allow the model to easily learn to attend by\nrelative positions, since for any fixed offset k, PEpos+k can be represented as a linear function of\nPEpos.\nWe also experimented with using learned positional embeddings [9] instead, and found that the two\nversions produced nearly identical results (see Table 3 row (E)). We chose the sinusoidal version\nbecause it may allow the model to extrapolate to sequence lengths longer than the ones encountered\nduring training.\n4\nWhy Self-Attention\nIn this section we compare various aspects of self-attention layers to the recurrent and convolu-\ntional layers commonly used for mapping one variable-length sequence of symbol representations\n(x1, ..., xn) to another sequence of equal length (z1, ..., zn), with xi, zi ∈Rd, such as a hidden\nlayer in a typical sequence transduction encoder or decoder. Motivating our use of self-attention we\nconsider three desiderata.\nOne is the total computational complexity per layer. Another is the amount of computation that can\nbe parallelized, as measured by the minimum number of sequential operations required.\nThe third is the path length between long-range dependencies in the network. Learning long-range\ndependencies is a key challenge in many sequence transduction tasks. One key factor affecting the\nability to learn such dependencies is the length of the paths forward and backward signals have to\ntraverse in the network. The shorter these paths between any combination of positions in the input\nand output sequences, the easier it is to learn long-range dependencies [12]. Hence we also compare\nthe maximum path length between any two input and output positions in networks composed of the\ndifferent layer types.\nAs noted in Table 1, a self-attention layer connects all positions with a constant number of sequentially\nexecuted operations, whereas a recurrent layer requires O(n) sequential operations. In terms of\ncomputational complexity, self-attention layers are faster than recurrent layers when the sequence\n6\n\n\n## PDF page 7\n\nlength n is smaller than the representation dimensionality d, which is most often the case with\nsentence representations used by state-of-the-art models in machine translations, such as word-piece\n[38] and byte-pair [31] representations. To improve computational performance for tasks involving\nvery long sequences, self-attention could be restricted to considering only a neighborhood of size r in\nthe input sequence centered around the respective output position. This would increase the maximum\npath length to O(n/r). We plan to investigate this approach further in future work.\nA single convolutional layer with kernel width k < n does not connect all pairs of input and output\npositions. Doing so requires a stack of O(n/k) convolutional layers in the case of contiguous kernels,\nor O(logk(n)) in the case of dilated convolutions [18], increasing the length of the longest paths\nbetween any two positions in the network. Convolutional layers are generally more expensive than\nrecurrent layers, by a factor of k. Separable convolutions [6], however, decrease the complexity\nconsiderably, to O(k · n · d + n · d2). Even with k = n, however, the complexity of a separable\nconvolution is equal to the combination of a self-attention layer and a point-wise feed-forward layer,\nthe approach we take in our model.\nAs side benefit, self-attention could yield more interpretable models. We inspect attention distributions\nfrom our models and present and discuss examples in the appendix. Not only do individual attention\nheads clearly learn to perform different tasks, many appear to exhibit behavior related to the syntactic\nand semantic structure of the sentences.\n5\nTraining\nThis section describes the training regime for our models.\n5.1\nTraining Data and Batching\nWe trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million\nsentence pairs. Sentences were encoded using byte-pair encoding [3], which has a shared source-\ntarget vocabulary of about 37000 tokens. For English-French, we used the significantly larger WMT\n2014 English-French dataset consisting of 36M sentences and split tokens into a 32000 word-piece\nvocabulary [38]. Sentence pairs were batched together by approximate sequence length. Each training\nbatch contained a set of sentence pairs containing approximately 25000 source tokens and 25000\ntarget tokens.\n5.2\nHardware and Schedule\nWe trained our models on one machine with 8 NVIDIA P100 GPUs. For our base models using\nthe hyperparameters described throughout the paper, each training step took about 0.4 seconds. We\ntrained the base models for a total of 100,000 steps or 12 hours. For our big models,(described on the\nbottom line of table 3), step time was 1.0 seconds. The big models were trained for 300,000 steps\n(3.5 days).\n5.3\nOptimizer\nWe used the Adam optimizer [20] with β1 = 0.9, β2 = 0.98 and ϵ = 109. We varied the learning\nrate over the course of training, according to the formula:\nlrate = d0.5\nmodel · min(step_num0.5, step_num · warmup_steps1.5)\n(3)\nThis corresponds to increasing the learning rate linearly for the first warmup_steps training steps,\nand decreasing it thereafter proportionally to the inverse square root of the step number. We used\nwarmup_steps = 4000.\n5.4\nRegularization\nWe employ three types of regularization during training:\n7\n\n\n## PDF page 8\n\nTable 2: The Transformer achieves better BLEU scores than previous state-of-the-art models on the\nEnglish-to-German and English-to-French newstest2014 tests at a fraction of the training cost.\nModel\nBLEU\nTraining Cost (FLOPs)\nEN-DE\nEN-FR\nEN-DE\nEN-FR\nByteNet [18]\n23.75\nDeep-Att + PosUnk [39]\n39.2\n1.0 · 1020\nGNMT + RL [38]\n24.6\n39.92\n2.3 · 1019\n1.4 · 1020\nConvS2S [9]\n25.16\n40.46\n9.6 · 1018\n1.5 · 1020\nMoE [32]\n26.03\n40.56\n2.0 · 1019\n1.2 · 1020\nDeep-Att + PosUnk Ensemble [39]\n40.4\n8.0 · 1020\nGNMT + RL Ensemble [38]\n26.30\n41.16\n1.8 · 1020\n1.1 · 1021\nConvS2S Ensemble [9]\n26.36\n41.29\n7.7 · 1019\n1.2 · 1021\nTransformer (base model)\n27.3\n38.1\n3.3 · 1018\nTransformer (big)\n28.4\n41.8\n2.3 · 1019\nResidual Dropout\nWe apply dropout [33] to the output of each sub-layer, before it is added to the\nsub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the\npositional encodings in both the encoder and decoder stacks. For the base model, we use a rate of\nPdrop = 0.1.\nLabel Smoothing\nDuring training, we employed label smoothing of value ϵls = 0.1 [36]. This\nhurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.\n6\nResults\n6.1\nMachine Translation\nOn the WMT 2014 English-to-German translation task, the big transformer model (Transformer (big)\nin Table 2) outperforms the best previously reported models (including ensembles) by more than 2.0\nBLEU, establishing a new state-of-the-art BLEU score of 28.4. The configuration of this model is\nlisted in the bottom line of Table 3. Training took 3.5 days on 8 P100 GPUs. Even our base model\nsurpasses all previously published models and ensembles, at a fraction of the training cost of any of\nthe competitive models.\nOn the WMT 2014 English-to-French translation task, our big model achieves a BLEU score of 41.0,\noutperforming all of the previously published single models, at less than 1/4 the training cost of the\nprevious state-of-the-art model. The Transformer (big) model trained for English-to-French used\ndropout rate Pdrop = 0.1, instead of 0.3.\nFor the base models, we used a single model obtained by averaging the last 5 checkpoints, which\nwere written at 10-minute intervals. For the big models, we averaged the last 20 checkpoints. We\nused beam search with a beam size of 4 and length penalty α = 0.6 [38]. These hyperparameters\nwere chosen after experimentation on the development set. We set the maximum output length during\ninference to input length + 50, but terminate early when possible [38].\nTable 2 summarizes our results and compares our translation quality and training costs to other model\narchitectures from the literature. We estimate the number of floating point operations used to train a\nmodel by multiplying the training time, the number of GPUs used, and an estimate of the sustained\nsingle-precision floating-point capacity of each GPU 5.\n6.2\nModel Variations\nTo evaluate the importance of different components of the Transformer, we varied our base model\nin different ways, measuring the change in performance on English-to-German translation on the\n5We used values of 2.8, 3.7, 6.0 and 9.5 TFLOPS for K80, K40, M40 and P100, respectively.\n8\n\n\n## PDF page 9\n\nTable 3: Variations on the Transformer architecture. Unlisted values are identical to those of the base\nmodel. All metrics are on the English-to-German translation development set, newstest2013. Listed\nperplexities are per-wordpiece, according to our byte-pair encoding, and should not be compared to\nper-word perplexities.\nN\ndmodel\ndff\nh\ndk\ndv\nPdrop\nϵls\ntrain\nPPL\nBLEU\nparams\nsteps\n(dev)\n(dev)\n×106\nbase\n6\n512\n2048\n8\n64\n64\n0.1\n0.1\n100K\n4.92\n25.8\n65\n(A)\n1\n512\n512\n5.29\n24.9\n4\n128\n128\n5.00\n25.5\n16\n32\n32\n4.91\n25.8\n32\n16\n16\n5.01\n25.4\n(B)\n16\n5.16\n25.1\n58\n32\n5.01\n25.4\n60\n(C)\n2\n6.11\n23.7\n36\n4\n5.19\n25.3\n50\n8\n4.88\n25.5\n80\n256\n32\n32\n5.75\n24.5\n28\n1024\n128\n128\n4.66\n26.0\n168\n1024\n5.12\n25.4\n53\n4096\n4.75\n26.2\n90\n(D)\n0.0\n5.77\n24.6\n0.2\n4.95\n25.5\n0.0\n4.67\n25.3\n0.2\n5.47\n25.7\n(E)\npositional embedding instead of sinusoids\n4.92\n25.7\nbig\n6\n1024\n4096\n16\n0.3\n300K\n4.33\n26.4\n213\ndevelopment set, newstest2013. We used beam search as described in the previous section, but no\ncheckpoint averaging. We present these results in Table 3.\nIn Table 3 rows (A), we vary the number of attention heads and the attention key and value dimensions,\nkeeping the amount of computation constant, as described in Section 3.2.2. While single-head\nattention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.\nIn Table 3 rows (B), we observe that reducing the attention key size dk hurts model quality. This\nsuggests that determining compatibility is not easy and that a more sophisticated compatibility\nfunction than dot product may be beneficial. We further observe in rows (C) and (D) that, as expected,\nbigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our\nsinusoidal positional encoding with learned positional embeddings [9], and observe nearly identical\nresults to the base model.\n6.3\nEnglish Constituency Parsing\nTo evaluate if the Transformer can generalize to other tasks we performed experiments on English\nconstituency parsing. This task presents specific challenges: the output is subject to strong structural\nconstraints and is significantly longer than the input. Furthermore, RNN sequence-to-sequence\nmodels have not been able to attain state-of-the-art results in small-data regimes [37].\nWe trained a 4-layer transformer with dmodel = 1024 on the Wall Street Journal (WSJ) portion of the\nPenn Treebank [25], about 40K training sentences. We also trained it in a semi-supervised setting,\nusing the larger high-confidence and BerkleyParser corpora from with approximately 17M sentences\n[37]. We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens\nfor the semi-supervised setting.\nWe performed only a small number of experiments to select the dropout, both attention and residual\n(section 5.4), learning rates and beam size on the Section 22 development set, all other parameters\nremained unchanged from the English-to-German base translation model. During inference, we\n9\n\n\n## PDF page 10\n\nTable 4: The Transformer generalizes well to English constituency parsing (Results are on Section 23\nof WSJ)\nParser\nTraining\nWSJ 23 F1\nVinyals & Kaiser el al. (2014) [37]\nWSJ only, discriminative\n88.3\nPetrov et al. (2006) [29]\nWSJ only, discriminative\n90.4\nZhu et al. (2013) [40]\nWSJ only, discriminative\n90.4\nDyer et al. (2016) [8]\nWSJ only, discriminative\n91.7\nTransformer (4 layers)\nWSJ only, discriminative\n91.3\nZhu et al. (2013) [40]\nsemi-supervised\n91.3\nHuang & Harper (2009) [14]\nsemi-supervised\n91.3\nMcClosky et al. (2006) [26]\nsemi-supervised\n92.1\nVinyals & Kaiser el al. (2014) [37]\nsemi-supervised\n92.1\nTransformer (4 layers)\nsemi-supervised\n92.7\nLuong et al. (2015) [23]\nmulti-task\n93.0\nDyer et al. (2016) [8]\ngenerative\n93.3\nincreased the maximum output length to input length + 300. We used a beam size of 21 and α = 0.3\nfor both WSJ only and the semi-supervised setting.\nOur results in Table 4 show that despite the lack of task-specific tuning our model performs sur-\nprisingly well, yielding better results than all previously reported models with the exception of the\nRecurrent Neural Network Grammar [8].\nIn contrast to RNN sequence-to-sequence models [37], the Transformer outperforms the Berkeley-\nParser [29] even when training only on the WSJ training set of 40K sentences.\n7\nConclusion\nIn this work, we presented the Transformer, the first sequence transduction model based entirely on\nattention, replacing the recurrent layers most commonly used in encoder-decoder architectures with\nmulti-headed self-attention.\nFor translation tasks, the Transformer can be trained significantly faster than architectures based\non recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014\nEnglish-to-French translation tasks, we achieve a new state of the art. In the former task our best\nmodel outperforms even all previously reported ensembles.\nWe are excited about the future of attention-based models and plan to apply them to other tasks. We\nplan to extend the Transformer to problems involving input and output modalities other than text and\nto investigate local, restricted attention mechanisms to efficiently handle large inputs and outputs\nsuch as images, audio and video. Making generation less sequential is another research goals of ours.\nThe code we used to train and evaluate our models is available at https://github.com/\ntensorflow/tensor2tensor.\nAcknowledgements\nWe are grateful to Nal Kalchbrenner and Stephan Gouws for their fruitful\ncomments, corrections and inspiration.\nReferences\n[1] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint\narXiv:1607.06450, 2016.\n[2] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly\nlearning to align and translate. CoRR, abs/1409.0473, 2014.\n[3] Denny Britz, Anna Goldie, Minh-Thang Luong, and Quoc V. Le. Massive exploration of neural\nmachine translation architectures. CoRR, abs/1703.03906, 2017.\n[4] Jianpeng Cheng, Li Dong, and Mirella Lapata. Long short-term memory-networks for machine\nreading. arXiv preprint arXiv:1601.06733, 2016.\n10\n\n\n## PDF page 11\n\n[5] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk,\nand Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical\nmachine translation. CoRR, abs/1406.1078, 2014.\n[6] Francois Chollet. Xception: Deep learning with depthwise separable convolutions. arXiv\npreprint arXiv:1610.02357, 2016.\n[7] Junyoung Chung, Çaglar Gülçehre, Kyunghyun Cho, and Yoshua Bengio. Empirical evaluation\nof gated recurrent neural networks on sequence modeling. CoRR, abs/1412.3555, 2014.\n[8] Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, and Noah A. Smith. Recurrent neural\nnetwork grammars. In Proc. of NAACL, 2016.\n[9] Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. Convolu-\ntional sequence to sequence learning. arXiv preprint arXiv:1705.03122v2, 2017.\n[10] Alex Graves.\nGenerating sequences with recurrent neural networks.\narXiv preprint\narXiv:1308.0850, 2013.\n[11] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for im-\nage recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern\nRecognition, pages 770778, 2016.\n[12] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber. Gradient flow in\nrecurrent nets: the difficulty of learning long-term dependencies, 2001.\n[13] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation,\n9(8):17351780, 1997.\n[14] Zhongqiang Huang and Mary Harper. Self-training PCFG grammars with latent annotations\nacross languages. In Proceedings of the 2009 Conference on Empirical Methods in Natural\nLanguage Processing, pages 832841. ACL, August 2009.\n[15] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring\nthe limits of language modeling. arXiv preprint arXiv:1602.02410, 2016.\n[16] Łukasz Kaiser and Samy Bengio. Can active memory replace attention? In Advances in Neural\nInformation Processing Systems, (NIPS), 2016.\n[17] Łukasz Kaiser and Ilya Sutskever. Neural GPUs learn algorithms. In International Conference\non Learning Representations (ICLR), 2016.\n[18] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Ko-\nray Kavukcuoglu. Neural machine translation in linear time. arXiv preprint arXiv:1610.10099v2,\n2017.\n[19] Yoon Kim, Carl Denton, Luong Hoang, and Alexander M. Rush. Structured attention networks.\nIn International Conference on Learning Representations, 2017.\n[20] Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.\n[21] Oleksii Kuchaiev and Boris Ginsburg. Factorization tricks for LSTM networks. arXiv preprint\narXiv:1703.10722, 2017.\n[22] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen\nZhou, and Yoshua Bengio. A structured self-attentive sentence embedding. arXiv preprint\narXiv:1703.03130, 2017.\n[23] Minh-Thang Luong, Quoc V. Le, Ilya Sutskever, Oriol Vinyals, and Lukasz Kaiser. Multi-task\nsequence to sequence learning. arXiv preprint arXiv:1511.06114, 2015.\n[24] Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-\nbased neural machine translation. arXiv preprint arXiv:1508.04025, 2015.\n11\n\n\n## PDF page 12\n\n[25] Mitchell P Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. Building a large annotated\ncorpus of english: The penn treebank. Computational linguistics, 19(2):313330, 1993.\n[26] David McClosky, Eugene Charniak, and Mark Johnson. Effective self-training for parsing. In\nProceedings of the Human Language Technology Conference of the NAACL, Main Conference,\npages 152159. ACL, June 2006.\n[27] Ankur Parikh, Oscar Täckström, Dipanjan Das, and Jakob Uszkoreit. A decomposable attention\nmodel. In Empirical Methods in Natural Language Processing, 2016.\n[28] Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive\nsummarization. arXiv preprint arXiv:1705.04304, 2017.\n[29] Slav Petrov, Leon Barrett, Romain Thibaux, and Dan Klein. Learning accurate, compact,\nand interpretable tree annotation. In Proceedings of the 21st International Conference on\nComputational Linguistics and 44th Annual Meeting of the ACL, pages 433440. ACL, July\n2006.\n[30] Ofir Press and Lior Wolf. Using the output embedding to improve language models. arXiv\npreprint arXiv:1608.05859, 2016.\n[31] Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words\nwith subword units. arXiv preprint arXiv:1508.07909, 2015.\n[32] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton,\nand Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts\nlayer. arXiv preprint arXiv:1701.06538, 2017.\n[33] Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdi-\nnov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine\nLearning Research, 15(1):19291958, 2014.\n[34] Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory\nnetworks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors,\nAdvances in Neural Information Processing Systems 28, pages 24402448. Curran Associates,\nInc., 2015.\n[35] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. Sequence to sequence learning with neural\nnetworks. In Advances in Neural Information Processing Systems, pages 31043112, 2014.\n[36] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna.\nRethinking the inception architecture for computer vision. CoRR, abs/1512.00567, 2015.\n[37] Vinyals & Kaiser, Koo, Petrov, Sutskever, and Hinton. Grammar as a foreign language. In\nAdvances in Neural Information Processing Systems, 2015.\n[38] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang\nMacherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Googles neural machine\ntranslation system: Bridging the gap between human and machine translation. arXiv preprint\narXiv:1609.08144, 2016.\n[39] Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. Deep recurrent models with\nfast-forward connections for neural machine translation. CoRR, abs/1606.04199, 2016.\n[40] Muhua Zhu, Yue Zhang, Wenliang Chen, Min Zhang, and Jingbo Zhu. Fast and accurate\nshift-reduce constituent parsing. In Proceedings of the 51st Annual Meeting of the ACL (Volume\n1: Long Papers), pages 434443. ACL, August 2013.\n12\n\n\n## PDF page 13\n\nAttention Visualizations\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nFigure 3: An example of the attention mechanism following long-distance dependencies in the\nencoder self-attention in layer 5 of 6. Many of the attention heads attend to a distant dependency of\nthe verb making, completing the phrase making...more difficult. Attentions here shown only for\nthe word making. Different colors represent different heads. Best viewed in color.\n13\n\n\n## PDF page 14\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 4: Two attention heads, also in layer 5 of 6, apparently involved in anaphora resolution. Top:\nFull attentions for head 5. Bottom: Isolated attentions from just the word its for attention heads 5\nand 6. Note that the attentions are very sharp for this word.\n14\n\n\n## PDF page 15\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 5: Many of the attention heads exhibit behaviour that seems related to the structure of the\nsentence. We give two such examples above, from two different heads from the encoder self-attention\nat layer 5 of 6. The heads clearly learned to perform different tasks.\n15\n\n\n可直接引用的图表文件(放在 Slidev public 目录,用 /文件名 引用):\n- paper_figure_1_transformer.pngFigure 1 from PDF page 3: The Transformer model architecture.\n- paper_figure_3_long_distance.pngFigure 3 from PDF page 13: Encoder self-attention following long-distance dependencies.\n- paper_figure_4_anaphora.pngFigure 4 from PDF page 14: Attention heads involved in anaphora resolution.\n\n请生成一版 10-20 页的完整初稿。内容必须忠于论文,至少引用上面列出的三张原论文图,并覆盖问题、Transformer 架构、注意力机制、训练、主要实验、局限和结论。不要复制长段原文;每页保持听众可读的信息密度。生成完整的 slides.md。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n- Proposes **Transformer** - a new network architecture based solely on attention mechanisms\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- Achieves state-of-the-art results on machine translation tasks:\n - 28.4 BLEU on WMT 2014 English-to-German\n - 41.8 BLEU on WMT 2014 English-to-French\n- Generalizes well to other tasks like English constituency parsing\n\n---\n\n## Background: Sequence Transduction Challenges\n\n### Traditional Approaches\n- **Recurrent models** (LSTM, GRU) have sequential computation\n- **Convolutional models** have limited long-range dependencies\n- Both have challenges with parallelization and long sequences\n\n### Attention Mechanisms\n- Already used in conjunction with recurrent networks\n- Allows modeling dependencies without regard to distance\n- But not used as the primary architecture... until now\n\n---\n\n## The Transformer: Key Idea\n\nReplace recurrence and convolution with **self-attention** to:\n- Enable more parallelization\n- Reduce sequential computation\n- Capture long-range dependencies more effectively\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n*Encoder (left) and Decoder (right) stacks with self-attention and feed-forward layers*\n\n---\n\n## Encoder Stack\n\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections around each sub-layer\n- Layer normalization after each sub-layer\n- All sub-layers produce outputs of dimension `d_model = 512`\n\n---\n\n## Decoder Stack\n\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward information flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Same residual connections and layer normalization as encoder\n- Output embeddings offset by one position (auto-regressive property)\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-40 mx-auto\" />\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder\n2. **Encoder self-attention**: All positions attend to all positions in previous encoder layer\n3. **Decoder self-attention**: Positions attend to previous positions (masked to preserve auto-regressive property)\n\n---\n\n## Positional Encoding\n\nSince there's no recurrence/convolution, we add positional information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performed similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Details\n\n### Data & Batching\n- WMT 2014 English-German (4.5M sentence pairs)\n- WMT 2014 English-French (36M sentence pairs)\n- Byte-pair encoding with shared vocabulary\n- Batches with ~25,000 source and target tokens\n\n### Hardware & Schedule\n- 8 NVIDIA P100 GPUs\n- Base model: 100,000 steps (12 hours)\n- Big model: 300,000 steps (3.5 days)\n\n---\n\n## Training Details (Cont.)\n\n### Optimizer\n- Adam with $\\beta_1 = 0.9$, $\\beta_2 = 0.98$, $\\epsilon = 10^{-9}$\n- Learning rate schedule:\n $$\\text{lrate} = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step\\_num}^{-0.5}, \\text{step\\_num} \\cdot \\text{warmup\\_steps}^{-1.5})$$\n- Warmup steps = 4000\n\n### Regularization\n- Residual dropout (P_drop = 0.1)\n- Label smoothing ($\\epsilon_{ls} = 0.1$)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n- 2+ BLEU improvement on English-to-German\n\n---\n\n## Model Architecture Ablations\n\n| Variation | Dev PPL | Dev BLEU |\n|-----------|---------|----------|\n| Base model | 4.92 | 25.8 |\n| (A) 1 attention head | 5.29 | 24.9 |\n| (B) d_k = 16 | 5.75 | 24.5 |\n| (C) 2 layers | 6.11 | 23.7 |\n| (D) No dropout | 5.77 | 24.6 |\n| (E) Learned positional embeddings | 4.92 | 25.7 |\n\n- Multi-head attention improves performance\n- Dropout is crucial for avoiding overfitting\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. (2014) | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Performs comparably to state-of-the-art parsers\n- Better than RNN models in small-data regimes\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion\n\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution\n- Achieved new state-of-the-art in machine translation:\n - 28.4 BLEU on English-to-German\n - 41.8 BLEU on English-to-French\n- More parallelizable and faster to train\n- Generalizes well to other tasks like constituency parsing\n\n---\n\n## Future Work\n\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "硬性验收失败:你刚才生成了 21 页,必须是 10–20 页。请在不删除三张原论文图、不丢失主要贡献的前提下合并或拆分内容,重新输出完整 slides.md;不得超过 20 页。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n- Proposes **Transformer** - a new network architecture based solely on attention\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- State-of-the-art results:\n - 28.4 BLEU on WMT 2014 English-to-German\n - 41.8 BLEU on WMT 2014 English-to-French\n- Generalizes well to other tasks like English constituency parsing\n\n---\n\n## Background & Key Idea\n\n### Traditional Sequence Models\n- **Recurrent models** (LSTM, GRU): Sequential computation, limited parallelization\n- **Convolutional models**: Limited long-range dependencies\n\n### Attention Mechanism\n- Already used with recurrent networks\n- Allows modeling dependencies without regard to distance\n\n### The Transformer\n- **Key innovation**: Replace recurrence and convolution with self-attention\n- Enables more parallelization and better long-range dependencies\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n*Encoder (left) and Decoder (right) stacks with self-attention and feed-forward layers*\n\n---\n\n## Encoder & Decoder Stacks\n\n### Encoder\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Output dimension: `d_model = 512`\n\n### Decoder\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise feed-forward network\n- Same residual connections and layer normalization\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n### Applications\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder\n2. **Encoder self-attention**: All positions attend to all positions\n3. **Decoder self-attention**: Positions attend to previous positions (masked)\n\n---\n\n## Positional Encoding\n\nSince there's no recurrence/convolution, we add positional information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performed similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Details\n\n### Data & Batching\n- WMT 2014 English-German (4.5M pairs), English-French (36M pairs)\n- Byte-pair encoding with shared vocabulary\n- Batches with ~25,000 source and target tokens\n\n### Hardware & Schedule\n- 8 NVIDIA P100 GPUs\n- Base model: 100,000 steps (12 hours)\n- Big model: 300,000 steps (3.5 days)\n\n### Optimizer & Regularization\n- Adam with $\\beta_1=0.9$, $\\beta_2=0.98$, $\\epsilon=10^{-9}$\n- Learning rate schedule with warmup steps=4000\n- Residual dropout (P_drop=0.1) and label smoothing ($\\epsilon_{ls}=0.1$)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n- 2+ BLEU improvement on English-to-German\n\n---\n\n## Model Architecture Ablations\n\n| Variation | Dev PPL | Dev BLEU |\n|-----------|---------|----------|\n| Base model | 4.92 | 25.8 |\n| (A) 1 attention head | 5.29 | 24.9 |\n| (B) d_k = 16 | 5.75 | 24.5 |\n| (C) 2 layers | 6.11 | 23.7 |\n| (D) No dropout | 5.77 | 24.6 |\n| (E) Learned positional embeddings | 4.92 | 25.7 |\n\n- Multi-head attention improves performance\n- Dropout is crucial for avoiding overfitting\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. (2014) | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Performs comparably to state-of-the-art parsers\n- Better than RNN models in small-data regimes\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion & Future Work\n\n### Contributions\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution\n- Achieved new state-of-the-art in machine translation\n- More parallelizable and faster to train\n- Generalizes well to other tasks\n\n### Future Work\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "审核者(Reviewer)渲染了你上一版 slides.md 的每一页截图,给出如下结构化改进建议(JSON):\n\n{\n \"overall_score\": 65,\n \"pass\": false,\n \"issues\": [\n {\n \"page\": 2,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将要点拆分为2页,例如将State-of-the-art results单独作为一页展示\"\n },\n {\n \"page\": 3,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将三个部分拆分为独立页面,每个部分单独一页详细说明\"\n },\n {\n \"page\": 4,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"放大架构图至占页面2/3空间,删除图片下方的文字说明或将其移至下一页\"\n },\n {\n \"page\": 4,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"删除图片下方的长段文字,仅保留标题和简短说明\"\n },\n {\n \"page\": 5,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Encoder和Decoder分拆为两页,每页单独详细说明其结构\"\n },\n {\n \"page\": 7,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Multi-Head Attention原理和Applications分拆为两页\"\n },\n {\n \"page\": 10,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"high\",\n \"suggestion\": \"将Data & Batching、Hardware & Schedule、Optimizer & Regularization三个部分拆分为3页\"\n },\n {\n \"page\": 14,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"放大注意力可视化图,使其占满页面,确保文字和连线清晰可见\"\n },\n {\n \"page\": 15,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"放大注意力可视化图,增加对比度,确保不同颜色的注意力头可区分\"\n },\n {\n \"page\": 16,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Contributions和Future Work分拆为两页,每部分保留3-4个要点\"\n }\n ]\n}\n\n请理解这些问题并修订 slides.md(可拆页、精简文字、调整图片尺寸等),重新输出完整的 slides.md。修订后仍必须保持 10–20 页;解决拥挤时优先精简与合并,不得用无限拆页规避版面问题。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract: Key Innovation\n\n- Proposes **Transformer** - first network architecture based solely on attention\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- Generalizes well to other tasks beyond machine translation\n\n---\n\n## Abstract: Performance Highlights\n\n- **WMT 2014 English-to-German**: 28.4 BLEU\n - Improves over existing best results by over 2 BLEU\n- **WMT 2014 English-to-French**: 41.8 BLEU\n - New single-model state-of-the-art\n - Trained for 3.5 days on eight GPUs (small fraction of previous costs)\n\n---\n\n## Background: Traditional Sequence Models\n\n### Recurrent Models (LSTM, GRU)\n- Sequential computation inherently limits parallelization\n- Long-range dependencies difficult to learn\n- Computation scales linearly with sequence length\n\n### Convolutional Models\n- Better parallelization but limited receptive field\n- Requires multiple layers to capture long-range dependencies\n- Computational complexity grows with kernel size\n\n---\n\n## Key Idea: The Transformer\n\nReplace recurrence and convolution with **self-attention** to:\n- Enable massive parallelization\n- Capture long-range dependencies directly\n- Reduce training time significantly\n- Maintain or improve model quality\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-96 mx-auto\" />\n\n---\n\n## Architecture Overview\n\n- **Encoder**: Processes input sequence into continuous representation\n- **Decoder**: Generates output sequence based on encoder output\n- Both use stacked self-attention and feed-forward layers\n- Residual connections and layer normalization throughout\n\n---\n\n## Encoder Stack\n\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections around each sub-layer\n- Layer normalization after each sub-layer\n- Output dimension: `d_model = 512`\n\n---\n\n## Decoder Stack\n\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise feed-forward network\n- Same residual connections and layer normalization as encoder\n- Output embeddings offset by one position (auto-regressive property)\n\n---\n\n## Scaled Dot-Product Attention\n\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention with similar performance\n\n---\n\n## Multi-Head Attention\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n---\n\n## Attention Applications\n\n1. **Encoder-decoder attention**: \n - Queries from decoder, keys/values from encoder\n - Enables decoder to attend to all input positions\n\n2. **Encoder self-attention**:\n - All positions attend to all positions in previous encoder layer\n - Captures dependencies within input sequence\n\n3. **Decoder self-attention**:\n - Positions attend to previous positions (masked)\n - Preserves auto-regressive property\n\n---\n\n## Positional Encoding\n\nAdds sequence position information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performs similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Data & Batching\n\n- **Datasets**:\n - WMT 2014 English-German (4.5M sentence pairs)\n - WMT 2014 English-French (36M sentence pairs)\n- **Tokenization**:\n - Byte-pair encoding with shared vocabulary\n - 37,000 tokens (EN-DE), 32,000 tokens (EN-FR)\n- **Batching**:\n - Sentences grouped by approximate length\n - Each batch contains ~25,000 source and target tokens\n\n---\n\n## Training Hardware & Schedule\n\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Base model**:\n - 100,000 training steps\n - ~12 hours total training time\n - 0.4 seconds per step\n- **Big model**:\n - 300,000 training steps\n - ~3.5 days total training time\n - 1.0 seconds per step\n\n---\n\n## Training Optimizer & Regularization\n\n- **Optimizer**: Adam\n - $\\beta_1 = 0.9$, $\\beta_2 = 0.98$, $\\epsilon = 10^{-9}$\n - Learning rate schedule with warmup steps=4000\n\n- **Regularization**:\n - Residual dropout (P_drop = 0.1)\n - Label smoothing ($\\epsilon_{ls} = 0.1$)\n - Dropout on embeddings + positional encodings\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-96 w-full object-contain\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-96 w-full object-contain\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion: Key Contributions\n\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution, enabling better parallelization\n- Achieved new state-of-the-art in machine translation\n- Reduced training time significantly compared to previous approaches\n- Generalized well to other tasks like English constituency parsing\n\n---\n\n## Future Work\n\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n- Extend to larger input/output sequences\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "硬性验收失败:你刚才生成了 22 页,必须是 10–20 页。请在不删除三张原论文图、不丢失主要贡献的前提下合并或拆分内容,重新输出完整 slides.md;不得超过 20 页。"
}
],
"temperature": 0.3
},
"response": {
"id": "0217853850436013bc9a923998b9a9cbb323528a1d3e323a2700b",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n### Key Innovation\n- First sequence transduction model based **solely on attention**\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable with significantly less training time\n\n### Performance Highlights\n- **WMT 2014 EN-DE**: 28.4 BLEU (+2+ over previous SOTA)\n- **WMT 2014 EN-FR**: 41.8 BLEU (new single-model SOTA)\n- Trained in 3.5 days on 8 GPUs (small fraction of previous costs)\n\n---\n\n## Background & Key Idea\n\n### Traditional Sequence Models\n- **Recurrent (LSTM/GRU)**: Sequential computation limits parallelization\n- **Convolutional**: Requires multiple layers for long-range dependencies\n\n### The Transformer\n- Replaces recurrence/convolution with **self-attention**\n- Enables direct modeling of long-range dependencies\n- Massive parallelization → faster training\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-96 mx-auto\" />\n\n*Encoder (left) and Decoder (right) with self-attention and feed-forward layers*\n\n---\n\n## Encoder & Decoder Stacks\n\n### Encoder (6 identical layers)\n- **Sub-layer 1**: Multi-head self-attention\n- **Sub-layer 2**: Position-wise feed-forward network\n- Residual connections + layer normalization\n- Output dimension: `d_model = 512`\n\n### Decoder (6 identical layers)\n- **Sub-layer 1**: Masked multi-head self-attention (prevents leftward flow)\n- **Sub-layer 2**: Multi-head attention over encoder output\n- **Sub-layer 3**: Position-wise feed-forward network\n- Same residual connections and normalization\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n- Scaling by $\\sqrt{d_k}$ prevents small gradients\n- Efficient with matrix multiplication\n\n### Multi-Head Attention\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1,...,\\text{head}_h)W^O$$\n- $h=8$ parallel heads, $d_k=d_v=64$\n- Captures diverse dependency patterns\n\n---\n\n## Attention Applications\n\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder \n2. **Encoder self-attention**: All positions attend to all input positions \n3. **Decoder self-attention**: Positions attend to previous positions (masked) \n\n---\n\n## Positional Encoding\n\nAdds sequence position information via sinusoidal functions:\n$$\\text{PE}_{(pos,2i)}=\\sin(pos/10000^{2i/d_{\\text{model}}})$$\n$$\\text{PE}_{(pos,2i+1)}=\\cos(pos/10000^{2i/d_{\\text{model}}})$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Enables learning of relative positions\n- Performs similarly to learned embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------------|------------------|----------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs\n- More interpretable attention patterns\n\n---\n\n## Training Setup\n\n### Data & Batching\n- WMT 2014 EN-DE (4.5M pairs), EN-FR (36M pairs)\n- Byte-pair encoding (37K/32K vocab)\n- Batches with ~25K source/target tokens\n\n### Hardware & Schedule\n- 8 NVIDIA P100 GPUs\n- Base model: 100K steps (12h), Big model: 300K steps (3.5d)\n\n### Optimization\n- Adam ($\\beta_1=0.9$, $\\beta_2=0.98$), learning rate warmup\n- Dropout (0.1), label smoothing (0.1)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|----------------------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)**| **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$**|\n\n- Outperforms all previous SOTA with lower training cost\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-96 w-full object-contain\" />\n\n*Encoder self-attention (layer 5) tracking \"making...more difficult\" dependency*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-96 w-full object-contain\" />\n\n*Attention heads resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion & Future Work\n\n### Key Contributions\n- Introduced Transformer, first attention-only transduction model\n- Eliminated recurrence/convolution → better parallelization\n- Set new SOTA in machine translation with lower training cost\n- Generalizes to other tasks (e.g., constituency parsing)\n\n### Future Work\n- Apply to other modalities (images, audio)\n- Explore local attention for large sequences\n- Improve generation sequentiality\n- Enhance attention interpretability\n\n**Code:** https://github.com/tensorflow/tensor2tensor\n```"
},
"usage": {
"prompt_tokens": 18829,
"completion_tokens": 2119,
"total_tokens": 20948,
"cached_prompt_tokens": 0
}
},
{
"meter": "Reviewer(每轮只看最新截图)",
"called_at_utc": "2026-07-30T04:18:56.153446+00:00",
"latency_s": 39.511,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名严格的演示文稿质量审核员(Reviewer)。你会看到一份由 Slidev 渲染出的 PPT,\n每张图对应一页幻灯片(按顺序编号,从第 1 页开始)。请逐页检查以下问题:\n\n- text_overflow(文字溢出/被裁切超出页面边界)\n- overcrowded(内容过多/过于拥挤/留白不足)\n- image_size(图片过大顶出布局,或过小看不清)\n- readability(字号过小、对比度差、代码块难读)\n- layout(对齐混乱、标题与正文比例失衡、空页)\n\n请以**目标用户是听众**的严格标准审查——一页幻灯片若要点超过约 5 条、或正文文字块偏长、\n或图片挤压了文字空间,都应视为 overcrowded/image_size 问题。报告真实存在的问题,\n但不要放过\"塞得太满\"。对每个问题给出:page(页码,整数)、\nissue_type(上面之一)、severityhigh/medium/low)、suggestion(具体、可执行的修改建议,中文)。\n\n同时给出:\n- overall_score0-100 的整体质量分(越高越好)\n- pass:布尔值,仅当整份 PPT **既无 high 也无 medium 级问题**、排版干净可读时才为 true\n\n严格输出如下 JSON(不要输出任何多余文字):\n{\n \"overall_score\": <int>,\n \"pass\": <bool>,\n \"issues\": [\n {\"page\": <int>, \"issue_type\": \"<type>\", \"severity\": \"<high|medium|low>\", \"suggestion\": \"<中文建议>\"}\n ]\n}"
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "这份 PPT 共 14 页,下面按页码顺序给出每一页的渲染截图。请审查。"
},
{
"type": "text",
"text": "第 1 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9d3c8d02979b8658be4dc98b1b914e4daf9ca6900e251a9c0d0c1225010ef208",
"characters": 61854,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 2 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "de1f8ac9c290fde8072ab2baecfa5117d5af3ea0743524d27fcfa0f67dce0dc6",
"characters": 155138,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 3 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "ecea27fcb38014d7a201537d7d34270862de36349682a3fc0b16cdc95011cb1d",
"characters": 146042,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 4 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "0eedf7de787893ea7baf40df422c98b0f004634d4e07bd58d4193b7100a143bb",
"characters": 169014,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 5 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "3b68ee00cf0687d942012fbad04eb0d48b2d8531f2ac877ec794c052baf4b331",
"characters": 189018,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 6 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "4b02c8b2a4836e2e41aae9da9fa42e508036588f448c593b90866e5260bb8a01",
"characters": 153882,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 7 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "8f7b1212ac4fad081fab53248710959a3a24cef8ccfb3f6c18533c6f9550b56d",
"characters": 96398,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 8 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "4702cb3592a561b59911bafde53e5c8b0e163d85c2a3efc5049bce46486e719b",
"characters": 120354,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 9 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "317afc56617303886072156d70c7f40b2c08f1a10b2545af504f8c656dcf3dfa",
"characters": 131406,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 10 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "2b30818d841c34c78733b698d5d0c79494ddc175164dee8bee1de57331e808e6",
"characters": 159662,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 11 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "3ea3f5d33395f0e164166778184da3b27a9b4eae27c21615de85d0dd015b2e43",
"characters": 110602,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 12 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "3ea18c28ce0fc814b7227950bd0623aead2898d75078a2273a5567ad8c615b99",
"characters": 198002,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 13 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "be3909357ea2edd2406b4c9889aeac6645aaf699276c3d9a9d6247b41d9350ea",
"characters": 202626,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 14 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "1e7cbdcbcdb68d8247497166bdb6d6eb25f0441926a76675ed17a226a53df4dd",
"characters": 196874,
"media_type": "image/png"
},
"detail": "high"
}
}
]
}
],
"temperature": 0.2
},
"response": {
"id": "021785385096891fb89e181bd9b21545a0eb5a18e7fe8dec4ee4f",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "{\n \"overall_score\": 75,\n \"pass\": false,\n \"issues\": [\n {\"page\": 4, \"issue_type\": \"image_size\", \"severity\": \"medium\", \"suggestion\": \"放大Transformer架构图,确保图中模块名称和连接关系清晰可见\"},\n {\"page\": 4, \"issue_type\": \"readability\", \"severity\": \"medium\", \"suggestion\": \"移除图片下方的长段文字说明,仅保留简洁标题或关键标注\"},\n {\"page\": 5, \"issue_type\": \"overcrowded\", \"severity\": \"medium\", \"suggestion\": \"将Encoder和Decoder内容拆分到两页,每页不超过4个要点\"},\n {\"page\": 10, \"issue_type\": \"overcrowded\", \"severity\": \"medium\", \"suggestion\": \"将Training Setup的三个部分拆分到单独页面,每个部分保留2-3个要点\"},\n {\"page\": 12, \"issue_type\": \"image_size\", \"severity\": \"high\", \"suggestion\": \"大幅放大注意力可视化图,确保文字标签和连接线清晰可辨\"},\n {\"page\": 12, \"issue_type\": \"readability\", \"severity\": \"high\", \"suggestion\": \"移除图片下方的详细说明文字,仅保留标题和简短解释\"},\n {\"page\": 13, \"issue_type\": \"image_size\", \"severity\": \"high\", \"suggestion\": \"大幅放大指代消解可视化图,确保文字和注意力权重分布清晰可见\"},\n {\"page\": 13, \"issue_type\": \"readability\", \"severity\": \"high\", \"suggestion\": \"移除图片下方的说明文字,改用简洁标题突出核心发现\"},\n {\"page\": 14, \"issue_type\": \"overcrowded\", \"severity\": \"medium\", \"suggestion\": \"将Key Contributions和Future Work拆分到两页,每部分保留3-4个要点\"}\n ]\n}"
},
"usage": {
"prompt_tokens": 17058,
"completion_tokens": 1883,
"total_tokens": 18941,
"cached_prompt_tokens": 0
}
},
{
"meter": "Proposer(纯文本)",
"called_at_utc": "2026-07-30T04:20:53.491724+00:00",
"latency_s": 117.325,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名擅长把学术论文转化为演示文稿的 Proposer Agent。\n你用 Slidev 框架(Markdown + HTML)编写 PPT 源码 slides.md。\n\nSlidev 语法要点:\n- 文件开头是 YAML frontmatter--- 包裹),设置 theme: default。\n- 用单独一行的 `---`(前后空行)分隔每一页幻灯片。\n- 首页通常放标题、作者、会议。\n- 引用图片用 markdown![说明](/图片文件名.png),可用 HTML 控制尺寸,\n 例如 <img src=\"/speedup_bar.png\" class=\"h-60 mx-auto\" />。\n- 可用 Windi/Uno CSS 工具类控制排版(如 text-sm、grid grid-cols-2 gap-4)。\n\n要求:\n- 最终生成 10-20 页,覆盖论文的标题、背景/动机、方法、实验结果、局限与结论。\n- 至少在 3 页中使用提供的图表/表格,且图文匹配。\n- 每页信息量适中、不要塞太多字,宁可拆页也不要溢出。\n- 只输出 slides.md 的完整内容,用 ```markdown 代码块包裹,不要额外解释。"
},
{
"role": "user",
"content": "以下是论文全文(Markdown):\n\n# Attention Is All You Need\n\nAuthors: Ashish Vaswani et al.\n\n\n## PDF page 1\n\nProvided proper attribution is provided, Google hereby grants permission to\nreproduce the tables and figures in this paper solely for use in journalistic or\nscholarly works.\nAttention Is All You Need\nAshish Vaswani\nGoogle Brain\navaswani@google.com\nNoam Shazeer\nGoogle Brain\nnoam@google.com\nNiki Parmar\nGoogle Research\nnikip@google.com\nJakob Uszkoreit\nGoogle Research\nusz@google.com\nLlion Jones\nGoogle Research\nllion@google.com\nAidan N. Gomez∗†\nUniversity of Toronto\naidan@cs.toronto.edu\nŁukasz Kaiser\nGoogle Brain\nlukaszkaiser@google.com\nIllia Polosukhin∗‡\nillia.polosukhin@gmail.com\nAbstract\nThe dominant sequence transduction models are based on complex recurrent or\nconvolutional neural networks that include an encoder and a decoder. The best\nperforming models also connect the encoder and decoder through an attention\nmechanism. We propose a new simple network architecture, the Transformer,\nbased solely on attention mechanisms, dispensing with recurrence and convolutions\nentirely. Experiments on two machine translation tasks show these models to\nbe superior in quality while being more parallelizable and requiring significantly\nless time to train. Our model achieves 28.4 BLEU on the WMT 2014 English-\nto-German translation task, improving over the existing best results, including\nensembles, by over 2 BLEU. On the WMT 2014 English-to-French translation task,\nour model establishes a new single-model state-of-the-art BLEU score of 41.8 after\ntraining for 3.5 days on eight GPUs, a small fraction of the training costs of the\nbest models from the literature. We show that the Transformer generalizes well to\nother tasks by applying it successfully to English constituency parsing both with\nlarge and limited training data.\nEqual contribution. Listing order is random. Jakob proposed replacing RNNs with self-attention and started\nthe effort to evaluate this idea. Ashish, with Illia, designed and implemented the first Transformer models and\nhas been crucially involved in every aspect of this work. Noam proposed scaled dot-product attention, multi-head\nattention and the parameter-free position representation and became the other person involved in nearly every\ndetail. Niki designed, implemented, tuned and evaluated countless model variants in our original codebase and\ntensor2tensor. Llion also experimented with novel model variants, was responsible for our initial codebase, and\nefficient inference and visualizations. Lukasz and Aidan spent countless long days designing various parts of and\nimplementing tensor2tensor, replacing our earlier codebase, greatly improving results and massively accelerating\nour research.\n†Work performed while at Google Brain.\n‡Work performed while at Google Research.\n31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA.\narXiv:1706.03762v7 [cs.CL] 2 Aug 2023\n\n\n## PDF page 2\n\n1\nIntroduction\nRecurrent neural networks, long short-term memory [13] and gated recurrent [7] neural networks\nin particular, have been firmly established as state of the art approaches in sequence modeling and\ntransduction problems such as language modeling and machine translation [35, 2, 5]. Numerous\nefforts have since continued to push the boundaries of recurrent language models and encoder-decoder\narchitectures [38, 24, 15].\nRecurrent models typically factor computation along the symbol positions of the input and output\nsequences. Aligning the positions to steps in computation time, they generate a sequence of hidden\nstates ht, as a function of the previous hidden state ht1 and the input for position t. This inherently\nsequential nature precludes parallelization within training examples, which becomes critical at longer\nsequence lengths, as memory constraints limit batching across examples. Recent work has achieved\nsignificant improvements in computational efficiency through factorization tricks [21] and conditional\ncomputation [32], while also improving model performance in case of the latter. The fundamental\nconstraint of sequential computation, however, remains.\nAttention mechanisms have become an integral part of compelling sequence modeling and transduc-\ntion models in various tasks, allowing modeling of dependencies without regard to their distance in\nthe input or output sequences [2, 19]. In all but a few cases [27], however, such attention mechanisms\nare used in conjunction with a recurrent network.\nIn this work we propose the Transformer, a model architecture eschewing recurrence and instead\nrelying entirely on an attention mechanism to draw global dependencies between input and output.\nThe Transformer allows for significantly more parallelization and can reach a new state of the art in\ntranslation quality after being trained for as little as twelve hours on eight P100 GPUs.\n2\nBackground\nThe goal of reducing sequential computation also forms the foundation of the Extended Neural GPU\n[16], ByteNet [18] and ConvS2S [9], all of which use convolutional neural networks as basic building\nblock, computing hidden representations in parallel for all input and output positions. In these models,\nthe number of operations required to relate signals from two arbitrary input or output positions grows\nin the distance between positions, linearly for ConvS2S and logarithmically for ByteNet. This makes\nit more difficult to learn dependencies between distant positions [12]. In the Transformer this is\nreduced to a constant number of operations, albeit at the cost of reduced effective resolution due\nto averaging attention-weighted positions, an effect we counteract with Multi-Head Attention as\ndescribed in section 3.2.\nSelf-attention, sometimes called intra-attention is an attention mechanism relating different positions\nof a single sequence in order to compute a representation of the sequence. Self-attention has been\nused successfully in a variety of tasks including reading comprehension, abstractive summarization,\ntextual entailment and learning task-independent sentence representations [4, 27, 28, 22].\nEnd-to-end memory networks are based on a recurrent attention mechanism instead of sequence-\naligned recurrence and have been shown to perform well on simple-language question answering and\nlanguage modeling tasks [34].\nTo the best of our knowledge, however, the Transformer is the first transduction model relying\nentirely on self-attention to compute representations of its input and output without using sequence-\naligned RNNs or convolution. In the following sections, we will describe the Transformer, motivate\nself-attention and discuss its advantages over models such as [17, 18] and [9].\n3\nModel Architecture\nMost competitive neural sequence transduction models have an encoder-decoder structure [5, 2, 35].\nHere, the encoder maps an input sequence of symbol representations (x1, ..., xn) to a sequence\nof continuous representations z = (z1, ..., zn). Given z, the decoder then generates an output\nsequence (y1, ..., ym) of symbols one element at a time. At each step the model is auto-regressive\n[10], consuming the previously generated symbols as additional input when generating the next.\n2\n\n\n## PDF page 3\n\nFigure 1: The Transformer - model architecture.\nThe Transformer follows this overall architecture using stacked self-attention and point-wise, fully\nconnected layers for both the encoder and decoder, shown in the left and right halves of Figure 1,\nrespectively.\n3.1\nEncoder and Decoder Stacks\nEncoder:\nThe encoder is composed of a stack of N = 6 identical layers. Each layer has two\nsub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, position-\nwise fully connected feed-forward network. We employ a residual connection [11] around each of\nthe two sub-layers, followed by layer normalization [1]. That is, the output of each sub-layer is\nLayerNorm(x + Sublayer(x)), where Sublayer(x) is the function implemented by the sub-layer\nitself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding\nlayers, produce outputs of dimension dmodel = 512.\nDecoder:\nThe decoder is also composed of a stack of N = 6 identical layers. In addition to the two\nsub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head\nattention over the output of the encoder stack. Similar to the encoder, we employ residual connections\naround each of the sub-layers, followed by layer normalization. We also modify the self-attention\nsub-layer in the decoder stack to prevent positions from attending to subsequent positions. This\nmasking, combined with fact that the output embeddings are offset by one position, ensures that the\npredictions for position i can depend only on the known outputs at positions less than i.\n3.2\nAttention\nAn attention function can be described as mapping a query and a set of key-value pairs to an output,\nwhere the query, keys, values, and output are all vectors. The output is computed as a weighted sum\n3\n\n\n## PDF page 4\n\nScaled Dot-Product Attention\nMulti-Head Attention\nFigure 2: (left) Scaled Dot-Product Attention. (right) Multi-Head Attention consists of several\nattention layers running in parallel.\nof the values, where the weight assigned to each value is computed by a compatibility function of the\nquery with the corresponding key.\n3.2.1\nScaled Dot-Product Attention\nWe call our particular attention \"Scaled Dot-Product Attention\" (Figure 2). The input consists of\nqueries and keys of dimension dk, and values of dimension dv. We compute the dot products of the\nquery with all keys, divide each by √dk, and apply a softmax function to obtain the weights on the\nvalues.\nIn practice, we compute the attention function on a set of queries simultaneously, packed together\ninto a matrix Q. The keys and values are also packed together into matrices K and V . We compute\nthe matrix of outputs as:\nAttention(Q, K, V ) = softmax(QKT\n√dk\n)V\n(1)\nThe two most commonly used attention functions are additive attention [2], and dot-product (multi-\nplicative) attention. Dot-product attention is identical to our algorithm, except for the scaling factor\nof\n1\n√dk . Additive attention computes the compatibility function using a feed-forward network with\na single hidden layer. While the two are similar in theoretical complexity, dot-product attention is\nmuch faster and more space-efficient in practice, since it can be implemented using highly optimized\nmatrix multiplication code.\nWhile for small values of dk the two mechanisms perform similarly, additive attention outperforms\ndot product attention without scaling for larger values of dk [3]. We suspect that for large values of\ndk, the dot products grow large in magnitude, pushing the softmax function into regions where it has\nextremely small gradients 4. To counteract this effect, we scale the dot products by\n1\n√dk .\n3.2.2\nMulti-Head Attention\nInstead of performing a single attention function with dmodel-dimensional keys, values and queries,\nwe found it beneficial to linearly project the queries, keys and values h times with different, learned\nlinear projections to dk, dk and dv dimensions, respectively. On each of these projected versions of\nqueries, keys and values we then perform the attention function in parallel, yielding dv-dimensional\n4To illustrate why the dot products get large, assume that the components of q and k are independent random\nvariables with mean 0 and variance 1. Then their dot product, q · k = Pdk\ni=1 qiki, has mean 0 and variance dk.\n4\n\n\n## PDF page 5\n\noutput values. These are concatenated and once again projected, resulting in the final values, as\ndepicted in Figure 2.\nMulti-head attention allows the model to jointly attend to information from different representation\nsubspaces at different positions. With a single attention head, averaging inhibits this.\nMultiHead(Q, K, V ) = Concat(head1, ..., headh)W O\nwhere headi = Attention(QW Q\ni , KW K\ni , V W V\ni )\nWhere the projections are parameter matrices W Q\ni\n∈Rdmodel×dk, W K\ni\n∈Rdmodel×dk, W V\ni\n∈Rdmodel×dv\nand W O ∈Rhdv×dmodel.\nIn this work we employ h = 8 parallel attention layers, or heads. For each of these we use\ndk = dv = dmodel/h = 64. Due to the reduced dimension of each head, the total computational cost\nis similar to that of single-head attention with full dimensionality.\n3.2.3\nApplications of Attention in our Model\nThe Transformer uses multi-head attention in three different ways:\n• In \"encoder-decoder attention\" layers, the queries come from the previous decoder layer,\nand the memory keys and values come from the output of the encoder. This allows every\nposition in the decoder to attend over all positions in the input sequence. This mimics the\ntypical encoder-decoder attention mechanisms in sequence-to-sequence models such as\n[38, 2, 9].\n• The encoder contains self-attention layers. In a self-attention layer all of the keys, values\nand queries come from the same place, in this case, the output of the previous layer in the\nencoder. Each position in the encoder can attend to all positions in the previous layer of the\nencoder.\n• Similarly, self-attention layers in the decoder allow each position in the decoder to attend to\nall positions in the decoder up to and including that position. We need to prevent leftward\ninformation flow in the decoder to preserve the auto-regressive property. We implement this\ninside of scaled dot-product attention by masking out (setting to −∞) all values in the input\nof the softmax which correspond to illegal connections. See Figure 2.\n3.3\nPosition-wise Feed-Forward Networks\nIn addition to attention sub-layers, each of the layers in our encoder and decoder contains a fully\nconnected feed-forward network, which is applied to each position separately and identically. This\nconsists of two linear transformations with a ReLU activation in between.\nFFN(x) = max(0, xW1 + b1)W2 + b2\n(2)\nWhile the linear transformations are the same across different positions, they use different parameters\nfrom layer to layer. Another way of describing this is as two convolutions with kernel size 1.\nThe dimensionality of input and output is dmodel = 512, and the inner-layer has dimensionality\ndff = 2048.\n3.4\nEmbeddings and Softmax\nSimilarly to other sequence transduction models, we use learned embeddings to convert the input\ntokens and output tokens to vectors of dimension dmodel. We also use the usual learned linear transfor-\nmation and softmax function to convert the decoder output to predicted next-token probabilities. In\nour model, we share the same weight matrix between the two embedding layers and the pre-softmax\nlinear transformation, similar to [30]. In the embedding layers, we multiply those weights by √dmodel.\n5\n\n\n## PDF page 6\n\nTable 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations\nfor different layer types. n is the sequence length, d is the representation dimension, k is the kernel\nsize of convolutions and r the size of the neighborhood in restricted self-attention.\nLayer Type\nComplexity per Layer\nSequential\nMaximum Path Length\nOperations\nSelf-Attention\nO(n2 · d)\nO(1)\nO(1)\nRecurrent\nO(n · d2)\nO(n)\nO(n)\nConvolutional\nO(k · n · d2)\nO(1)\nO(logk(n))\nSelf-Attention (restricted)\nO(r · n · d)\nO(1)\nO(n/r)\n3.5\nPositional Encoding\nSince our model contains no recurrence and no convolution, in order for the model to make use of the\norder of the sequence, we must inject some information about the relative or absolute position of the\ntokens in the sequence. To this end, we add \"positional encodings\" to the input embeddings at the\nbottoms of the encoder and decoder stacks. The positional encodings have the same dimension dmodel\nas the embeddings, so that the two can be summed. There are many choices of positional encodings,\nlearned and fixed [9].\nIn this work, we use sine and cosine functions of different frequencies:\nPE(pos,2i) = sin(pos/100002i/dmodel)\nPE(pos,2i+1) = cos(pos/100002i/dmodel)\nwhere pos is the position and i is the dimension. That is, each dimension of the positional encoding\ncorresponds to a sinusoid. The wavelengths form a geometric progression from 2π to 10000 · 2π. We\nchose this function because we hypothesized it would allow the model to easily learn to attend by\nrelative positions, since for any fixed offset k, PEpos+k can be represented as a linear function of\nPEpos.\nWe also experimented with using learned positional embeddings [9] instead, and found that the two\nversions produced nearly identical results (see Table 3 row (E)). We chose the sinusoidal version\nbecause it may allow the model to extrapolate to sequence lengths longer than the ones encountered\nduring training.\n4\nWhy Self-Attention\nIn this section we compare various aspects of self-attention layers to the recurrent and convolu-\ntional layers commonly used for mapping one variable-length sequence of symbol representations\n(x1, ..., xn) to another sequence of equal length (z1, ..., zn), with xi, zi ∈Rd, such as a hidden\nlayer in a typical sequence transduction encoder or decoder. Motivating our use of self-attention we\nconsider three desiderata.\nOne is the total computational complexity per layer. Another is the amount of computation that can\nbe parallelized, as measured by the minimum number of sequential operations required.\nThe third is the path length between long-range dependencies in the network. Learning long-range\ndependencies is a key challenge in many sequence transduction tasks. One key factor affecting the\nability to learn such dependencies is the length of the paths forward and backward signals have to\ntraverse in the network. The shorter these paths between any combination of positions in the input\nand output sequences, the easier it is to learn long-range dependencies [12]. Hence we also compare\nthe maximum path length between any two input and output positions in networks composed of the\ndifferent layer types.\nAs noted in Table 1, a self-attention layer connects all positions with a constant number of sequentially\nexecuted operations, whereas a recurrent layer requires O(n) sequential operations. In terms of\ncomputational complexity, self-attention layers are faster than recurrent layers when the sequence\n6\n\n\n## PDF page 7\n\nlength n is smaller than the representation dimensionality d, which is most often the case with\nsentence representations used by state-of-the-art models in machine translations, such as word-piece\n[38] and byte-pair [31] representations. To improve computational performance for tasks involving\nvery long sequences, self-attention could be restricted to considering only a neighborhood of size r in\nthe input sequence centered around the respective output position. This would increase the maximum\npath length to O(n/r). We plan to investigate this approach further in future work.\nA single convolutional layer with kernel width k < n does not connect all pairs of input and output\npositions. Doing so requires a stack of O(n/k) convolutional layers in the case of contiguous kernels,\nor O(logk(n)) in the case of dilated convolutions [18], increasing the length of the longest paths\nbetween any two positions in the network. Convolutional layers are generally more expensive than\nrecurrent layers, by a factor of k. Separable convolutions [6], however, decrease the complexity\nconsiderably, to O(k · n · d + n · d2). Even with k = n, however, the complexity of a separable\nconvolution is equal to the combination of a self-attention layer and a point-wise feed-forward layer,\nthe approach we take in our model.\nAs side benefit, self-attention could yield more interpretable models. We inspect attention distributions\nfrom our models and present and discuss examples in the appendix. Not only do individual attention\nheads clearly learn to perform different tasks, many appear to exhibit behavior related to the syntactic\nand semantic structure of the sentences.\n5\nTraining\nThis section describes the training regime for our models.\n5.1\nTraining Data and Batching\nWe trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million\nsentence pairs. Sentences were encoded using byte-pair encoding [3], which has a shared source-\ntarget vocabulary of about 37000 tokens. For English-French, we used the significantly larger WMT\n2014 English-French dataset consisting of 36M sentences and split tokens into a 32000 word-piece\nvocabulary [38]. Sentence pairs were batched together by approximate sequence length. Each training\nbatch contained a set of sentence pairs containing approximately 25000 source tokens and 25000\ntarget tokens.\n5.2\nHardware and Schedule\nWe trained our models on one machine with 8 NVIDIA P100 GPUs. For our base models using\nthe hyperparameters described throughout the paper, each training step took about 0.4 seconds. We\ntrained the base models for a total of 100,000 steps or 12 hours. For our big models,(described on the\nbottom line of table 3), step time was 1.0 seconds. The big models were trained for 300,000 steps\n(3.5 days).\n5.3\nOptimizer\nWe used the Adam optimizer [20] with β1 = 0.9, β2 = 0.98 and ϵ = 109. We varied the learning\nrate over the course of training, according to the formula:\nlrate = d0.5\nmodel · min(step_num0.5, step_num · warmup_steps1.5)\n(3)\nThis corresponds to increasing the learning rate linearly for the first warmup_steps training steps,\nand decreasing it thereafter proportionally to the inverse square root of the step number. We used\nwarmup_steps = 4000.\n5.4\nRegularization\nWe employ three types of regularization during training:\n7\n\n\n## PDF page 8\n\nTable 2: The Transformer achieves better BLEU scores than previous state-of-the-art models on the\nEnglish-to-German and English-to-French newstest2014 tests at a fraction of the training cost.\nModel\nBLEU\nTraining Cost (FLOPs)\nEN-DE\nEN-FR\nEN-DE\nEN-FR\nByteNet [18]\n23.75\nDeep-Att + PosUnk [39]\n39.2\n1.0 · 1020\nGNMT + RL [38]\n24.6\n39.92\n2.3 · 1019\n1.4 · 1020\nConvS2S [9]\n25.16\n40.46\n9.6 · 1018\n1.5 · 1020\nMoE [32]\n26.03\n40.56\n2.0 · 1019\n1.2 · 1020\nDeep-Att + PosUnk Ensemble [39]\n40.4\n8.0 · 1020\nGNMT + RL Ensemble [38]\n26.30\n41.16\n1.8 · 1020\n1.1 · 1021\nConvS2S Ensemble [9]\n26.36\n41.29\n7.7 · 1019\n1.2 · 1021\nTransformer (base model)\n27.3\n38.1\n3.3 · 1018\nTransformer (big)\n28.4\n41.8\n2.3 · 1019\nResidual Dropout\nWe apply dropout [33] to the output of each sub-layer, before it is added to the\nsub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the\npositional encodings in both the encoder and decoder stacks. For the base model, we use a rate of\nPdrop = 0.1.\nLabel Smoothing\nDuring training, we employed label smoothing of value ϵls = 0.1 [36]. This\nhurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.\n6\nResults\n6.1\nMachine Translation\nOn the WMT 2014 English-to-German translation task, the big transformer model (Transformer (big)\nin Table 2) outperforms the best previously reported models (including ensembles) by more than 2.0\nBLEU, establishing a new state-of-the-art BLEU score of 28.4. The configuration of this model is\nlisted in the bottom line of Table 3. Training took 3.5 days on 8 P100 GPUs. Even our base model\nsurpasses all previously published models and ensembles, at a fraction of the training cost of any of\nthe competitive models.\nOn the WMT 2014 English-to-French translation task, our big model achieves a BLEU score of 41.0,\noutperforming all of the previously published single models, at less than 1/4 the training cost of the\nprevious state-of-the-art model. The Transformer (big) model trained for English-to-French used\ndropout rate Pdrop = 0.1, instead of 0.3.\nFor the base models, we used a single model obtained by averaging the last 5 checkpoints, which\nwere written at 10-minute intervals. For the big models, we averaged the last 20 checkpoints. We\nused beam search with a beam size of 4 and length penalty α = 0.6 [38]. These hyperparameters\nwere chosen after experimentation on the development set. We set the maximum output length during\ninference to input length + 50, but terminate early when possible [38].\nTable 2 summarizes our results and compares our translation quality and training costs to other model\narchitectures from the literature. We estimate the number of floating point operations used to train a\nmodel by multiplying the training time, the number of GPUs used, and an estimate of the sustained\nsingle-precision floating-point capacity of each GPU 5.\n6.2\nModel Variations\nTo evaluate the importance of different components of the Transformer, we varied our base model\nin different ways, measuring the change in performance on English-to-German translation on the\n5We used values of 2.8, 3.7, 6.0 and 9.5 TFLOPS for K80, K40, M40 and P100, respectively.\n8\n\n\n## PDF page 9\n\nTable 3: Variations on the Transformer architecture. Unlisted values are identical to those of the base\nmodel. All metrics are on the English-to-German translation development set, newstest2013. Listed\nperplexities are per-wordpiece, according to our byte-pair encoding, and should not be compared to\nper-word perplexities.\nN\ndmodel\ndff\nh\ndk\ndv\nPdrop\nϵls\ntrain\nPPL\nBLEU\nparams\nsteps\n(dev)\n(dev)\n×106\nbase\n6\n512\n2048\n8\n64\n64\n0.1\n0.1\n100K\n4.92\n25.8\n65\n(A)\n1\n512\n512\n5.29\n24.9\n4\n128\n128\n5.00\n25.5\n16\n32\n32\n4.91\n25.8\n32\n16\n16\n5.01\n25.4\n(B)\n16\n5.16\n25.1\n58\n32\n5.01\n25.4\n60\n(C)\n2\n6.11\n23.7\n36\n4\n5.19\n25.3\n50\n8\n4.88\n25.5\n80\n256\n32\n32\n5.75\n24.5\n28\n1024\n128\n128\n4.66\n26.0\n168\n1024\n5.12\n25.4\n53\n4096\n4.75\n26.2\n90\n(D)\n0.0\n5.77\n24.6\n0.2\n4.95\n25.5\n0.0\n4.67\n25.3\n0.2\n5.47\n25.7\n(E)\npositional embedding instead of sinusoids\n4.92\n25.7\nbig\n6\n1024\n4096\n16\n0.3\n300K\n4.33\n26.4\n213\ndevelopment set, newstest2013. We used beam search as described in the previous section, but no\ncheckpoint averaging. We present these results in Table 3.\nIn Table 3 rows (A), we vary the number of attention heads and the attention key and value dimensions,\nkeeping the amount of computation constant, as described in Section 3.2.2. While single-head\nattention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.\nIn Table 3 rows (B), we observe that reducing the attention key size dk hurts model quality. This\nsuggests that determining compatibility is not easy and that a more sophisticated compatibility\nfunction than dot product may be beneficial. We further observe in rows (C) and (D) that, as expected,\nbigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our\nsinusoidal positional encoding with learned positional embeddings [9], and observe nearly identical\nresults to the base model.\n6.3\nEnglish Constituency Parsing\nTo evaluate if the Transformer can generalize to other tasks we performed experiments on English\nconstituency parsing. This task presents specific challenges: the output is subject to strong structural\nconstraints and is significantly longer than the input. Furthermore, RNN sequence-to-sequence\nmodels have not been able to attain state-of-the-art results in small-data regimes [37].\nWe trained a 4-layer transformer with dmodel = 1024 on the Wall Street Journal (WSJ) portion of the\nPenn Treebank [25], about 40K training sentences. We also trained it in a semi-supervised setting,\nusing the larger high-confidence and BerkleyParser corpora from with approximately 17M sentences\n[37]. We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens\nfor the semi-supervised setting.\nWe performed only a small number of experiments to select the dropout, both attention and residual\n(section 5.4), learning rates and beam size on the Section 22 development set, all other parameters\nremained unchanged from the English-to-German base translation model. During inference, we\n9\n\n\n## PDF page 10\n\nTable 4: The Transformer generalizes well to English constituency parsing (Results are on Section 23\nof WSJ)\nParser\nTraining\nWSJ 23 F1\nVinyals & Kaiser el al. (2014) [37]\nWSJ only, discriminative\n88.3\nPetrov et al. (2006) [29]\nWSJ only, discriminative\n90.4\nZhu et al. (2013) [40]\nWSJ only, discriminative\n90.4\nDyer et al. (2016) [8]\nWSJ only, discriminative\n91.7\nTransformer (4 layers)\nWSJ only, discriminative\n91.3\nZhu et al. (2013) [40]\nsemi-supervised\n91.3\nHuang & Harper (2009) [14]\nsemi-supervised\n91.3\nMcClosky et al. (2006) [26]\nsemi-supervised\n92.1\nVinyals & Kaiser el al. (2014) [37]\nsemi-supervised\n92.1\nTransformer (4 layers)\nsemi-supervised\n92.7\nLuong et al. (2015) [23]\nmulti-task\n93.0\nDyer et al. (2016) [8]\ngenerative\n93.3\nincreased the maximum output length to input length + 300. We used a beam size of 21 and α = 0.3\nfor both WSJ only and the semi-supervised setting.\nOur results in Table 4 show that despite the lack of task-specific tuning our model performs sur-\nprisingly well, yielding better results than all previously reported models with the exception of the\nRecurrent Neural Network Grammar [8].\nIn contrast to RNN sequence-to-sequence models [37], the Transformer outperforms the Berkeley-\nParser [29] even when training only on the WSJ training set of 40K sentences.\n7\nConclusion\nIn this work, we presented the Transformer, the first sequence transduction model based entirely on\nattention, replacing the recurrent layers most commonly used in encoder-decoder architectures with\nmulti-headed self-attention.\nFor translation tasks, the Transformer can be trained significantly faster than architectures based\non recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014\nEnglish-to-French translation tasks, we achieve a new state of the art. In the former task our best\nmodel outperforms even all previously reported ensembles.\nWe are excited about the future of attention-based models and plan to apply them to other tasks. We\nplan to extend the Transformer to problems involving input and output modalities other than text and\nto investigate local, restricted attention mechanisms to efficiently handle large inputs and outputs\nsuch as images, audio and video. Making generation less sequential is another research goals of ours.\nThe code we used to train and evaluate our models is available at https://github.com/\ntensorflow/tensor2tensor.\nAcknowledgements\nWe are grateful to Nal Kalchbrenner and Stephan Gouws for their fruitful\ncomments, corrections and inspiration.\nReferences\n[1] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint\narXiv:1607.06450, 2016.\n[2] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly\nlearning to align and translate. CoRR, abs/1409.0473, 2014.\n[3] Denny Britz, Anna Goldie, Minh-Thang Luong, and Quoc V. Le. Massive exploration of neural\nmachine translation architectures. CoRR, abs/1703.03906, 2017.\n[4] Jianpeng Cheng, Li Dong, and Mirella Lapata. Long short-term memory-networks for machine\nreading. arXiv preprint arXiv:1601.06733, 2016.\n10\n\n\n## PDF page 11\n\n[5] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk,\nand Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical\nmachine translation. CoRR, abs/1406.1078, 2014.\n[6] Francois Chollet. Xception: Deep learning with depthwise separable convolutions. arXiv\npreprint arXiv:1610.02357, 2016.\n[7] Junyoung Chung, Çaglar Gülçehre, Kyunghyun Cho, and Yoshua Bengio. Empirical evaluation\nof gated recurrent neural networks on sequence modeling. CoRR, abs/1412.3555, 2014.\n[8] Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, and Noah A. Smith. Recurrent neural\nnetwork grammars. In Proc. of NAACL, 2016.\n[9] Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. Convolu-\ntional sequence to sequence learning. arXiv preprint arXiv:1705.03122v2, 2017.\n[10] Alex Graves.\nGenerating sequences with recurrent neural networks.\narXiv preprint\narXiv:1308.0850, 2013.\n[11] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for im-\nage recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern\nRecognition, pages 770778, 2016.\n[12] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber. Gradient flow in\nrecurrent nets: the difficulty of learning long-term dependencies, 2001.\n[13] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation,\n9(8):17351780, 1997.\n[14] Zhongqiang Huang and Mary Harper. Self-training PCFG grammars with latent annotations\nacross languages. In Proceedings of the 2009 Conference on Empirical Methods in Natural\nLanguage Processing, pages 832841. ACL, August 2009.\n[15] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring\nthe limits of language modeling. arXiv preprint arXiv:1602.02410, 2016.\n[16] Łukasz Kaiser and Samy Bengio. Can active memory replace attention? In Advances in Neural\nInformation Processing Systems, (NIPS), 2016.\n[17] Łukasz Kaiser and Ilya Sutskever. Neural GPUs learn algorithms. In International Conference\non Learning Representations (ICLR), 2016.\n[18] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Ko-\nray Kavukcuoglu. Neural machine translation in linear time. arXiv preprint arXiv:1610.10099v2,\n2017.\n[19] Yoon Kim, Carl Denton, Luong Hoang, and Alexander M. Rush. Structured attention networks.\nIn International Conference on Learning Representations, 2017.\n[20] Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.\n[21] Oleksii Kuchaiev and Boris Ginsburg. Factorization tricks for LSTM networks. arXiv preprint\narXiv:1703.10722, 2017.\n[22] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen\nZhou, and Yoshua Bengio. A structured self-attentive sentence embedding. arXiv preprint\narXiv:1703.03130, 2017.\n[23] Minh-Thang Luong, Quoc V. Le, Ilya Sutskever, Oriol Vinyals, and Lukasz Kaiser. Multi-task\nsequence to sequence learning. arXiv preprint arXiv:1511.06114, 2015.\n[24] Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-\nbased neural machine translation. arXiv preprint arXiv:1508.04025, 2015.\n11\n\n\n## PDF page 12\n\n[25] Mitchell P Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. Building a large annotated\ncorpus of english: The penn treebank. Computational linguistics, 19(2):313330, 1993.\n[26] David McClosky, Eugene Charniak, and Mark Johnson. Effective self-training for parsing. In\nProceedings of the Human Language Technology Conference of the NAACL, Main Conference,\npages 152159. ACL, June 2006.\n[27] Ankur Parikh, Oscar Täckström, Dipanjan Das, and Jakob Uszkoreit. A decomposable attention\nmodel. In Empirical Methods in Natural Language Processing, 2016.\n[28] Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive\nsummarization. arXiv preprint arXiv:1705.04304, 2017.\n[29] Slav Petrov, Leon Barrett, Romain Thibaux, and Dan Klein. Learning accurate, compact,\nand interpretable tree annotation. In Proceedings of the 21st International Conference on\nComputational Linguistics and 44th Annual Meeting of the ACL, pages 433440. ACL, July\n2006.\n[30] Ofir Press and Lior Wolf. Using the output embedding to improve language models. arXiv\npreprint arXiv:1608.05859, 2016.\n[31] Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words\nwith subword units. arXiv preprint arXiv:1508.07909, 2015.\n[32] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton,\nand Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts\nlayer. arXiv preprint arXiv:1701.06538, 2017.\n[33] Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdi-\nnov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine\nLearning Research, 15(1):19291958, 2014.\n[34] Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory\nnetworks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors,\nAdvances in Neural Information Processing Systems 28, pages 24402448. Curran Associates,\nInc., 2015.\n[35] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. Sequence to sequence learning with neural\nnetworks. In Advances in Neural Information Processing Systems, pages 31043112, 2014.\n[36] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna.\nRethinking the inception architecture for computer vision. CoRR, abs/1512.00567, 2015.\n[37] Vinyals & Kaiser, Koo, Petrov, Sutskever, and Hinton. Grammar as a foreign language. In\nAdvances in Neural Information Processing Systems, 2015.\n[38] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang\nMacherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Googles neural machine\ntranslation system: Bridging the gap between human and machine translation. arXiv preprint\narXiv:1609.08144, 2016.\n[39] Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. Deep recurrent models with\nfast-forward connections for neural machine translation. CoRR, abs/1606.04199, 2016.\n[40] Muhua Zhu, Yue Zhang, Wenliang Chen, Min Zhang, and Jingbo Zhu. Fast and accurate\nshift-reduce constituent parsing. In Proceedings of the 51st Annual Meeting of the ACL (Volume\n1: Long Papers), pages 434443. ACL, August 2013.\n12\n\n\n## PDF page 13\n\nAttention Visualizations\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nFigure 3: An example of the attention mechanism following long-distance dependencies in the\nencoder self-attention in layer 5 of 6. Many of the attention heads attend to a distant dependency of\nthe verb making, completing the phrase making...more difficult. Attentions here shown only for\nthe word making. Different colors represent different heads. Best viewed in color.\n13\n\n\n## PDF page 14\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 4: Two attention heads, also in layer 5 of 6, apparently involved in anaphora resolution. Top:\nFull attentions for head 5. Bottom: Isolated attentions from just the word its for attention heads 5\nand 6. Note that the attentions are very sharp for this word.\n14\n\n\n## PDF page 15\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 5: Many of the attention heads exhibit behaviour that seems related to the structure of the\nsentence. We give two such examples above, from two different heads from the encoder self-attention\nat layer 5 of 6. The heads clearly learned to perform different tasks.\n15\n\n\n可直接引用的图表文件(放在 Slidev public 目录,用 /文件名 引用):\n- paper_figure_1_transformer.pngFigure 1 from PDF page 3: The Transformer model architecture.\n- paper_figure_3_long_distance.pngFigure 3 from PDF page 13: Encoder self-attention following long-distance dependencies.\n- paper_figure_4_anaphora.pngFigure 4 from PDF page 14: Attention heads involved in anaphora resolution.\n\n请生成一版 10-20 页的完整初稿。内容必须忠于论文,至少引用上面列出的三张原论文图,并覆盖问题、Transformer 架构、注意力机制、训练、主要实验、局限和结论。不要复制长段原文;每页保持听众可读的信息密度。生成完整的 slides.md。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n- Proposes **Transformer** - a new network architecture based solely on attention mechanisms\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- Achieves state-of-the-art results on machine translation tasks:\n - 28.4 BLEU on WMT 2014 English-to-German\n - 41.8 BLEU on WMT 2014 English-to-French\n- Generalizes well to other tasks like English constituency parsing\n\n---\n\n## Background: Sequence Transduction Challenges\n\n### Traditional Approaches\n- **Recurrent models** (LSTM, GRU) have sequential computation\n- **Convolutional models** have limited long-range dependencies\n- Both have challenges with parallelization and long sequences\n\n### Attention Mechanisms\n- Already used in conjunction with recurrent networks\n- Allows modeling dependencies without regard to distance\n- But not used as the primary architecture... until now\n\n---\n\n## The Transformer: Key Idea\n\nReplace recurrence and convolution with **self-attention** to:\n- Enable more parallelization\n- Reduce sequential computation\n- Capture long-range dependencies more effectively\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n*Encoder (left) and Decoder (right) stacks with self-attention and feed-forward layers*\n\n---\n\n## Encoder Stack\n\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections around each sub-layer\n- Layer normalization after each sub-layer\n- All sub-layers produce outputs of dimension `d_model = 512`\n\n---\n\n## Decoder Stack\n\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward information flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Same residual connections and layer normalization as encoder\n- Output embeddings offset by one position (auto-regressive property)\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-40 mx-auto\" />\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder\n2. **Encoder self-attention**: All positions attend to all positions in previous encoder layer\n3. **Decoder self-attention**: Positions attend to previous positions (masked to preserve auto-regressive property)\n\n---\n\n## Positional Encoding\n\nSince there's no recurrence/convolution, we add positional information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performed similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Details\n\n### Data & Batching\n- WMT 2014 English-German (4.5M sentence pairs)\n- WMT 2014 English-French (36M sentence pairs)\n- Byte-pair encoding with shared vocabulary\n- Batches with ~25,000 source and target tokens\n\n### Hardware & Schedule\n- 8 NVIDIA P100 GPUs\n- Base model: 100,000 steps (12 hours)\n- Big model: 300,000 steps (3.5 days)\n\n---\n\n## Training Details (Cont.)\n\n### Optimizer\n- Adam with $\\beta_1 = 0.9$, $\\beta_2 = 0.98$, $\\epsilon = 10^{-9}$\n- Learning rate schedule:\n $$\\text{lrate} = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step\\_num}^{-0.5}, \\text{step\\_num} \\cdot \\text{warmup\\_steps}^{-1.5})$$\n- Warmup steps = 4000\n\n### Regularization\n- Residual dropout (P_drop = 0.1)\n- Label smoothing ($\\epsilon_{ls} = 0.1$)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n- 2+ BLEU improvement on English-to-German\n\n---\n\n## Model Architecture Ablations\n\n| Variation | Dev PPL | Dev BLEU |\n|-----------|---------|----------|\n| Base model | 4.92 | 25.8 |\n| (A) 1 attention head | 5.29 | 24.9 |\n| (B) d_k = 16 | 5.75 | 24.5 |\n| (C) 2 layers | 6.11 | 23.7 |\n| (D) No dropout | 5.77 | 24.6 |\n| (E) Learned positional embeddings | 4.92 | 25.7 |\n\n- Multi-head attention improves performance\n- Dropout is crucial for avoiding overfitting\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. (2014) | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Performs comparably to state-of-the-art parsers\n- Better than RNN models in small-data regimes\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion\n\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution\n- Achieved new state-of-the-art in machine translation:\n - 28.4 BLEU on English-to-German\n - 41.8 BLEU on English-to-French\n- More parallelizable and faster to train\n- Generalizes well to other tasks like constituency parsing\n\n---\n\n## Future Work\n\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "硬性验收失败:你刚才生成了 21 页,必须是 10–20 页。请在不删除三张原论文图、不丢失主要贡献的前提下合并或拆分内容,重新输出完整 slides.md;不得超过 20 页。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n- Proposes **Transformer** - a new network architecture based solely on attention\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- State-of-the-art results:\n - 28.4 BLEU on WMT 2014 English-to-German\n - 41.8 BLEU on WMT 2014 English-to-French\n- Generalizes well to other tasks like English constituency parsing\n\n---\n\n## Background & Key Idea\n\n### Traditional Sequence Models\n- **Recurrent models** (LSTM, GRU): Sequential computation, limited parallelization\n- **Convolutional models**: Limited long-range dependencies\n\n### Attention Mechanism\n- Already used with recurrent networks\n- Allows modeling dependencies without regard to distance\n\n### The Transformer\n- **Key innovation**: Replace recurrence and convolution with self-attention\n- Enables more parallelization and better long-range dependencies\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n*Encoder (left) and Decoder (right) stacks with self-attention and feed-forward layers*\n\n---\n\n## Encoder & Decoder Stacks\n\n### Encoder\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Output dimension: `d_model = 512`\n\n### Decoder\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise feed-forward network\n- Same residual connections and layer normalization\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n### Applications\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder\n2. **Encoder self-attention**: All positions attend to all positions\n3. **Decoder self-attention**: Positions attend to previous positions (masked)\n\n---\n\n## Positional Encoding\n\nSince there's no recurrence/convolution, we add positional information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performed similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Details\n\n### Data & Batching\n- WMT 2014 English-German (4.5M pairs), English-French (36M pairs)\n- Byte-pair encoding with shared vocabulary\n- Batches with ~25,000 source and target tokens\n\n### Hardware & Schedule\n- 8 NVIDIA P100 GPUs\n- Base model: 100,000 steps (12 hours)\n- Big model: 300,000 steps (3.5 days)\n\n### Optimizer & Regularization\n- Adam with $\\beta_1=0.9$, $\\beta_2=0.98$, $\\epsilon=10^{-9}$\n- Learning rate schedule with warmup steps=4000\n- Residual dropout (P_drop=0.1) and label smoothing ($\\epsilon_{ls}=0.1$)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n- 2+ BLEU improvement on English-to-German\n\n---\n\n## Model Architecture Ablations\n\n| Variation | Dev PPL | Dev BLEU |\n|-----------|---------|----------|\n| Base model | 4.92 | 25.8 |\n| (A) 1 attention head | 5.29 | 24.9 |\n| (B) d_k = 16 | 5.75 | 24.5 |\n| (C) 2 layers | 6.11 | 23.7 |\n| (D) No dropout | 5.77 | 24.6 |\n| (E) Learned positional embeddings | 4.92 | 25.7 |\n\n- Multi-head attention improves performance\n- Dropout is crucial for avoiding overfitting\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. (2014) | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Performs comparably to state-of-the-art parsers\n- Better than RNN models in small-data regimes\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion & Future Work\n\n### Contributions\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution\n- Achieved new state-of-the-art in machine translation\n- More parallelizable and faster to train\n- Generalizes well to other tasks\n\n### Future Work\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "审核者(Reviewer)渲染了你上一版 slides.md 的每一页截图,给出如下结构化改进建议(JSON):\n\n{\n \"overall_score\": 65,\n \"pass\": false,\n \"issues\": [\n {\n \"page\": 2,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将要点拆分为2页,例如将State-of-the-art results单独作为一页展示\"\n },\n {\n \"page\": 3,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将三个部分拆分为独立页面,每个部分单独一页详细说明\"\n },\n {\n \"page\": 4,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"放大架构图至占页面2/3空间,删除图片下方的文字说明或将其移至下一页\"\n },\n {\n \"page\": 4,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"删除图片下方的长段文字,仅保留标题和简短说明\"\n },\n {\n \"page\": 5,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Encoder和Decoder分拆为两页,每页单独详细说明其结构\"\n },\n {\n \"page\": 7,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Multi-Head Attention原理和Applications分拆为两页\"\n },\n {\n \"page\": 10,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"high\",\n \"suggestion\": \"将Data & Batching、Hardware & Schedule、Optimizer & Regularization三个部分拆分为3页\"\n },\n {\n \"page\": 14,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"放大注意力可视化图,使其占满页面,确保文字和连线清晰可见\"\n },\n {\n \"page\": 15,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"放大注意力可视化图,增加对比度,确保不同颜色的注意力头可区分\"\n },\n {\n \"page\": 16,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Contributions和Future Work分拆为两页,每部分保留3-4个要点\"\n }\n ]\n}\n\n请理解这些问题并修订 slides.md(可拆页、精简文字、调整图片尺寸等),重新输出完整的 slides.md。修订后仍必须保持 10–20 页;解决拥挤时优先精简与合并,不得用无限拆页规避版面问题。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract: Key Innovation\n\n- Proposes **Transformer** - first network architecture based solely on attention\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- Generalizes well to other tasks beyond machine translation\n\n---\n\n## Abstract: Performance Highlights\n\n- **WMT 2014 English-to-German**: 28.4 BLEU\n - Improves over existing best results by over 2 BLEU\n- **WMT 2014 English-to-French**: 41.8 BLEU\n - New single-model state-of-the-art\n - Trained for 3.5 days on eight GPUs (small fraction of previous costs)\n\n---\n\n## Background: Traditional Sequence Models\n\n### Recurrent Models (LSTM, GRU)\n- Sequential computation inherently limits parallelization\n- Long-range dependencies difficult to learn\n- Computation scales linearly with sequence length\n\n### Convolutional Models\n- Better parallelization but limited receptive field\n- Requires multiple layers to capture long-range dependencies\n- Computational complexity grows with kernel size\n\n---\n\n## Key Idea: The Transformer\n\nReplace recurrence and convolution with **self-attention** to:\n- Enable massive parallelization\n- Capture long-range dependencies directly\n- Reduce training time significantly\n- Maintain or improve model quality\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-96 mx-auto\" />\n\n---\n\n## Architecture Overview\n\n- **Encoder**: Processes input sequence into continuous representation\n- **Decoder**: Generates output sequence based on encoder output\n- Both use stacked self-attention and feed-forward layers\n- Residual connections and layer normalization throughout\n\n---\n\n## Encoder Stack\n\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections around each sub-layer\n- Layer normalization after each sub-layer\n- Output dimension: `d_model = 512`\n\n---\n\n## Decoder Stack\n\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise feed-forward network\n- Same residual connections and layer normalization as encoder\n- Output embeddings offset by one position (auto-regressive property)\n\n---\n\n## Scaled Dot-Product Attention\n\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention with similar performance\n\n---\n\n## Multi-Head Attention\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n---\n\n## Attention Applications\n\n1. **Encoder-decoder attention**: \n - Queries from decoder, keys/values from encoder\n - Enables decoder to attend to all input positions\n\n2. **Encoder self-attention**:\n - All positions attend to all positions in previous encoder layer\n - Captures dependencies within input sequence\n\n3. **Decoder self-attention**:\n - Positions attend to previous positions (masked)\n - Preserves auto-regressive property\n\n---\n\n## Positional Encoding\n\nAdds sequence position information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performs similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Data & Batching\n\n- **Datasets**:\n - WMT 2014 English-German (4.5M sentence pairs)\n - WMT 2014 English-French (36M sentence pairs)\n- **Tokenization**:\n - Byte-pair encoding with shared vocabulary\n - 37,000 tokens (EN-DE), 32,000 tokens (EN-FR)\n- **Batching**:\n - Sentences grouped by approximate length\n - Each batch contains ~25,000 source and target tokens\n\n---\n\n## Training Hardware & Schedule\n\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Base model**:\n - 100,000 training steps\n - ~12 hours total training time\n - 0.4 seconds per step\n- **Big model**:\n - 300,000 training steps\n - ~3.5 days total training time\n - 1.0 seconds per step\n\n---\n\n## Training Optimizer & Regularization\n\n- **Optimizer**: Adam\n - $\\beta_1 = 0.9$, $\\beta_2 = 0.98$, $\\epsilon = 10^{-9}$\n - Learning rate schedule with warmup steps=4000\n\n- **Regularization**:\n - Residual dropout (P_drop = 0.1)\n - Label smoothing ($\\epsilon_{ls} = 0.1$)\n - Dropout on embeddings + positional encodings\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-96 w-full object-contain\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-96 w-full object-contain\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion: Key Contributions\n\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution, enabling better parallelization\n- Achieved new state-of-the-art in machine translation\n- Reduced training time significantly compared to previous approaches\n- Generalized well to other tasks like English constituency parsing\n\n---\n\n## Future Work\n\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n- Extend to larger input/output sequences\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "硬性验收失败:你刚才生成了 22 页,必须是 10–20 页。请在不删除三张原论文图、不丢失主要贡献的前提下合并或拆分内容,重新输出完整 slides.md;不得超过 20 页。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n### Key Innovation\n- First sequence transduction model based **solely on attention**\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable with significantly less training time\n\n### Performance Highlights\n- **WMT 2014 EN-DE**: 28.4 BLEU (+2+ over previous SOTA)\n- **WMT 2014 EN-FR**: 41.8 BLEU (new single-model SOTA)\n- Trained in 3.5 days on 8 GPUs (small fraction of previous costs)\n\n---\n\n## Background & Key Idea\n\n### Traditional Sequence Models\n- **Recurrent (LSTM/GRU)**: Sequential computation limits parallelization\n- **Convolutional**: Requires multiple layers for long-range dependencies\n\n### The Transformer\n- Replaces recurrence/convolution with **self-attention**\n- Enables direct modeling of long-range dependencies\n- Massive parallelization → faster training\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-96 mx-auto\" />\n\n*Encoder (left) and Decoder (right) with self-attention and feed-forward layers*\n\n---\n\n## Encoder & Decoder Stacks\n\n### Encoder (6 identical layers)\n- **Sub-layer 1**: Multi-head self-attention\n- **Sub-layer 2**: Position-wise feed-forward network\n- Residual connections + layer normalization\n- Output dimension: `d_model = 512`\n\n### Decoder (6 identical layers)\n- **Sub-layer 1**: Masked multi-head self-attention (prevents leftward flow)\n- **Sub-layer 2**: Multi-head attention over encoder output\n- **Sub-layer 3**: Position-wise feed-forward network\n- Same residual connections and normalization\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n- Scaling by $\\sqrt{d_k}$ prevents small gradients\n- Efficient with matrix multiplication\n\n### Multi-Head Attention\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1,...,\\text{head}_h)W^O$$\n- $h=8$ parallel heads, $d_k=d_v=64$\n- Captures diverse dependency patterns\n\n---\n\n## Attention Applications\n\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder \n2. **Encoder self-attention**: All positions attend to all input positions \n3. **Decoder self-attention**: Positions attend to previous positions (masked) \n\n---\n\n## Positional Encoding\n\nAdds sequence position information via sinusoidal functions:\n$$\\text{PE}_{(pos,2i)}=\\sin(pos/10000^{2i/d_{\\text{model}}})$$\n$$\\text{PE}_{(pos,2i+1)}=\\cos(pos/10000^{2i/d_{\\text{model}}})$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Enables learning of relative positions\n- Performs similarly to learned embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------------|------------------|----------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs\n- More interpretable attention patterns\n\n---\n\n## Training Setup\n\n### Data & Batching\n- WMT 2014 EN-DE (4.5M pairs), EN-FR (36M pairs)\n- Byte-pair encoding (37K/32K vocab)\n- Batches with ~25K source/target tokens\n\n### Hardware & Schedule\n- 8 NVIDIA P100 GPUs\n- Base model: 100K steps (12h), Big model: 300K steps (3.5d)\n\n### Optimization\n- Adam ($\\beta_1=0.9$, $\\beta_2=0.98$), learning rate warmup\n- Dropout (0.1), label smoothing (0.1)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|----------------------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)**| **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$**|\n\n- Outperforms all previous SOTA with lower training cost\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-96 w-full object-contain\" />\n\n*Encoder self-attention (layer 5) tracking \"making...more difficult\" dependency*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-96 w-full object-contain\" />\n\n*Attention heads resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion & Future Work\n\n### Key Contributions\n- Introduced Transformer, first attention-only transduction model\n- Eliminated recurrence/convolution → better parallelization\n- Set new SOTA in machine translation with lower training cost\n- Generalizes to other tasks (e.g., constituency parsing)\n\n### Future Work\n- Apply to other modalities (images, audio)\n- Explore local attention for large sequences\n- Improve generation sequentiality\n- Enhance attention interpretability\n\n**Code:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "审核者(Reviewer)渲染了你上一版 slides.md 的每一页截图,给出如下结构化改进建议(JSON):\n\n{\n \"overall_score\": 75,\n \"pass\": false,\n \"issues\": [\n {\n \"page\": 4,\n \"issue_type\": \"image_size\",\n \"severity\": \"medium\",\n \"suggestion\": \"放大Transformer架构图,确保图中模块名称和连接关系清晰可见\"\n },\n {\n \"page\": 4,\n \"issue_type\": \"readability\",\n \"severity\": \"medium\",\n \"suggestion\": \"移除图片下方的长段文字说明,仅保留简洁标题或关键标注\"\n },\n {\n \"page\": 5,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Encoder和Decoder内容拆分到两页,每页不超过4个要点\"\n },\n {\n \"page\": 10,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Training Setup的三个部分拆分到单独页面,每个部分保留2-3个要点\"\n },\n {\n \"page\": 12,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"大幅放大注意力可视化图,确保文字标签和连接线清晰可辨\"\n },\n {\n \"page\": 12,\n \"issue_type\": \"readability\",\n \"severity\": \"high\",\n \"suggestion\": \"移除图片下方的详细说明文字,仅保留标题和简短解释\"\n },\n {\n \"page\": 13,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"大幅放大指代消解可视化图,确保文字和注意力权重分布清晰可见\"\n },\n {\n \"page\": 13,\n \"issue_type\": \"readability\",\n \"severity\": \"high\",\n \"suggestion\": \"移除图片下方的说明文字,改用简洁标题突出核心发现\"\n },\n {\n \"page\": 14,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Key Contributions和Future Work拆分到两页,每部分保留3-4个要点\"\n }\n ]\n}\n\n请理解这些问题并修订 slides.md(可拆页、精简文字、调整图片尺寸等),重新输出完整的 slides.md。修订后仍必须保持 10–20 页;解决拥挤时优先精简与合并,不得用无限拆页规避版面问题。"
}
],
"temperature": 0.3
},
"response": {
"id": "021785385196967ffa263910bfaab0198f27d0234753c49206363",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n### Key Innovation\n- First sequence transduction model based **solely on attention**\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable with significantly less training time\n\n### Performance Highlights\n- **WMT 2014 EN-DE**: 28.4 BLEU (+2+ over previous SOTA)\n- **WMT 2014 EN-FR**: 41.8 BLEU (new single-model SOTA)\n- Trained in 3.5 days on 8 GPUs (small fraction of previous costs)\n\n---\n\n## Background & Key Idea\n\n### Traditional Sequence Models\n- **Recurrent (LSTM/GRU)**: Sequential computation limits parallelization\n- **Convolutional**: Requires multiple layers for long-range dependencies\n\n### The Transformer\n- Replaces recurrence/convolution with **self-attention**\n- Enables direct modeling of long-range dependencies\n- Massive parallelization → faster training\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-[600px] w-full object-contain\" />\n\n---\n\n## Encoder Stack\n\n- **6 identical layers** with two sub-layers:\n 1. Multi-head self-attention mechanism\n 2. Position-wise feed-forward network\n- Residual connections around each sub-layer\n- Layer normalization after each sub-layer\n- Output dimension: `d_model = 512`\n\n---\n\n## Decoder Stack\n\n- **6 identical layers** with three sub-layers:\n 1. Masked multi-head self-attention (prevents leftward flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise feed-forward network\n- Same residual connections and normalization as encoder\n- Output embeddings offset by one position (auto-regressive property)\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n- Scaling by $\\sqrt{d_k}$ prevents small gradients\n- Efficient with matrix multiplication\n\n### Multi-Head Attention\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1,...,\\text{head}_h)W^O$$\n- $h=8$ parallel heads, $d_k=d_v=64$\n- Captures diverse dependency patterns\n\n---\n\n## Attention Applications\n\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder \n2. **Encoder self-attention**: All positions attend to all input positions \n3. **Decoder self-attention**: Positions attend to previous positions (masked) \n\n---\n\n## Positional Encoding\n\nAdds sequence position information via sinusoidal functions:\n$$\\text{PE}_{(pos,2i)}=\\sin(pos/10000^{2i/d_{\\text{model}}})$$\n$$\\text{PE}_{(pos,2i+1)}=\\cos(pos/10000^{2i/d_{\\text{model}}})$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Enables learning of relative positions\n- Performs similarly to learned embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------------|------------------|----------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs\n- More interpretable attention patterns\n\n---\n\n## Training Data & Batching\n\n- **Datasets**:\n - WMT 2014 EN-DE (4.5M sentence pairs)\n - WMT 2014 EN-FR (36M sentence pairs)\n- **Tokenization**:\n - Byte-pair encoding with shared vocabulary\n - 37K tokens (EN-DE), 32K tokens (EN-FR)\n- **Batching**:\n - Sentences grouped by approximate length\n - Each batch contains ~25K source and target tokens\n\n---\n\n## Training Hardware & Schedule\n\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Base model**:\n - 100,000 training steps\n - ~12 hours total training time\n- **Big model**:\n - 300,000 training steps\n - ~3.5 days total training time\n\n---\n\n## Training Optimization\n\n- **Optimizer**: Adam\n - $\\beta_1 = 0.9$, $\\beta_2 = 0.98$, $\\epsilon = 10^{-9}$\n - Learning rate schedule with warmup steps=4000\n\n- **Regularization**:\n - Residual dropout (P_drop = 0.1)\n - Label smoothing ($\\epsilon_{ls} = 0.1$)\n - Dropout on embeddings + positional encodings\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|----------------------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)**| **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$**|\n\n- Outperforms all previous SOTA with lower training cost\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-[600px] w-full object-contain\" />\n\n*Tracking \"making...more difficult\" dependency across distant positions*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-[600px] w-full object-contain\" />\n\n*Resolving \"its\" to antecedent \"The Law\"*\n\n---\n\n## Key Contributions\n\n- Introduced Transformer, first attention-only transduction model\n- Eliminated recurrence/convolution → better parallelization\n- Set new SOTA in machine translation with lower training cost\n- Generalizes to other tasks (e.g., constituency parsing)\n\n---\n\n## Future Work\n\n- Apply to other modalities (images, audio, video)\n- Explore local attention for large sequences\n- Improve generation sequentiality\n- Enhance attention interpretability\n\n**Code:** https://github.com/tensorflow/tensor2tensor\n```"
},
"usage": {
"prompt_tokens": 20995,
"completion_tokens": 2466,
"total_tokens": 23461,
"cached_prompt_tokens": 0
}
},
{
"meter": "Reviewer(每轮只看最新截图)",
"called_at_utc": "2026-07-30T04:21:40.286305+00:00",
"latency_s": 32.898,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名严格的演示文稿质量审核员(Reviewer)。你会看到一份由 Slidev 渲染出的 PPT,\n每张图对应一页幻灯片(按顺序编号,从第 1 页开始)。请逐页检查以下问题:\n\n- text_overflow(文字溢出/被裁切超出页面边界)\n- overcrowded(内容过多/过于拥挤/留白不足)\n- image_size(图片过大顶出布局,或过小看不清)\n- readability(字号过小、对比度差、代码块难读)\n- layout(对齐混乱、标题与正文比例失衡、空页)\n\n请以**目标用户是听众**的严格标准审查——一页幻灯片若要点超过约 5 条、或正文文字块偏长、\n或图片挤压了文字空间,都应视为 overcrowded/image_size 问题。报告真实存在的问题,\n但不要放过\"塞得太满\"。对每个问题给出:page(页码,整数)、\nissue_type(上面之一)、severityhigh/medium/low)、suggestion(具体、可执行的修改建议,中文)。\n\n同时给出:\n- overall_score0-100 的整体质量分(越高越好)\n- pass:布尔值,仅当整份 PPT **既无 high 也无 medium 级问题**、排版干净可读时才为 true\n\n严格输出如下 JSON(不要输出任何多余文字):\n{\n \"overall_score\": <int>,\n \"pass\": <bool>,\n \"issues\": [\n {\"page\": <int>, \"issue_type\": \"<type>\", \"severity\": \"<high|medium|low>\", \"suggestion\": \"<中文建议>\"}\n ]\n}"
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "这份 PPT 共 18 页,下面按页码顺序给出每一页的渲染截图。请审查。"
},
{
"type": "text",
"text": "第 1 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9d3c8d02979b8658be4dc98b1b914e4daf9ca6900e251a9c0d0c1225010ef208",
"characters": 61854,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 2 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "de1f8ac9c290fde8072ab2baecfa5117d5af3ea0743524d27fcfa0f67dce0dc6",
"characters": 155138,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 3 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "ecea27fcb38014d7a201537d7d34270862de36349682a3fc0b16cdc95011cb1d",
"characters": 146042,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 4 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "7f0a9adb6003279433fbe0b678d32a00d1b18aa53a64ad7b410a82854daa1745",
"characters": 134138,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 5 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "f21c0de2d76609a1c98769e6b8466011a7157092b26879a647939982c93a0324",
"characters": 100734,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 6 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "929555f1f5c7a6c5d2e366eb2e496aa9ba70e2dbac7939382d744b9f9d50ad72",
"characters": 124658,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 7 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "4b02c8b2a4836e2e41aae9da9fa42e508036588f448c593b90866e5260bb8a01",
"characters": 153882,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 8 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "8f7b1212ac4fad081fab53248710959a3a24cef8ccfb3f6c18533c6f9550b56d",
"characters": 96398,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 9 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "4702cb3592a561b59911bafde53e5c8b0e163d85c2a3efc5049bce46486e719b",
"characters": 120354,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 10 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "317afc56617303886072156d70c7f40b2c08f1a10b2545af504f8c656dcf3dfa",
"characters": 131406,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 11 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9dc07ae2ad962c2c8a73f13bf8f1655551b104c0a37211a57c993d9c46965ede",
"characters": 136050,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 12 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "71e1693b042f6020b01b0523b775ba04782749444679354ec89a44c3bfd9ca92",
"characters": 92510,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 13 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "bd8143c387ff06c4782826a81b077a3c3cefb1aeb08816bca0160a527f8e7e68",
"characters": 105534,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 14 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "3ea3f5d33395f0e164166778184da3b27a9b4eae27c21615de85d0dd015b2e43",
"characters": 110602,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 15 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "3941596c28c3c3bf92d5edb9a455a8782241a1c436b97bfebbc197a862da68d0",
"characters": 272750,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 16 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9d96bf60e05ef420ed392d9802c64327b22e7d6c55751fe224cbad1cd1e11fec",
"characters": 261346,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 17 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "2b06e06e39d8d79187144dd3480800259dba1dd1de79efdc40c43d68b19ad6e9",
"characters": 101706,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 18 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "00cb22fea345052aded272d9f8636e2fa27935367e3e1b5a701f96d2719fcdc5",
"characters": 95498,
"media_type": "image/png"
},
"detail": "high"
}
}
]
}
],
"temperature": 0.2
},
"response": {
"id": "021785385267637cb43b51ad7a6f2b3d703638489b11c03c19f3d",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "{\n \"overall_score\": 85,\n \"pass\": false,\n \"issues\": [\n {\"page\": 2, \"issue_type\": \"overcrowded\", \"severity\": \"medium\", \"suggestion\": \"将6个要点拆分为2页,Key Innovation和Performance Highlights各占一页,或删减次要信息使每页不超过5个要点\"},\n {\"page\": 11, \"issue_type\": \"overcrowded\", \"severity\": \"medium\", \"suggestion\": \"将6个子要点拆分为2页,例如将Datasets和Tokenization作为一页,Batching单独作为一页\"},\n {\"page\": 15, \"issue_type\": \"readability\", \"severity\": \"medium\", \"suggestion\": \"放大可视化图中的文字,或截取局部放大展示关键区域,确保观众能看清注意力模式和词语对应关系\"},\n {\"page\": 16, \"issue_type\": \"readability\", \"severity\": \"medium\", \"suggestion\": \"放大可视化图中的文字,或选择更清晰的可视化案例,确保代词解析的注意力关系清晰可见\"}\n ]\n}"
},
"usage": {
"prompt_tokens": 21794,
"completion_tokens": 1513,
"total_tokens": 23307,
"cached_prompt_tokens": 0
}
},
{
"meter": "Proposer(纯文本)",
"called_at_utc": "2026-07-30T04:22:20.315952+00:00",
"latency_s": 40.02,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名擅长把学术论文转化为演示文稿的 Proposer Agent。\n你用 Slidev 框架(Markdown + HTML)编写 PPT 源码 slides.md。\n\nSlidev 语法要点:\n- 文件开头是 YAML frontmatter--- 包裹),设置 theme: default。\n- 用单独一行的 `---`(前后空行)分隔每一页幻灯片。\n- 首页通常放标题、作者、会议。\n- 引用图片用 markdown![说明](/图片文件名.png),可用 HTML 控制尺寸,\n 例如 <img src=\"/speedup_bar.png\" class=\"h-60 mx-auto\" />。\n- 可用 Windi/Uno CSS 工具类控制排版(如 text-sm、grid grid-cols-2 gap-4)。\n\n要求:\n- 最终生成 10-20 页,覆盖论文的标题、背景/动机、方法、实验结果、局限与结论。\n- 至少在 3 页中使用提供的图表/表格,且图文匹配。\n- 每页信息量适中、不要塞太多字,宁可拆页也不要溢出。\n- 只输出 slides.md 的完整内容,用 ```markdown 代码块包裹,不要额外解释。"
},
{
"role": "user",
"content": "以下是论文全文(Markdown):\n\n# Attention Is All You Need\n\nAuthors: Ashish Vaswani et al.\n\n\n## PDF page 1\n\nProvided proper attribution is provided, Google hereby grants permission to\nreproduce the tables and figures in this paper solely for use in journalistic or\nscholarly works.\nAttention Is All You Need\nAshish Vaswani\nGoogle Brain\navaswani@google.com\nNoam Shazeer\nGoogle Brain\nnoam@google.com\nNiki Parmar\nGoogle Research\nnikip@google.com\nJakob Uszkoreit\nGoogle Research\nusz@google.com\nLlion Jones\nGoogle Research\nllion@google.com\nAidan N. Gomez∗†\nUniversity of Toronto\naidan@cs.toronto.edu\nŁukasz Kaiser\nGoogle Brain\nlukaszkaiser@google.com\nIllia Polosukhin∗‡\nillia.polosukhin@gmail.com\nAbstract\nThe dominant sequence transduction models are based on complex recurrent or\nconvolutional neural networks that include an encoder and a decoder. The best\nperforming models also connect the encoder and decoder through an attention\nmechanism. We propose a new simple network architecture, the Transformer,\nbased solely on attention mechanisms, dispensing with recurrence and convolutions\nentirely. Experiments on two machine translation tasks show these models to\nbe superior in quality while being more parallelizable and requiring significantly\nless time to train. Our model achieves 28.4 BLEU on the WMT 2014 English-\nto-German translation task, improving over the existing best results, including\nensembles, by over 2 BLEU. On the WMT 2014 English-to-French translation task,\nour model establishes a new single-model state-of-the-art BLEU score of 41.8 after\ntraining for 3.5 days on eight GPUs, a small fraction of the training costs of the\nbest models from the literature. We show that the Transformer generalizes well to\nother tasks by applying it successfully to English constituency parsing both with\nlarge and limited training data.\nEqual contribution. Listing order is random. Jakob proposed replacing RNNs with self-attention and started\nthe effort to evaluate this idea. Ashish, with Illia, designed and implemented the first Transformer models and\nhas been crucially involved in every aspect of this work. Noam proposed scaled dot-product attention, multi-head\nattention and the parameter-free position representation and became the other person involved in nearly every\ndetail. Niki designed, implemented, tuned and evaluated countless model variants in our original codebase and\ntensor2tensor. Llion also experimented with novel model variants, was responsible for our initial codebase, and\nefficient inference and visualizations. Lukasz and Aidan spent countless long days designing various parts of and\nimplementing tensor2tensor, replacing our earlier codebase, greatly improving results and massively accelerating\nour research.\n†Work performed while at Google Brain.\n‡Work performed while at Google Research.\n31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA.\narXiv:1706.03762v7 [cs.CL] 2 Aug 2023\n\n\n## PDF page 2\n\n1\nIntroduction\nRecurrent neural networks, long short-term memory [13] and gated recurrent [7] neural networks\nin particular, have been firmly established as state of the art approaches in sequence modeling and\ntransduction problems such as language modeling and machine translation [35, 2, 5]. Numerous\nefforts have since continued to push the boundaries of recurrent language models and encoder-decoder\narchitectures [38, 24, 15].\nRecurrent models typically factor computation along the symbol positions of the input and output\nsequences. Aligning the positions to steps in computation time, they generate a sequence of hidden\nstates ht, as a function of the previous hidden state ht1 and the input for position t. This inherently\nsequential nature precludes parallelization within training examples, which becomes critical at longer\nsequence lengths, as memory constraints limit batching across examples. Recent work has achieved\nsignificant improvements in computational efficiency through factorization tricks [21] and conditional\ncomputation [32], while also improving model performance in case of the latter. The fundamental\nconstraint of sequential computation, however, remains.\nAttention mechanisms have become an integral part of compelling sequence modeling and transduc-\ntion models in various tasks, allowing modeling of dependencies without regard to their distance in\nthe input or output sequences [2, 19]. In all but a few cases [27], however, such attention mechanisms\nare used in conjunction with a recurrent network.\nIn this work we propose the Transformer, a model architecture eschewing recurrence and instead\nrelying entirely on an attention mechanism to draw global dependencies between input and output.\nThe Transformer allows for significantly more parallelization and can reach a new state of the art in\ntranslation quality after being trained for as little as twelve hours on eight P100 GPUs.\n2\nBackground\nThe goal of reducing sequential computation also forms the foundation of the Extended Neural GPU\n[16], ByteNet [18] and ConvS2S [9], all of which use convolutional neural networks as basic building\nblock, computing hidden representations in parallel for all input and output positions. In these models,\nthe number of operations required to relate signals from two arbitrary input or output positions grows\nin the distance between positions, linearly for ConvS2S and logarithmically for ByteNet. This makes\nit more difficult to learn dependencies between distant positions [12]. In the Transformer this is\nreduced to a constant number of operations, albeit at the cost of reduced effective resolution due\nto averaging attention-weighted positions, an effect we counteract with Multi-Head Attention as\ndescribed in section 3.2.\nSelf-attention, sometimes called intra-attention is an attention mechanism relating different positions\nof a single sequence in order to compute a representation of the sequence. Self-attention has been\nused successfully in a variety of tasks including reading comprehension, abstractive summarization,\ntextual entailment and learning task-independent sentence representations [4, 27, 28, 22].\nEnd-to-end memory networks are based on a recurrent attention mechanism instead of sequence-\naligned recurrence and have been shown to perform well on simple-language question answering and\nlanguage modeling tasks [34].\nTo the best of our knowledge, however, the Transformer is the first transduction model relying\nentirely on self-attention to compute representations of its input and output without using sequence-\naligned RNNs or convolution. In the following sections, we will describe the Transformer, motivate\nself-attention and discuss its advantages over models such as [17, 18] and [9].\n3\nModel Architecture\nMost competitive neural sequence transduction models have an encoder-decoder structure [5, 2, 35].\nHere, the encoder maps an input sequence of symbol representations (x1, ..., xn) to a sequence\nof continuous representations z = (z1, ..., zn). Given z, the decoder then generates an output\nsequence (y1, ..., ym) of symbols one element at a time. At each step the model is auto-regressive\n[10], consuming the previously generated symbols as additional input when generating the next.\n2\n\n\n## PDF page 3\n\nFigure 1: The Transformer - model architecture.\nThe Transformer follows this overall architecture using stacked self-attention and point-wise, fully\nconnected layers for both the encoder and decoder, shown in the left and right halves of Figure 1,\nrespectively.\n3.1\nEncoder and Decoder Stacks\nEncoder:\nThe encoder is composed of a stack of N = 6 identical layers. Each layer has two\nsub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, position-\nwise fully connected feed-forward network. We employ a residual connection [11] around each of\nthe two sub-layers, followed by layer normalization [1]. That is, the output of each sub-layer is\nLayerNorm(x + Sublayer(x)), where Sublayer(x) is the function implemented by the sub-layer\nitself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding\nlayers, produce outputs of dimension dmodel = 512.\nDecoder:\nThe decoder is also composed of a stack of N = 6 identical layers. In addition to the two\nsub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head\nattention over the output of the encoder stack. Similar to the encoder, we employ residual connections\naround each of the sub-layers, followed by layer normalization. We also modify the self-attention\nsub-layer in the decoder stack to prevent positions from attending to subsequent positions. This\nmasking, combined with fact that the output embeddings are offset by one position, ensures that the\npredictions for position i can depend only on the known outputs at positions less than i.\n3.2\nAttention\nAn attention function can be described as mapping a query and a set of key-value pairs to an output,\nwhere the query, keys, values, and output are all vectors. The output is computed as a weighted sum\n3\n\n\n## PDF page 4\n\nScaled Dot-Product Attention\nMulti-Head Attention\nFigure 2: (left) Scaled Dot-Product Attention. (right) Multi-Head Attention consists of several\nattention layers running in parallel.\nof the values, where the weight assigned to each value is computed by a compatibility function of the\nquery with the corresponding key.\n3.2.1\nScaled Dot-Product Attention\nWe call our particular attention \"Scaled Dot-Product Attention\" (Figure 2). The input consists of\nqueries and keys of dimension dk, and values of dimension dv. We compute the dot products of the\nquery with all keys, divide each by √dk, and apply a softmax function to obtain the weights on the\nvalues.\nIn practice, we compute the attention function on a set of queries simultaneously, packed together\ninto a matrix Q. The keys and values are also packed together into matrices K and V . We compute\nthe matrix of outputs as:\nAttention(Q, K, V ) = softmax(QKT\n√dk\n)V\n(1)\nThe two most commonly used attention functions are additive attention [2], and dot-product (multi-\nplicative) attention. Dot-product attention is identical to our algorithm, except for the scaling factor\nof\n1\n√dk . Additive attention computes the compatibility function using a feed-forward network with\na single hidden layer. While the two are similar in theoretical complexity, dot-product attention is\nmuch faster and more space-efficient in practice, since it can be implemented using highly optimized\nmatrix multiplication code.\nWhile for small values of dk the two mechanisms perform similarly, additive attention outperforms\ndot product attention without scaling for larger values of dk [3]. We suspect that for large values of\ndk, the dot products grow large in magnitude, pushing the softmax function into regions where it has\nextremely small gradients 4. To counteract this effect, we scale the dot products by\n1\n√dk .\n3.2.2\nMulti-Head Attention\nInstead of performing a single attention function with dmodel-dimensional keys, values and queries,\nwe found it beneficial to linearly project the queries, keys and values h times with different, learned\nlinear projections to dk, dk and dv dimensions, respectively. On each of these projected versions of\nqueries, keys and values we then perform the attention function in parallel, yielding dv-dimensional\n4To illustrate why the dot products get large, assume that the components of q and k are independent random\nvariables with mean 0 and variance 1. Then their dot product, q · k = Pdk\ni=1 qiki, has mean 0 and variance dk.\n4\n\n\n## PDF page 5\n\noutput values. These are concatenated and once again projected, resulting in the final values, as\ndepicted in Figure 2.\nMulti-head attention allows the model to jointly attend to information from different representation\nsubspaces at different positions. With a single attention head, averaging inhibits this.\nMultiHead(Q, K, V ) = Concat(head1, ..., headh)W O\nwhere headi = Attention(QW Q\ni , KW K\ni , V W V\ni )\nWhere the projections are parameter matrices W Q\ni\n∈Rdmodel×dk, W K\ni\n∈Rdmodel×dk, W V\ni\n∈Rdmodel×dv\nand W O ∈Rhdv×dmodel.\nIn this work we employ h = 8 parallel attention layers, or heads. For each of these we use\ndk = dv = dmodel/h = 64. Due to the reduced dimension of each head, the total computational cost\nis similar to that of single-head attention with full dimensionality.\n3.2.3\nApplications of Attention in our Model\nThe Transformer uses multi-head attention in three different ways:\n• In \"encoder-decoder attention\" layers, the queries come from the previous decoder layer,\nand the memory keys and values come from the output of the encoder. This allows every\nposition in the decoder to attend over all positions in the input sequence. This mimics the\ntypical encoder-decoder attention mechanisms in sequence-to-sequence models such as\n[38, 2, 9].\n• The encoder contains self-attention layers. In a self-attention layer all of the keys, values\nand queries come from the same place, in this case, the output of the previous layer in the\nencoder. Each position in the encoder can attend to all positions in the previous layer of the\nencoder.\n• Similarly, self-attention layers in the decoder allow each position in the decoder to attend to\nall positions in the decoder up to and including that position. We need to prevent leftward\ninformation flow in the decoder to preserve the auto-regressive property. We implement this\ninside of scaled dot-product attention by masking out (setting to −∞) all values in the input\nof the softmax which correspond to illegal connections. See Figure 2.\n3.3\nPosition-wise Feed-Forward Networks\nIn addition to attention sub-layers, each of the layers in our encoder and decoder contains a fully\nconnected feed-forward network, which is applied to each position separately and identically. This\nconsists of two linear transformations with a ReLU activation in between.\nFFN(x) = max(0, xW1 + b1)W2 + b2\n(2)\nWhile the linear transformations are the same across different positions, they use different parameters\nfrom layer to layer. Another way of describing this is as two convolutions with kernel size 1.\nThe dimensionality of input and output is dmodel = 512, and the inner-layer has dimensionality\ndff = 2048.\n3.4\nEmbeddings and Softmax\nSimilarly to other sequence transduction models, we use learned embeddings to convert the input\ntokens and output tokens to vectors of dimension dmodel. We also use the usual learned linear transfor-\nmation and softmax function to convert the decoder output to predicted next-token probabilities. In\nour model, we share the same weight matrix between the two embedding layers and the pre-softmax\nlinear transformation, similar to [30]. In the embedding layers, we multiply those weights by √dmodel.\n5\n\n\n## PDF page 6\n\nTable 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations\nfor different layer types. n is the sequence length, d is the representation dimension, k is the kernel\nsize of convolutions and r the size of the neighborhood in restricted self-attention.\nLayer Type\nComplexity per Layer\nSequential\nMaximum Path Length\nOperations\nSelf-Attention\nO(n2 · d)\nO(1)\nO(1)\nRecurrent\nO(n · d2)\nO(n)\nO(n)\nConvolutional\nO(k · n · d2)\nO(1)\nO(logk(n))\nSelf-Attention (restricted)\nO(r · n · d)\nO(1)\nO(n/r)\n3.5\nPositional Encoding\nSince our model contains no recurrence and no convolution, in order for the model to make use of the\norder of the sequence, we must inject some information about the relative or absolute position of the\ntokens in the sequence. To this end, we add \"positional encodings\" to the input embeddings at the\nbottoms of the encoder and decoder stacks. The positional encodings have the same dimension dmodel\nas the embeddings, so that the two can be summed. There are many choices of positional encodings,\nlearned and fixed [9].\nIn this work, we use sine and cosine functions of different frequencies:\nPE(pos,2i) = sin(pos/100002i/dmodel)\nPE(pos,2i+1) = cos(pos/100002i/dmodel)\nwhere pos is the position and i is the dimension. That is, each dimension of the positional encoding\ncorresponds to a sinusoid. The wavelengths form a geometric progression from 2π to 10000 · 2π. We\nchose this function because we hypothesized it would allow the model to easily learn to attend by\nrelative positions, since for any fixed offset k, PEpos+k can be represented as a linear function of\nPEpos.\nWe also experimented with using learned positional embeddings [9] instead, and found that the two\nversions produced nearly identical results (see Table 3 row (E)). We chose the sinusoidal version\nbecause it may allow the model to extrapolate to sequence lengths longer than the ones encountered\nduring training.\n4\nWhy Self-Attention\nIn this section we compare various aspects of self-attention layers to the recurrent and convolu-\ntional layers commonly used for mapping one variable-length sequence of symbol representations\n(x1, ..., xn) to another sequence of equal length (z1, ..., zn), with xi, zi ∈Rd, such as a hidden\nlayer in a typical sequence transduction encoder or decoder. Motivating our use of self-attention we\nconsider three desiderata.\nOne is the total computational complexity per layer. Another is the amount of computation that can\nbe parallelized, as measured by the minimum number of sequential operations required.\nThe third is the path length between long-range dependencies in the network. Learning long-range\ndependencies is a key challenge in many sequence transduction tasks. One key factor affecting the\nability to learn such dependencies is the length of the paths forward and backward signals have to\ntraverse in the network. The shorter these paths between any combination of positions in the input\nand output sequences, the easier it is to learn long-range dependencies [12]. Hence we also compare\nthe maximum path length between any two input and output positions in networks composed of the\ndifferent layer types.\nAs noted in Table 1, a self-attention layer connects all positions with a constant number of sequentially\nexecuted operations, whereas a recurrent layer requires O(n) sequential operations. In terms of\ncomputational complexity, self-attention layers are faster than recurrent layers when the sequence\n6\n\n\n## PDF page 7\n\nlength n is smaller than the representation dimensionality d, which is most often the case with\nsentence representations used by state-of-the-art models in machine translations, such as word-piece\n[38] and byte-pair [31] representations. To improve computational performance for tasks involving\nvery long sequences, self-attention could be restricted to considering only a neighborhood of size r in\nthe input sequence centered around the respective output position. This would increase the maximum\npath length to O(n/r). We plan to investigate this approach further in future work.\nA single convolutional layer with kernel width k < n does not connect all pairs of input and output\npositions. Doing so requires a stack of O(n/k) convolutional layers in the case of contiguous kernels,\nor O(logk(n)) in the case of dilated convolutions [18], increasing the length of the longest paths\nbetween any two positions in the network. Convolutional layers are generally more expensive than\nrecurrent layers, by a factor of k. Separable convolutions [6], however, decrease the complexity\nconsiderably, to O(k · n · d + n · d2). Even with k = n, however, the complexity of a separable\nconvolution is equal to the combination of a self-attention layer and a point-wise feed-forward layer,\nthe approach we take in our model.\nAs side benefit, self-attention could yield more interpretable models. We inspect attention distributions\nfrom our models and present and discuss examples in the appendix. Not only do individual attention\nheads clearly learn to perform different tasks, many appear to exhibit behavior related to the syntactic\nand semantic structure of the sentences.\n5\nTraining\nThis section describes the training regime for our models.\n5.1\nTraining Data and Batching\nWe trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million\nsentence pairs. Sentences were encoded using byte-pair encoding [3], which has a shared source-\ntarget vocabulary of about 37000 tokens. For English-French, we used the significantly larger WMT\n2014 English-French dataset consisting of 36M sentences and split tokens into a 32000 word-piece\nvocabulary [38]. Sentence pairs were batched together by approximate sequence length. Each training\nbatch contained a set of sentence pairs containing approximately 25000 source tokens and 25000\ntarget tokens.\n5.2\nHardware and Schedule\nWe trained our models on one machine with 8 NVIDIA P100 GPUs. For our base models using\nthe hyperparameters described throughout the paper, each training step took about 0.4 seconds. We\ntrained the base models for a total of 100,000 steps or 12 hours. For our big models,(described on the\nbottom line of table 3), step time was 1.0 seconds. The big models were trained for 300,000 steps\n(3.5 days).\n5.3\nOptimizer\nWe used the Adam optimizer [20] with β1 = 0.9, β2 = 0.98 and ϵ = 109. We varied the learning\nrate over the course of training, according to the formula:\nlrate = d0.5\nmodel · min(step_num0.5, step_num · warmup_steps1.5)\n(3)\nThis corresponds to increasing the learning rate linearly for the first warmup_steps training steps,\nand decreasing it thereafter proportionally to the inverse square root of the step number. We used\nwarmup_steps = 4000.\n5.4\nRegularization\nWe employ three types of regularization during training:\n7\n\n\n## PDF page 8\n\nTable 2: The Transformer achieves better BLEU scores than previous state-of-the-art models on the\nEnglish-to-German and English-to-French newstest2014 tests at a fraction of the training cost.\nModel\nBLEU\nTraining Cost (FLOPs)\nEN-DE\nEN-FR\nEN-DE\nEN-FR\nByteNet [18]\n23.75\nDeep-Att + PosUnk [39]\n39.2\n1.0 · 1020\nGNMT + RL [38]\n24.6\n39.92\n2.3 · 1019\n1.4 · 1020\nConvS2S [9]\n25.16\n40.46\n9.6 · 1018\n1.5 · 1020\nMoE [32]\n26.03\n40.56\n2.0 · 1019\n1.2 · 1020\nDeep-Att + PosUnk Ensemble [39]\n40.4\n8.0 · 1020\nGNMT + RL Ensemble [38]\n26.30\n41.16\n1.8 · 1020\n1.1 · 1021\nConvS2S Ensemble [9]\n26.36\n41.29\n7.7 · 1019\n1.2 · 1021\nTransformer (base model)\n27.3\n38.1\n3.3 · 1018\nTransformer (big)\n28.4\n41.8\n2.3 · 1019\nResidual Dropout\nWe apply dropout [33] to the output of each sub-layer, before it is added to the\nsub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the\npositional encodings in both the encoder and decoder stacks. For the base model, we use a rate of\nPdrop = 0.1.\nLabel Smoothing\nDuring training, we employed label smoothing of value ϵls = 0.1 [36]. This\nhurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.\n6\nResults\n6.1\nMachine Translation\nOn the WMT 2014 English-to-German translation task, the big transformer model (Transformer (big)\nin Table 2) outperforms the best previously reported models (including ensembles) by more than 2.0\nBLEU, establishing a new state-of-the-art BLEU score of 28.4. The configuration of this model is\nlisted in the bottom line of Table 3. Training took 3.5 days on 8 P100 GPUs. Even our base model\nsurpasses all previously published models and ensembles, at a fraction of the training cost of any of\nthe competitive models.\nOn the WMT 2014 English-to-French translation task, our big model achieves a BLEU score of 41.0,\noutperforming all of the previously published single models, at less than 1/4 the training cost of the\nprevious state-of-the-art model. The Transformer (big) model trained for English-to-French used\ndropout rate Pdrop = 0.1, instead of 0.3.\nFor the base models, we used a single model obtained by averaging the last 5 checkpoints, which\nwere written at 10-minute intervals. For the big models, we averaged the last 20 checkpoints. We\nused beam search with a beam size of 4 and length penalty α = 0.6 [38]. These hyperparameters\nwere chosen after experimentation on the development set. We set the maximum output length during\ninference to input length + 50, but terminate early when possible [38].\nTable 2 summarizes our results and compares our translation quality and training costs to other model\narchitectures from the literature. We estimate the number of floating point operations used to train a\nmodel by multiplying the training time, the number of GPUs used, and an estimate of the sustained\nsingle-precision floating-point capacity of each GPU 5.\n6.2\nModel Variations\nTo evaluate the importance of different components of the Transformer, we varied our base model\nin different ways, measuring the change in performance on English-to-German translation on the\n5We used values of 2.8, 3.7, 6.0 and 9.5 TFLOPS for K80, K40, M40 and P100, respectively.\n8\n\n\n## PDF page 9\n\nTable 3: Variations on the Transformer architecture. Unlisted values are identical to those of the base\nmodel. All metrics are on the English-to-German translation development set, newstest2013. Listed\nperplexities are per-wordpiece, according to our byte-pair encoding, and should not be compared to\nper-word perplexities.\nN\ndmodel\ndff\nh\ndk\ndv\nPdrop\nϵls\ntrain\nPPL\nBLEU\nparams\nsteps\n(dev)\n(dev)\n×106\nbase\n6\n512\n2048\n8\n64\n64\n0.1\n0.1\n100K\n4.92\n25.8\n65\n(A)\n1\n512\n512\n5.29\n24.9\n4\n128\n128\n5.00\n25.5\n16\n32\n32\n4.91\n25.8\n32\n16\n16\n5.01\n25.4\n(B)\n16\n5.16\n25.1\n58\n32\n5.01\n25.4\n60\n(C)\n2\n6.11\n23.7\n36\n4\n5.19\n25.3\n50\n8\n4.88\n25.5\n80\n256\n32\n32\n5.75\n24.5\n28\n1024\n128\n128\n4.66\n26.0\n168\n1024\n5.12\n25.4\n53\n4096\n4.75\n26.2\n90\n(D)\n0.0\n5.77\n24.6\n0.2\n4.95\n25.5\n0.0\n4.67\n25.3\n0.2\n5.47\n25.7\n(E)\npositional embedding instead of sinusoids\n4.92\n25.7\nbig\n6\n1024\n4096\n16\n0.3\n300K\n4.33\n26.4\n213\ndevelopment set, newstest2013. We used beam search as described in the previous section, but no\ncheckpoint averaging. We present these results in Table 3.\nIn Table 3 rows (A), we vary the number of attention heads and the attention key and value dimensions,\nkeeping the amount of computation constant, as described in Section 3.2.2. While single-head\nattention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.\nIn Table 3 rows (B), we observe that reducing the attention key size dk hurts model quality. This\nsuggests that determining compatibility is not easy and that a more sophisticated compatibility\nfunction than dot product may be beneficial. We further observe in rows (C) and (D) that, as expected,\nbigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our\nsinusoidal positional encoding with learned positional embeddings [9], and observe nearly identical\nresults to the base model.\n6.3\nEnglish Constituency Parsing\nTo evaluate if the Transformer can generalize to other tasks we performed experiments on English\nconstituency parsing. This task presents specific challenges: the output is subject to strong structural\nconstraints and is significantly longer than the input. Furthermore, RNN sequence-to-sequence\nmodels have not been able to attain state-of-the-art results in small-data regimes [37].\nWe trained a 4-layer transformer with dmodel = 1024 on the Wall Street Journal (WSJ) portion of the\nPenn Treebank [25], about 40K training sentences. We also trained it in a semi-supervised setting,\nusing the larger high-confidence and BerkleyParser corpora from with approximately 17M sentences\n[37]. We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens\nfor the semi-supervised setting.\nWe performed only a small number of experiments to select the dropout, both attention and residual\n(section 5.4), learning rates and beam size on the Section 22 development set, all other parameters\nremained unchanged from the English-to-German base translation model. During inference, we\n9\n\n\n## PDF page 10\n\nTable 4: The Transformer generalizes well to English constituency parsing (Results are on Section 23\nof WSJ)\nParser\nTraining\nWSJ 23 F1\nVinyals & Kaiser el al. (2014) [37]\nWSJ only, discriminative\n88.3\nPetrov et al. (2006) [29]\nWSJ only, discriminative\n90.4\nZhu et al. (2013) [40]\nWSJ only, discriminative\n90.4\nDyer et al. (2016) [8]\nWSJ only, discriminative\n91.7\nTransformer (4 layers)\nWSJ only, discriminative\n91.3\nZhu et al. (2013) [40]\nsemi-supervised\n91.3\nHuang & Harper (2009) [14]\nsemi-supervised\n91.3\nMcClosky et al. (2006) [26]\nsemi-supervised\n92.1\nVinyals & Kaiser el al. (2014) [37]\nsemi-supervised\n92.1\nTransformer (4 layers)\nsemi-supervised\n92.7\nLuong et al. (2015) [23]\nmulti-task\n93.0\nDyer et al. (2016) [8]\ngenerative\n93.3\nincreased the maximum output length to input length + 300. We used a beam size of 21 and α = 0.3\nfor both WSJ only and the semi-supervised setting.\nOur results in Table 4 show that despite the lack of task-specific tuning our model performs sur-\nprisingly well, yielding better results than all previously reported models with the exception of the\nRecurrent Neural Network Grammar [8].\nIn contrast to RNN sequence-to-sequence models [37], the Transformer outperforms the Berkeley-\nParser [29] even when training only on the WSJ training set of 40K sentences.\n7\nConclusion\nIn this work, we presented the Transformer, the first sequence transduction model based entirely on\nattention, replacing the recurrent layers most commonly used in encoder-decoder architectures with\nmulti-headed self-attention.\nFor translation tasks, the Transformer can be trained significantly faster than architectures based\non recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014\nEnglish-to-French translation tasks, we achieve a new state of the art. In the former task our best\nmodel outperforms even all previously reported ensembles.\nWe are excited about the future of attention-based models and plan to apply them to other tasks. We\nplan to extend the Transformer to problems involving input and output modalities other than text and\nto investigate local, restricted attention mechanisms to efficiently handle large inputs and outputs\nsuch as images, audio and video. Making generation less sequential is another research goals of ours.\nThe code we used to train and evaluate our models is available at https://github.com/\ntensorflow/tensor2tensor.\nAcknowledgements\nWe are grateful to Nal Kalchbrenner and Stephan Gouws for their fruitful\ncomments, corrections and inspiration.\nReferences\n[1] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint\narXiv:1607.06450, 2016.\n[2] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly\nlearning to align and translate. CoRR, abs/1409.0473, 2014.\n[3] Denny Britz, Anna Goldie, Minh-Thang Luong, and Quoc V. Le. Massive exploration of neural\nmachine translation architectures. CoRR, abs/1703.03906, 2017.\n[4] Jianpeng Cheng, Li Dong, and Mirella Lapata. Long short-term memory-networks for machine\nreading. arXiv preprint arXiv:1601.06733, 2016.\n10\n\n\n## PDF page 11\n\n[5] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk,\nand Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical\nmachine translation. CoRR, abs/1406.1078, 2014.\n[6] Francois Chollet. Xception: Deep learning with depthwise separable convolutions. arXiv\npreprint arXiv:1610.02357, 2016.\n[7] Junyoung Chung, Çaglar Gülçehre, Kyunghyun Cho, and Yoshua Bengio. Empirical evaluation\nof gated recurrent neural networks on sequence modeling. CoRR, abs/1412.3555, 2014.\n[8] Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, and Noah A. Smith. Recurrent neural\nnetwork grammars. In Proc. of NAACL, 2016.\n[9] Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. Convolu-\ntional sequence to sequence learning. arXiv preprint arXiv:1705.03122v2, 2017.\n[10] Alex Graves.\nGenerating sequences with recurrent neural networks.\narXiv preprint\narXiv:1308.0850, 2013.\n[11] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for im-\nage recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern\nRecognition, pages 770778, 2016.\n[12] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber. Gradient flow in\nrecurrent nets: the difficulty of learning long-term dependencies, 2001.\n[13] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation,\n9(8):17351780, 1997.\n[14] Zhongqiang Huang and Mary Harper. Self-training PCFG grammars with latent annotations\nacross languages. In Proceedings of the 2009 Conference on Empirical Methods in Natural\nLanguage Processing, pages 832841. ACL, August 2009.\n[15] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring\nthe limits of language modeling. arXiv preprint arXiv:1602.02410, 2016.\n[16] Łukasz Kaiser and Samy Bengio. Can active memory replace attention? In Advances in Neural\nInformation Processing Systems, (NIPS), 2016.\n[17] Łukasz Kaiser and Ilya Sutskever. Neural GPUs learn algorithms. In International Conference\non Learning Representations (ICLR), 2016.\n[18] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Ko-\nray Kavukcuoglu. Neural machine translation in linear time. arXiv preprint arXiv:1610.10099v2,\n2017.\n[19] Yoon Kim, Carl Denton, Luong Hoang, and Alexander M. Rush. Structured attention networks.\nIn International Conference on Learning Representations, 2017.\n[20] Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.\n[21] Oleksii Kuchaiev and Boris Ginsburg. Factorization tricks for LSTM networks. arXiv preprint\narXiv:1703.10722, 2017.\n[22] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen\nZhou, and Yoshua Bengio. A structured self-attentive sentence embedding. arXiv preprint\narXiv:1703.03130, 2017.\n[23] Minh-Thang Luong, Quoc V. Le, Ilya Sutskever, Oriol Vinyals, and Lukasz Kaiser. Multi-task\nsequence to sequence learning. arXiv preprint arXiv:1511.06114, 2015.\n[24] Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-\nbased neural machine translation. arXiv preprint arXiv:1508.04025, 2015.\n11\n\n\n## PDF page 12\n\n[25] Mitchell P Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. Building a large annotated\ncorpus of english: The penn treebank. Computational linguistics, 19(2):313330, 1993.\n[26] David McClosky, Eugene Charniak, and Mark Johnson. Effective self-training for parsing. In\nProceedings of the Human Language Technology Conference of the NAACL, Main Conference,\npages 152159. ACL, June 2006.\n[27] Ankur Parikh, Oscar Täckström, Dipanjan Das, and Jakob Uszkoreit. A decomposable attention\nmodel. In Empirical Methods in Natural Language Processing, 2016.\n[28] Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive\nsummarization. arXiv preprint arXiv:1705.04304, 2017.\n[29] Slav Petrov, Leon Barrett, Romain Thibaux, and Dan Klein. Learning accurate, compact,\nand interpretable tree annotation. In Proceedings of the 21st International Conference on\nComputational Linguistics and 44th Annual Meeting of the ACL, pages 433440. ACL, July\n2006.\n[30] Ofir Press and Lior Wolf. Using the output embedding to improve language models. arXiv\npreprint arXiv:1608.05859, 2016.\n[31] Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words\nwith subword units. arXiv preprint arXiv:1508.07909, 2015.\n[32] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton,\nand Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts\nlayer. arXiv preprint arXiv:1701.06538, 2017.\n[33] Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdi-\nnov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine\nLearning Research, 15(1):19291958, 2014.\n[34] Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory\nnetworks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors,\nAdvances in Neural Information Processing Systems 28, pages 24402448. Curran Associates,\nInc., 2015.\n[35] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. Sequence to sequence learning with neural\nnetworks. In Advances in Neural Information Processing Systems, pages 31043112, 2014.\n[36] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna.\nRethinking the inception architecture for computer vision. CoRR, abs/1512.00567, 2015.\n[37] Vinyals & Kaiser, Koo, Petrov, Sutskever, and Hinton. Grammar as a foreign language. In\nAdvances in Neural Information Processing Systems, 2015.\n[38] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang\nMacherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Googles neural machine\ntranslation system: Bridging the gap between human and machine translation. arXiv preprint\narXiv:1609.08144, 2016.\n[39] Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. Deep recurrent models with\nfast-forward connections for neural machine translation. CoRR, abs/1606.04199, 2016.\n[40] Muhua Zhu, Yue Zhang, Wenliang Chen, Min Zhang, and Jingbo Zhu. Fast and accurate\nshift-reduce constituent parsing. In Proceedings of the 51st Annual Meeting of the ACL (Volume\n1: Long Papers), pages 434443. ACL, August 2013.\n12\n\n\n## PDF page 13\n\nAttention Visualizations\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nFigure 3: An example of the attention mechanism following long-distance dependencies in the\nencoder self-attention in layer 5 of 6. Many of the attention heads attend to a distant dependency of\nthe verb making, completing the phrase making...more difficult. Attentions here shown only for\nthe word making. Different colors represent different heads. Best viewed in color.\n13\n\n\n## PDF page 14\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 4: Two attention heads, also in layer 5 of 6, apparently involved in anaphora resolution. Top:\nFull attentions for head 5. Bottom: Isolated attentions from just the word its for attention heads 5\nand 6. Note that the attentions are very sharp for this word.\n14\n\n\n## PDF page 15\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 5: Many of the attention heads exhibit behaviour that seems related to the structure of the\nsentence. We give two such examples above, from two different heads from the encoder self-attention\nat layer 5 of 6. The heads clearly learned to perform different tasks.\n15\n\n\n可直接引用的图表文件(放在 Slidev public 目录,用 /文件名 引用):\n- paper_figure_1_transformer.pngFigure 1 from PDF page 3: The Transformer model architecture.\n- paper_figure_3_long_distance.pngFigure 3 from PDF page 13: Encoder self-attention following long-distance dependencies.\n- paper_figure_4_anaphora.pngFigure 4 from PDF page 14: Attention heads involved in anaphora resolution.\n\n请生成一版 10-20 页的完整初稿。内容必须忠于论文,至少引用上面列出的三张原论文图,并覆盖问题、Transformer 架构、注意力机制、训练、主要实验、局限和结论。不要复制长段原文;每页保持听众可读的信息密度。生成完整的 slides.md。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n- Proposes **Transformer** - a new network architecture based solely on attention mechanisms\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- Achieves state-of-the-art results on machine translation tasks:\n - 28.4 BLEU on WMT 2014 English-to-German\n - 41.8 BLEU on WMT 2014 English-to-French\n- Generalizes well to other tasks like English constituency parsing\n\n---\n\n## Background: Sequence Transduction Challenges\n\n### Traditional Approaches\n- **Recurrent models** (LSTM, GRU) have sequential computation\n- **Convolutional models** have limited long-range dependencies\n- Both have challenges with parallelization and long sequences\n\n### Attention Mechanisms\n- Already used in conjunction with recurrent networks\n- Allows modeling dependencies without regard to distance\n- But not used as the primary architecture... until now\n\n---\n\n## The Transformer: Key Idea\n\nReplace recurrence and convolution with **self-attention** to:\n- Enable more parallelization\n- Reduce sequential computation\n- Capture long-range dependencies more effectively\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n*Encoder (left) and Decoder (right) stacks with self-attention and feed-forward layers*\n\n---\n\n## Encoder Stack\n\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections around each sub-layer\n- Layer normalization after each sub-layer\n- All sub-layers produce outputs of dimension `d_model = 512`\n\n---\n\n## Decoder Stack\n\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward information flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Same residual connections and layer normalization as encoder\n- Output embeddings offset by one position (auto-regressive property)\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-40 mx-auto\" />\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder\n2. **Encoder self-attention**: All positions attend to all positions in previous encoder layer\n3. **Decoder self-attention**: Positions attend to previous positions (masked to preserve auto-regressive property)\n\n---\n\n## Positional Encoding\n\nSince there's no recurrence/convolution, we add positional information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performed similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Details\n\n### Data & Batching\n- WMT 2014 English-German (4.5M sentence pairs)\n- WMT 2014 English-French (36M sentence pairs)\n- Byte-pair encoding with shared vocabulary\n- Batches with ~25,000 source and target tokens\n\n### Hardware & Schedule\n- 8 NVIDIA P100 GPUs\n- Base model: 100,000 steps (12 hours)\n- Big model: 300,000 steps (3.5 days)\n\n---\n\n## Training Details (Cont.)\n\n### Optimizer\n- Adam with $\\beta_1 = 0.9$, $\\beta_2 = 0.98$, $\\epsilon = 10^{-9}$\n- Learning rate schedule:\n $$\\text{lrate} = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step\\_num}^{-0.5}, \\text{step\\_num} \\cdot \\text{warmup\\_steps}^{-1.5})$$\n- Warmup steps = 4000\n\n### Regularization\n- Residual dropout (P_drop = 0.1)\n- Label smoothing ($\\epsilon_{ls} = 0.1$)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n- 2+ BLEU improvement on English-to-German\n\n---\n\n## Model Architecture Ablations\n\n| Variation | Dev PPL | Dev BLEU |\n|-----------|---------|----------|\n| Base model | 4.92 | 25.8 |\n| (A) 1 attention head | 5.29 | 24.9 |\n| (B) d_k = 16 | 5.75 | 24.5 |\n| (C) 2 layers | 6.11 | 23.7 |\n| (D) No dropout | 5.77 | 24.6 |\n| (E) Learned positional embeddings | 4.92 | 25.7 |\n\n- Multi-head attention improves performance\n- Dropout is crucial for avoiding overfitting\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. (2014) | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Performs comparably to state-of-the-art parsers\n- Better than RNN models in small-data regimes\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion\n\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution\n- Achieved new state-of-the-art in machine translation:\n - 28.4 BLEU on English-to-German\n - 41.8 BLEU on English-to-French\n- More parallelizable and faster to train\n- Generalizes well to other tasks like constituency parsing\n\n---\n\n## Future Work\n\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "硬性验收失败:你刚才生成了 21 页,必须是 10–20 页。请在不删除三张原论文图、不丢失主要贡献的前提下合并或拆分内容,重新输出完整 slides.md;不得超过 20 页。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n- Proposes **Transformer** - a new network architecture based solely on attention\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- State-of-the-art results:\n - 28.4 BLEU on WMT 2014 English-to-German\n - 41.8 BLEU on WMT 2014 English-to-French\n- Generalizes well to other tasks like English constituency parsing\n\n---\n\n## Background & Key Idea\n\n### Traditional Sequence Models\n- **Recurrent models** (LSTM, GRU): Sequential computation, limited parallelization\n- **Convolutional models**: Limited long-range dependencies\n\n### Attention Mechanism\n- Already used with recurrent networks\n- Allows modeling dependencies without regard to distance\n\n### The Transformer\n- **Key innovation**: Replace recurrence and convolution with self-attention\n- Enables more parallelization and better long-range dependencies\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n*Encoder (left) and Decoder (right) stacks with self-attention and feed-forward layers*\n\n---\n\n## Encoder & Decoder Stacks\n\n### Encoder\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Output dimension: `d_model = 512`\n\n### Decoder\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise feed-forward network\n- Same residual connections and layer normalization\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n### Applications\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder\n2. **Encoder self-attention**: All positions attend to all positions\n3. **Decoder self-attention**: Positions attend to previous positions (masked)\n\n---\n\n## Positional Encoding\n\nSince there's no recurrence/convolution, we add positional information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performed similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Details\n\n### Data & Batching\n- WMT 2014 English-German (4.5M pairs), English-French (36M pairs)\n- Byte-pair encoding with shared vocabulary\n- Batches with ~25,000 source and target tokens\n\n### Hardware & Schedule\n- 8 NVIDIA P100 GPUs\n- Base model: 100,000 steps (12 hours)\n- Big model: 300,000 steps (3.5 days)\n\n### Optimizer & Regularization\n- Adam with $\\beta_1=0.9$, $\\beta_2=0.98$, $\\epsilon=10^{-9}$\n- Learning rate schedule with warmup steps=4000\n- Residual dropout (P_drop=0.1) and label smoothing ($\\epsilon_{ls}=0.1$)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n- 2+ BLEU improvement on English-to-German\n\n---\n\n## Model Architecture Ablations\n\n| Variation | Dev PPL | Dev BLEU |\n|-----------|---------|----------|\n| Base model | 4.92 | 25.8 |\n| (A) 1 attention head | 5.29 | 24.9 |\n| (B) d_k = 16 | 5.75 | 24.5 |\n| (C) 2 layers | 6.11 | 23.7 |\n| (D) No dropout | 5.77 | 24.6 |\n| (E) Learned positional embeddings | 4.92 | 25.7 |\n\n- Multi-head attention improves performance\n- Dropout is crucial for avoiding overfitting\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. (2014) | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Performs comparably to state-of-the-art parsers\n- Better than RNN models in small-data regimes\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion & Future Work\n\n### Contributions\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution\n- Achieved new state-of-the-art in machine translation\n- More parallelizable and faster to train\n- Generalizes well to other tasks\n\n### Future Work\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "审核者(Reviewer)渲染了你上一版 slides.md 的每一页截图,给出如下结构化改进建议(JSON):\n\n{\n \"overall_score\": 65,\n \"pass\": false,\n \"issues\": [\n {\n \"page\": 2,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将要点拆分为2页,例如将State-of-the-art results单独作为一页展示\"\n },\n {\n \"page\": 3,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将三个部分拆分为独立页面,每个部分单独一页详细说明\"\n },\n {\n \"page\": 4,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"放大架构图至占页面2/3空间,删除图片下方的文字说明或将其移至下一页\"\n },\n {\n \"page\": 4,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"删除图片下方的长段文字,仅保留标题和简短说明\"\n },\n {\n \"page\": 5,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Encoder和Decoder分拆为两页,每页单独详细说明其结构\"\n },\n {\n \"page\": 7,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Multi-Head Attention原理和Applications分拆为两页\"\n },\n {\n \"page\": 10,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"high\",\n \"suggestion\": \"将Data & Batching、Hardware & Schedule、Optimizer & Regularization三个部分拆分为3页\"\n },\n {\n \"page\": 14,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"放大注意力可视化图,使其占满页面,确保文字和连线清晰可见\"\n },\n {\n \"page\": 15,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"放大注意力可视化图,增加对比度,确保不同颜色的注意力头可区分\"\n },\n {\n \"page\": 16,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Contributions和Future Work分拆为两页,每部分保留3-4个要点\"\n }\n ]\n}\n\n请理解这些问题并修订 slides.md(可拆页、精简文字、调整图片尺寸等),重新输出完整的 slides.md。修订后仍必须保持 10–20 页;解决拥挤时优先精简与合并,不得用无限拆页规避版面问题。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract: Key Innovation\n\n- Proposes **Transformer** - first network architecture based solely on attention\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable and requires significantly less training time\n- Generalizes well to other tasks beyond machine translation\n\n---\n\n## Abstract: Performance Highlights\n\n- **WMT 2014 English-to-German**: 28.4 BLEU\n - Improves over existing best results by over 2 BLEU\n- **WMT 2014 English-to-French**: 41.8 BLEU\n - New single-model state-of-the-art\n - Trained for 3.5 days on eight GPUs (small fraction of previous costs)\n\n---\n\n## Background: Traditional Sequence Models\n\n### Recurrent Models (LSTM, GRU)\n- Sequential computation inherently limits parallelization\n- Long-range dependencies difficult to learn\n- Computation scales linearly with sequence length\n\n### Convolutional Models\n- Better parallelization but limited receptive field\n- Requires multiple layers to capture long-range dependencies\n- Computational complexity grows with kernel size\n\n---\n\n## Key Idea: The Transformer\n\nReplace recurrence and convolution with **self-attention** to:\n- Enable massive parallelization\n- Capture long-range dependencies directly\n- Reduce training time significantly\n- Maintain or improve model quality\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-96 mx-auto\" />\n\n---\n\n## Architecture Overview\n\n- **Encoder**: Processes input sequence into continuous representation\n- **Decoder**: Generates output sequence based on encoder output\n- Both use stacked self-attention and feed-forward layers\n- Residual connections and layer normalization throughout\n\n---\n\n## Encoder Stack\n\n- **6 identical layers** each with:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections around each sub-layer\n- Layer normalization after each sub-layer\n- Output dimension: `d_model = 512`\n\n---\n\n## Decoder Stack\n\n- **6 identical layers** each with:\n 1. Masked multi-head self-attention (prevents leftward flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise feed-forward network\n- Same residual connections and layer normalization as encoder\n- Output embeddings offset by one position (auto-regressive property)\n\n---\n\n## Scaled Dot-Product Attention\n\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- $Q$ (queries), $K$ (keys), $V$ (values) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradients from becoming too small\n- More efficient than additive attention with similar performance\n\n---\n\n## Multi-Head Attention\n\n- Projects queries, keys, values $h$ times with different linear projections\n- Performs attention in parallel on each projected version\n- Concatenates results and projects again:\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- $h = 8$ heads, $d_k = d_v = d_{\\text{model}}/h = 64$\n\n---\n\n## Attention Applications\n\n1. **Encoder-decoder attention**: \n - Queries from decoder, keys/values from encoder\n - Enables decoder to attend to all input positions\n\n2. **Encoder self-attention**:\n - All positions attend to all positions in previous encoder layer\n - Captures dependencies within input sequence\n\n3. **Decoder self-attention**:\n - Positions attend to previous positions (masked)\n - Preserves auto-regressive property\n\n---\n\n## Positional Encoding\n\nAdds sequence position information:\n\n$$\\text{PE}_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$\\text{PE}_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Allows model to learn relative position information\n- Performs similarly to learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Operations | Max Path Length |\n|------------|------------|-----------------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs/RNNs\n- More interpretable attention distributions\n\n---\n\n## Training Data & Batching\n\n- **Datasets**:\n - WMT 2014 English-German (4.5M sentence pairs)\n - WMT 2014 English-French (36M sentence pairs)\n- **Tokenization**:\n - Byte-pair encoding with shared vocabulary\n - 37,000 tokens (EN-DE), 32,000 tokens (EN-FR)\n- **Batching**:\n - Sentences grouped by approximate length\n - Each batch contains ~25,000 source and target tokens\n\n---\n\n## Training Hardware & Schedule\n\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Base model**:\n - 100,000 training steps\n - ~12 hours total training time\n - 0.4 seconds per step\n- **Big model**:\n - 300,000 training steps\n - ~3.5 days total training time\n - 1.0 seconds per step\n\n---\n\n## Training Optimizer & Regularization\n\n- **Optimizer**: Adam\n - $\\beta_1 = 0.9$, $\\beta_2 = 0.98$, $\\epsilon = 10^{-9}$\n - Learning rate schedule with warmup steps=4000\n\n- **Regularization**:\n - Residual dropout (P_drop = 0.1)\n - Label smoothing ($\\epsilon_{ls} = 0.1$)\n - Dropout on embeddings + positional encodings\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)** | **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$** |\n\n- Transformer outperforms all previous state-of-the-art models\n- Achieves better results with significantly lower training cost\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-96 w-full object-contain\" />\n\n*Encoder self-attention in layer 5 showing attention to distant dependency \"making...more difficult\"*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-96 w-full object-contain\" />\n\n*Attention heads focusing on resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion: Key Contributions\n\n- Introduced **Transformer**, first transduction model based entirely on attention\n- Eliminated recurrence and convolution, enabling better parallelization\n- Achieved new state-of-the-art in machine translation\n- Reduced training time significantly compared to previous approaches\n- Generalized well to other tasks like English constituency parsing\n\n---\n\n## Future Work\n\n- Apply to other modalities (images, audio, video)\n- Investigate local, restricted attention mechanisms\n- Make generation less sequential\n- Explore interpretability of attention patterns\n- Extend to larger input/output sequences\n\n**Code available at:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "硬性验收失败:你刚才生成了 22 页,必须是 10–20 页。请在不删除三张原论文图、不丢失主要贡献的前提下合并或拆分内容,重新输出完整 slides.md;不得超过 20 页。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n### Key Innovation\n- First sequence transduction model based **solely on attention**\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable with significantly less training time\n\n### Performance Highlights\n- **WMT 2014 EN-DE**: 28.4 BLEU (+2+ over previous SOTA)\n- **WMT 2014 EN-FR**: 41.8 BLEU (new single-model SOTA)\n- Trained in 3.5 days on 8 GPUs (small fraction of previous costs)\n\n---\n\n## Background & Key Idea\n\n### Traditional Sequence Models\n- **Recurrent (LSTM/GRU)**: Sequential computation limits parallelization\n- **Convolutional**: Requires multiple layers for long-range dependencies\n\n### The Transformer\n- Replaces recurrence/convolution with **self-attention**\n- Enables direct modeling of long-range dependencies\n- Massive parallelization → faster training\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-96 mx-auto\" />\n\n*Encoder (left) and Decoder (right) with self-attention and feed-forward layers*\n\n---\n\n## Encoder & Decoder Stacks\n\n### Encoder (6 identical layers)\n- **Sub-layer 1**: Multi-head self-attention\n- **Sub-layer 2**: Position-wise feed-forward network\n- Residual connections + layer normalization\n- Output dimension: `d_model = 512`\n\n### Decoder (6 identical layers)\n- **Sub-layer 1**: Masked multi-head self-attention (prevents leftward flow)\n- **Sub-layer 2**: Multi-head attention over encoder output\n- **Sub-layer 3**: Position-wise feed-forward network\n- Same residual connections and normalization\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n- Scaling by $\\sqrt{d_k}$ prevents small gradients\n- Efficient with matrix multiplication\n\n### Multi-Head Attention\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1,...,\\text{head}_h)W^O$$\n- $h=8$ parallel heads, $d_k=d_v=64$\n- Captures diverse dependency patterns\n\n---\n\n## Attention Applications\n\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder \n2. **Encoder self-attention**: All positions attend to all input positions \n3. **Decoder self-attention**: Positions attend to previous positions (masked) \n\n---\n\n## Positional Encoding\n\nAdds sequence position information via sinusoidal functions:\n$$\\text{PE}_{(pos,2i)}=\\sin(pos/10000^{2i/d_{\\text{model}}})$$\n$$\\text{PE}_{(pos,2i+1)}=\\cos(pos/10000^{2i/d_{\\text{model}}})$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Enables learning of relative positions\n- Performs similarly to learned embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------------|------------------|----------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs\n- More interpretable attention patterns\n\n---\n\n## Training Setup\n\n### Data & Batching\n- WMT 2014 EN-DE (4.5M pairs), EN-FR (36M pairs)\n- Byte-pair encoding (37K/32K vocab)\n- Batches with ~25K source/target tokens\n\n### Hardware & Schedule\n- 8 NVIDIA P100 GPUs\n- Base model: 100K steps (12h), Big model: 300K steps (3.5d)\n\n### Optimization\n- Adam ($\\beta_1=0.9$, $\\beta_2=0.98$), learning rate warmup\n- Dropout (0.1), label smoothing (0.1)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|----------------------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)**| **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$**|\n\n- Outperforms all previous SOTA with lower training cost\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-96 w-full object-contain\" />\n\n*Encoder self-attention (layer 5) tracking \"making...more difficult\" dependency*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-96 w-full object-contain\" />\n\n*Attention heads resolving \"its\" to \"The Law\"*\n\n---\n\n## Conclusion & Future Work\n\n### Key Contributions\n- Introduced Transformer, first attention-only transduction model\n- Eliminated recurrence/convolution → better parallelization\n- Set new SOTA in machine translation with lower training cost\n- Generalizes to other tasks (e.g., constituency parsing)\n\n### Future Work\n- Apply to other modalities (images, audio)\n- Explore local attention for large sequences\n- Improve generation sequentiality\n- Enhance attention interpretability\n\n**Code:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "审核者(Reviewer)渲染了你上一版 slides.md 的每一页截图,给出如下结构化改进建议(JSON):\n\n{\n \"overall_score\": 75,\n \"pass\": false,\n \"issues\": [\n {\n \"page\": 4,\n \"issue_type\": \"image_size\",\n \"severity\": \"medium\",\n \"suggestion\": \"放大Transformer架构图,确保图中模块名称和连接关系清晰可见\"\n },\n {\n \"page\": 4,\n \"issue_type\": \"readability\",\n \"severity\": \"medium\",\n \"suggestion\": \"移除图片下方的长段文字说明,仅保留简洁标题或关键标注\"\n },\n {\n \"page\": 5,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Encoder和Decoder内容拆分到两页,每页不超过4个要点\"\n },\n {\n \"page\": 10,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Training Setup的三个部分拆分到单独页面,每个部分保留2-3个要点\"\n },\n {\n \"page\": 12,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"大幅放大注意力可视化图,确保文字标签和连接线清晰可辨\"\n },\n {\n \"page\": 12,\n \"issue_type\": \"readability\",\n \"severity\": \"high\",\n \"suggestion\": \"移除图片下方的详细说明文字,仅保留标题和简短解释\"\n },\n {\n \"page\": 13,\n \"issue_type\": \"image_size\",\n \"severity\": \"high\",\n \"suggestion\": \"大幅放大指代消解可视化图,确保文字和注意力权重分布清晰可见\"\n },\n {\n \"page\": 13,\n \"issue_type\": \"readability\",\n \"severity\": \"high\",\n \"suggestion\": \"移除图片下方的说明文字,改用简洁标题突出核心发现\"\n },\n {\n \"page\": 14,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将Key Contributions和Future Work拆分到两页,每部分保留3-4个要点\"\n }\n ]\n}\n\n请理解这些问题并修订 slides.md(可拆页、精简文字、调整图片尺寸等),重新输出完整的 slides.md。修订后仍必须保持 10–20 页;解决拥挤时优先精简与合并,不得用无限拆页规避版面问题。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Abstract\n\n### Key Innovation\n- First sequence transduction model based **solely on attention**\n- Dispenses with recurrence and convolutions entirely\n- More parallelizable with significantly less training time\n\n### Performance Highlights\n- **WMT 2014 EN-DE**: 28.4 BLEU (+2+ over previous SOTA)\n- **WMT 2014 EN-FR**: 41.8 BLEU (new single-model SOTA)\n- Trained in 3.5 days on 8 GPUs (small fraction of previous costs)\n\n---\n\n## Background & Key Idea\n\n### Traditional Sequence Models\n- **Recurrent (LSTM/GRU)**: Sequential computation limits parallelization\n- **Convolutional**: Requires multiple layers for long-range dependencies\n\n### The Transformer\n- Replaces recurrence/convolution with **self-attention**\n- Enables direct modeling of long-range dependencies\n- Massive parallelization → faster training\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-[600px] w-full object-contain\" />\n\n---\n\n## Encoder Stack\n\n- **6 identical layers** with two sub-layers:\n 1. Multi-head self-attention mechanism\n 2. Position-wise feed-forward network\n- Residual connections around each sub-layer\n- Layer normalization after each sub-layer\n- Output dimension: `d_model = 512`\n\n---\n\n## Decoder Stack\n\n- **6 identical layers** with three sub-layers:\n 1. Masked multi-head self-attention (prevents leftward flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise feed-forward network\n- Same residual connections and normalization as encoder\n- Output embeddings offset by one position (auto-regressive property)\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n- Scaling by $\\sqrt{d_k}$ prevents small gradients\n- Efficient with matrix multiplication\n\n### Multi-Head Attention\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1,...,\\text{head}_h)W^O$$\n- $h=8$ parallel heads, $d_k=d_v=64$\n- Captures diverse dependency patterns\n\n---\n\n## Attention Applications\n\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder \n2. **Encoder self-attention**: All positions attend to all input positions \n3. **Decoder self-attention**: Positions attend to previous positions (masked) \n\n---\n\n## Positional Encoding\n\nAdds sequence position information via sinusoidal functions:\n$$\\text{PE}_{(pos,2i)}=\\sin(pos/10000^{2i/d_{\\text{model}}})$$\n$$\\text{PE}_{(pos,2i+1)}=\\cos(pos/10000^{2i/d_{\\text{model}}})$$\n\n- Same dimension as embeddings ($d_{\\text{model}}$)\n- Enables learning of relative positions\n- Performs similarly to learned embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------------|------------------|----------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs\n- More interpretable attention patterns\n\n---\n\n## Training Data & Batching\n\n- **Datasets**:\n - WMT 2014 EN-DE (4.5M sentence pairs)\n - WMT 2014 EN-FR (36M sentence pairs)\n- **Tokenization**:\n - Byte-pair encoding with shared vocabulary\n - 37K tokens (EN-DE), 32K tokens (EN-FR)\n- **Batching**:\n - Sentences grouped by approximate length\n - Each batch contains ~25K source and target tokens\n\n---\n\n## Training Hardware & Schedule\n\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Base model**:\n - 100,000 training steps\n - ~12 hours total training time\n- **Big model**:\n - 300,000 training steps\n - ~3.5 days total training time\n\n---\n\n## Training Optimization\n\n- **Optimizer**: Adam\n - $\\beta_1 = 0.9$, $\\beta_2 = 0.98$, $\\epsilon = 10^{-9}$\n - Learning rate schedule with warmup steps=4000\n\n- **Regularization**:\n - Residual dropout (P_drop = 0.1)\n - Label smoothing ($\\epsilon_{ls} = 0.1$)\n - Dropout on embeddings + positional encodings\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|----------------------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)**| **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$**|\n\n- Outperforms all previous SOTA with lower training cost\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-[600px] w-full object-contain\" />\n\n*Tracking \"making...more difficult\" dependency across distant positions*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-[600px] w-full object-contain\" />\n\n*Resolving \"its\" to antecedent \"The Law\"*\n\n---\n\n## Key Contributions\n\n- Introduced Transformer, first attention-only transduction model\n- Eliminated recurrence/convolution → better parallelization\n- Set new SOTA in machine translation with lower training cost\n- Generalizes to other tasks (e.g., constituency parsing)\n\n---\n\n## Future Work\n\n- Apply to other modalities (images, audio, video)\n- Explore local attention for large sequences\n- Improve generation sequentiality\n- Enhance attention interpretability\n\n**Code:** https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": "审核者(Reviewer)渲染了你上一版 slides.md 的每一页截图,给出如下结构化改进建议(JSON):\n\n{\n \"overall_score\": 85,\n \"pass\": false,\n \"issues\": [\n {\n \"page\": 2,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将6个要点拆分为2页,Key Innovation和Performance Highlights各占一页,或删减次要信息使每页不超过5个要点\"\n },\n {\n \"page\": 11,\n \"issue_type\": \"overcrowded\",\n \"severity\": \"medium\",\n \"suggestion\": \"将6个子要点拆分为2页,例如将Datasets和Tokenization作为一页,Batching单独作为一页\"\n },\n {\n \"page\": 15,\n \"issue_type\": \"readability\",\n \"severity\": \"medium\",\n \"suggestion\": \"放大可视化图中的文字,或截取局部放大展示关键区域,确保观众能看清注意力模式和词语对应关系\"\n },\n {\n \"page\": 16,\n \"issue_type\": \"readability\",\n \"severity\": \"medium\",\n \"suggestion\": \"放大可视化图中的文字,或选择更清晰的可视化案例,确保代词解析的注意力关系清晰可见\"\n }\n ]\n}\n\n请理解这些问题并修订 slides.md(可拆页、精简文字、调整图片尺寸等),重新输出完整的 slides.md。修订后仍必须保持 10–20 页;解决拥挤时优先精简与合并,不得用无限拆页规避版面问题。"
}
],
"temperature": 0.3
},
"response": {
"id": "0217853853005302abf1227a14b352d5dc70daecccf2aa541a3a2",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "```markdown\n---\ntheme: default\ntitle: 'Attention Is All You Need'\nauthor: 'Ashish Vaswani et al.'\ndate: 'NIPS 2017'\n---\n\n# Attention Is All You Need\n\n**Authors:** Ashish Vaswani et al. \n**Conference:** NIPS 2017\n\n---\n\n## Key Innovation\n\n- First sequence transduction model based **solely on attention**\n- Dispenses with recurrence and convolutions entirely\n- Enables significantly more parallelization\n- Requires substantially less training time\n- Maintains or improves model quality\n\n---\n\n## Performance Highlights\n\n- **WMT 2014 English-to-German**: 28.4 BLEU\n - Improves over existing best results by 2+ BLEU\n- **WMT 2014 English-to-French**: 41.8 BLEU\n - New single-model state-of-the-art\n - Trained for 3.5 days on 8 GPUs (small fraction of previous costs)\n\n---\n\n## Background & Motivation\n\n### Traditional Sequence Models\n- **Recurrent (LSTM/GRU)**: Sequential computation limits parallelization\n- **Convolutional**: Requires multiple layers for long-range dependencies\n\n### The Transformer Solution\n- Replaces recurrence/convolution with **self-attention**\n- Directly models long-range dependencies\n- Massive parallelization enables faster training\n\n---\n\n## Transformer Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-[600px] w-full object-contain\" />\n\n---\n\n## Encoder Stack\n\n- **6 identical layers** with two sub-layers:\n 1. Multi-head self-attention mechanism\n 2. Position-wise feed-forward network\n- Residual connections around each sub-layer\n- Layer normalization after each sub-layer\n- Output dimension: `d_model = 512`\n\n---\n\n## Decoder Stack\n\n- **6 identical layers** with three sub-layers:\n 1. Masked multi-head self-attention (prevents leftward flow)\n 2. Multi-head attention over encoder output\n 3. Position-wise feed-forward network\n- Same residual connections and normalization as encoder\n- Output embeddings offset by one position (auto-regressive property)\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n- Scaling by $\\sqrt{d_k}$ prevents small gradients\n- Efficient with matrix multiplication\n\n### Multi-Head Attention\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1,...,\\text{head}_h)W^O$$\n- $h=8$ parallel heads, $d_k=d_v=64$\n- Captures diverse dependency patterns\n\n---\n\n## Attention Applications & Positional Encoding\n\n### Attention Applications\n1. **Encoder-decoder attention**: Queries from decoder, keys/values from encoder \n2. **Encoder self-attention**: All positions attend to all input positions \n3. **Decoder self-attention**: Positions attend to previous positions (masked) \n\n### Positional Encoding\nAdds sequence position information via sinusoidal functions:\n$$\\text{PE}_{(pos,2i)}=\\sin(pos/10000^{2i/d_{\\text{model}}})$$\n$$\\text{PE}_{(pos,2i+1)}=\\cos(pos/10000^{2i/d_{\\text{model}}})$$\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------------|------------------|----------------|-----------------|\n| Self-Attention | $O(n^2 \\cdot d)$ | $O(1)$ | $O(1)$ |\n| Recurrent | $O(n \\cdot d^2)$ | $O(n)$ | $O(n)$ |\n| Convolutional | $O(k \\cdot n \\cdot d^2)$ | $O(1)$ | $O(\\log_k n)$ |\n\n- Better parallelization than RNNs\n- Shorter path length than CNNs\n- More interpretable attention patterns\n\n---\n\n## Training Datasets & Tokenization\n\n- **Datasets**:\n - WMT 2014 English-German (4.5M sentence pairs)\n - WMT 2014 English-French (36M sentence pairs)\n\n- **Tokenization**:\n - Byte-pair encoding with shared vocabulary\n - 37,000 tokens (EN-DE), 32,000 tokens (EN-FR)\n\n---\n\n## Training Batching Strategy\n\n- Sentences grouped by approximate length\n- Each batch contains ~25,000 source tokens\n- Each batch contains ~25,000 target tokens\n- Balances computational efficiency and sequence length variation\n\n---\n\n## Training Hardware & Schedule\n\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Base model**:\n - 100,000 training steps\n - ~12 hours total training time\n- **Big model**:\n - 300,000 training steps\n - ~3.5 days total training time\n\n---\n\n## Training Optimization\n\n- **Optimizer**: Adam\n - $\\beta_1 = 0.9$, $\\beta_2 = 0.98$, $\\epsilon = 10^{-9}$\n - Learning rate schedule with warmup steps=4000\n\n- **Regularization**:\n - Residual dropout (P_drop = 0.1)\n - Label smoothing ($\\epsilon_{ls} = 0.1$)\n - Dropout on embeddings + positional encodings\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|----------------------|------------|------------|-----------------------|\n| GNMT + RL Ensemble | 26.30 | 41.16 | $1.8 \\cdot 10^{20}$ |\n| ConvS2S Ensemble | 26.36 | 41.29 | $7.7 \\cdot 10^{19}$ |\n| **Transformer (big)**| **28.4** | **41.8** | **$2.3 \\cdot 10^{19}$**|\n\n- Outperforms all previous SOTA with lower training cost\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-[600px] w-full object-contain\" />\n\n*Tracking \"making...more difficult\" dependency across distant positions*\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-[600px] w-full object-contain\" />\n\n*Resolving \"its\" to antecedent \"The Law\"*\n\n---\n\n## Key Contributions\n\n- Introduced Transformer, first attention-only transduction model\n- Eliminated recurrence/convolution → better parallelization\n- Set new SOTA in machine translation with lower training cost\n- Generalizes to other tasks (e.g., constituency parsing)\n\n---\n\n## Future Work\n\n- Apply to other modalities (images, audio, video)\n- Explore local attention for large sequences\n- Improve generation sequentiality\n- Enhance attention interpretability\n\n**Code:** https://github.com/tensorflow/tensor2tensor\n```"
},
"usage": {
"prompt_tokens": 23072,
"completion_tokens": 2109,
"total_tokens": 25181,
"cached_prompt_tokens": 0
}
},
{
"meter": "Reviewer(每轮只看最新截图)",
"called_at_utc": "2026-07-30T04:24:09.598578+00:00",
"latency_s": 99.311,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名严格的演示文稿质量审核员(Reviewer)。你会看到一份由 Slidev 渲染出的 PPT,\n每张图对应一页幻灯片(按顺序编号,从第 1 页开始)。请逐页检查以下问题:\n\n- text_overflow(文字溢出/被裁切超出页面边界)\n- overcrowded(内容过多/过于拥挤/留白不足)\n- image_size(图片过大顶出布局,或过小看不清)\n- readability(字号过小、对比度差、代码块难读)\n- layout(对齐混乱、标题与正文比例失衡、空页)\n\n请以**目标用户是听众**的严格标准审查——一页幻灯片若要点超过约 5 条、或正文文字块偏长、\n或图片挤压了文字空间,都应视为 overcrowded/image_size 问题。报告真实存在的问题,\n但不要放过\"塞得太满\"。对每个问题给出:page(页码,整数)、\nissue_type(上面之一)、severityhigh/medium/low)、suggestion(具体、可执行的修改建议,中文)。\n\n同时给出:\n- overall_score0-100 的整体质量分(越高越好)\n- pass:布尔值,仅当整份 PPT **既无 high 也无 medium 级问题**、排版干净可读时才为 true\n\n严格输出如下 JSON(不要输出任何多余文字):\n{\n \"overall_score\": <int>,\n \"pass\": <bool>,\n \"issues\": [\n {\"page\": <int>, \"issue_type\": \"<type>\", \"severity\": \"<high|medium|low>\", \"suggestion\": \"<中文建议>\"}\n ]\n}"
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "这份 PPT 共 19 页,下面按页码顺序给出每一页的渲染截图。请审查。"
},
{
"type": "text",
"text": "第 1 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9d3c8d02979b8658be4dc98b1b914e4daf9ca6900e251a9c0d0c1225010ef208",
"characters": 61854,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 2 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "e3dd4226e5604f9b7d44c96e83d39d8cab36acfddd2ce044dd12ab4178ee6c03",
"characters": 99678,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 3 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "d54253c9d63ccd761cb68f2105dcbfc9546353ac173dc17e00a7aea2e54deb65",
"characters": 106506,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 4 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a36b9480cac068a4697457cf802e348a489af1e3cecd2a96cd6d375e9792effe",
"characters": 151218,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 5 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "7f0a9adb6003279433fbe0b678d32a00d1b18aa53a64ad7b410a82854daa1745",
"characters": 134138,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 6 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "f21c0de2d76609a1c98769e6b8466011a7157092b26879a647939982c93a0324",
"characters": 100734,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 7 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "929555f1f5c7a6c5d2e366eb2e496aa9ba70e2dbac7939382d744b9f9d50ad72",
"characters": 124658,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 8 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "4b02c8b2a4836e2e41aae9da9fa42e508036588f448c593b90866e5260bb8a01",
"characters": 153882,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 9 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "fbba53df383f6638fb8f09f85758530a9dd2ed69f707a424ad8acecacafe4b2e",
"characters": 187154,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 10 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "317afc56617303886072156d70c7f40b2c08f1a10b2545af504f8c656dcf3dfa",
"characters": 131406,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 11 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "4acf19a7ed443435686c95f30c4953a1f0428dd9270ad532c301d4caa0613242",
"characters": 110062,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 12 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "ced86f319797ec6fed137e4a9657b3c27843e16c597631553fc1552c1417f45e",
"characters": 97798,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 13 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "71e1693b042f6020b01b0523b775ba04782749444679354ec89a44c3bfd9ca92",
"characters": 92510,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 14 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "bd8143c387ff06c4782826a81b077a3c3cefb1aeb08816bca0160a527f8e7e68",
"characters": 105534,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 15 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "3ea3f5d33395f0e164166778184da3b27a9b4eae27c21615de85d0dd015b2e43",
"characters": 110602,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 16 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "3941596c28c3c3bf92d5edb9a455a8782241a1c436b97bfebbc197a862da68d0",
"characters": 272750,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 17 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9d96bf60e05ef420ed392d9802c64327b22e7d6c55751fe224cbad1cd1e11fec",
"characters": 261346,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 18 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "2b06e06e39d8d79187144dd3480800259dba1dd1de79efdc40c43d68b19ad6e9",
"characters": 101706,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 19 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "00cb22fea345052aded272d9f8636e2fa27935367e3e1b5a701f96d2719fcdc5",
"characters": 95498,
"media_type": "image/png"
},
"detail": "high"
}
}
]
}
],
"temperature": 0.2
},
"response": {
"id": "021785385411269aa5397b165da2577de074a3e1d2c08413ebef1",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "{\n \"overall_score\": 85,\n \"pass\": false,\n \"issues\": [\n {\"page\": 16, \"issue_type\": \"readability\", \"severity\": \"medium\", \"suggestion\": \"放大注意力可视化图中的文字,确保观众能清晰辨认词语和连接线;可适当简化图例说明文字\"},\n {\"page\": 16, \"issue_type\": \"image_size\", \"severity\": \"medium\", \"suggestion\": \"增大可视化图表尺寸,占据更多页面空间以提升细节可见度,避免文字挤压\"},\n {\"page\": 17, \"issue_type\": \"readability\", \"severity\": \"high\", \"suggestion\": \"重新生成高分辨率的注意力可视化图,确保所有词语清晰可辨;考虑使用更大字号的文本标注\"},\n {\"page\": 17, \"issue_type\": \"image_size\", \"severity\": \"high\", \"suggestion\": \"显著放大图表至页面70%以上空间,或拆分图表为单独页面展示;添加简洁标题说明图表内容\"}\n ]\n}"
},
"usage": {
"prompt_tokens": 22978,
"completion_tokens": 1778,
"total_tokens": 24756,
"cached_prompt_tokens": 0
}
},
{
"meter": "SingleAgent(自审, 图片累积)",
"called_at_utc": "2026-07-30T04:24:58.752999+00:00",
"latency_s": 49.088,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名擅长把学术论文转化为演示文稿的 Proposer Agent。\n你用 Slidev 框架(Markdown + HTML)编写 PPT 源码 slides.md。\n\nSlidev 语法要点:\n- 文件开头是 YAML frontmatter--- 包裹),设置 theme: default。\n- 用单独一行的 `---`(前后空行)分隔每一页幻灯片。\n- 首页通常放标题、作者、会议。\n- 引用图片用 markdown![说明](/图片文件名.png),可用 HTML 控制尺寸,\n 例如 <img src=\"/speedup_bar.png\" class=\"h-60 mx-auto\" />。\n- 可用 Windi/Uno CSS 工具类控制排版(如 text-sm、grid grid-cols-2 gap-4)。\n\n要求:\n- 最终生成 10-20 页,覆盖论文的标题、背景/动机、方法、实验结果、局限与结论。\n- 至少在 3 页中使用提供的图表/表格,且图文匹配。\n- 每页信息量适中、不要塞太多字,宁可拆页也不要溢出。\n- 只输出 slides.md 的完整内容,用 ```markdown 代码块包裹,不要额外解释。\n\n此外,你还要**自我审查**:当收到自己 PPT 的渲染截图时,先在心里按下列标准找出问题\n(文字溢出、内容拥挤、图片尺寸、可读性、布局),再据此输出修订后的完整 slides.md。"
},
{
"role": "user",
"content": "以下是论文全文(Markdown):\n\n# Attention Is All You Need\n\nAuthors: Ashish Vaswani et al.\n\n\n## PDF page 1\n\nProvided proper attribution is provided, Google hereby grants permission to\nreproduce the tables and figures in this paper solely for use in journalistic or\nscholarly works.\nAttention Is All You Need\nAshish Vaswani\nGoogle Brain\navaswani@google.com\nNoam Shazeer\nGoogle Brain\nnoam@google.com\nNiki Parmar\nGoogle Research\nnikip@google.com\nJakob Uszkoreit\nGoogle Research\nusz@google.com\nLlion Jones\nGoogle Research\nllion@google.com\nAidan N. Gomez∗†\nUniversity of Toronto\naidan@cs.toronto.edu\nŁukasz Kaiser\nGoogle Brain\nlukaszkaiser@google.com\nIllia Polosukhin∗‡\nillia.polosukhin@gmail.com\nAbstract\nThe dominant sequence transduction models are based on complex recurrent or\nconvolutional neural networks that include an encoder and a decoder. The best\nperforming models also connect the encoder and decoder through an attention\nmechanism. We propose a new simple network architecture, the Transformer,\nbased solely on attention mechanisms, dispensing with recurrence and convolutions\nentirely. Experiments on two machine translation tasks show these models to\nbe superior in quality while being more parallelizable and requiring significantly\nless time to train. Our model achieves 28.4 BLEU on the WMT 2014 English-\nto-German translation task, improving over the existing best results, including\nensembles, by over 2 BLEU. On the WMT 2014 English-to-French translation task,\nour model establishes a new single-model state-of-the-art BLEU score of 41.8 after\ntraining for 3.5 days on eight GPUs, a small fraction of the training costs of the\nbest models from the literature. We show that the Transformer generalizes well to\nother tasks by applying it successfully to English constituency parsing both with\nlarge and limited training data.\nEqual contribution. Listing order is random. Jakob proposed replacing RNNs with self-attention and started\nthe effort to evaluate this idea. Ashish, with Illia, designed and implemented the first Transformer models and\nhas been crucially involved in every aspect of this work. Noam proposed scaled dot-product attention, multi-head\nattention and the parameter-free position representation and became the other person involved in nearly every\ndetail. Niki designed, implemented, tuned and evaluated countless model variants in our original codebase and\ntensor2tensor. Llion also experimented with novel model variants, was responsible for our initial codebase, and\nefficient inference and visualizations. Lukasz and Aidan spent countless long days designing various parts of and\nimplementing tensor2tensor, replacing our earlier codebase, greatly improving results and massively accelerating\nour research.\n†Work performed while at Google Brain.\n‡Work performed while at Google Research.\n31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA.\narXiv:1706.03762v7 [cs.CL] 2 Aug 2023\n\n\n## PDF page 2\n\n1\nIntroduction\nRecurrent neural networks, long short-term memory [13] and gated recurrent [7] neural networks\nin particular, have been firmly established as state of the art approaches in sequence modeling and\ntransduction problems such as language modeling and machine translation [35, 2, 5]. Numerous\nefforts have since continued to push the boundaries of recurrent language models and encoder-decoder\narchitectures [38, 24, 15].\nRecurrent models typically factor computation along the symbol positions of the input and output\nsequences. Aligning the positions to steps in computation time, they generate a sequence of hidden\nstates ht, as a function of the previous hidden state ht1 and the input for position t. This inherently\nsequential nature precludes parallelization within training examples, which becomes critical at longer\nsequence lengths, as memory constraints limit batching across examples. Recent work has achieved\nsignificant improvements in computational efficiency through factorization tricks [21] and conditional\ncomputation [32], while also improving model performance in case of the latter. The fundamental\nconstraint of sequential computation, however, remains.\nAttention mechanisms have become an integral part of compelling sequence modeling and transduc-\ntion models in various tasks, allowing modeling of dependencies without regard to their distance in\nthe input or output sequences [2, 19]. In all but a few cases [27], however, such attention mechanisms\nare used in conjunction with a recurrent network.\nIn this work we propose the Transformer, a model architecture eschewing recurrence and instead\nrelying entirely on an attention mechanism to draw global dependencies between input and output.\nThe Transformer allows for significantly more parallelization and can reach a new state of the art in\ntranslation quality after being trained for as little as twelve hours on eight P100 GPUs.\n2\nBackground\nThe goal of reducing sequential computation also forms the foundation of the Extended Neural GPU\n[16], ByteNet [18] and ConvS2S [9], all of which use convolutional neural networks as basic building\nblock, computing hidden representations in parallel for all input and output positions. In these models,\nthe number of operations required to relate signals from two arbitrary input or output positions grows\nin the distance between positions, linearly for ConvS2S and logarithmically for ByteNet. This makes\nit more difficult to learn dependencies between distant positions [12]. In the Transformer this is\nreduced to a constant number of operations, albeit at the cost of reduced effective resolution due\nto averaging attention-weighted positions, an effect we counteract with Multi-Head Attention as\ndescribed in section 3.2.\nSelf-attention, sometimes called intra-attention is an attention mechanism relating different positions\nof a single sequence in order to compute a representation of the sequence. Self-attention has been\nused successfully in a variety of tasks including reading comprehension, abstractive summarization,\ntextual entailment and learning task-independent sentence representations [4, 27, 28, 22].\nEnd-to-end memory networks are based on a recurrent attention mechanism instead of sequence-\naligned recurrence and have been shown to perform well on simple-language question answering and\nlanguage modeling tasks [34].\nTo the best of our knowledge, however, the Transformer is the first transduction model relying\nentirely on self-attention to compute representations of its input and output without using sequence-\naligned RNNs or convolution. In the following sections, we will describe the Transformer, motivate\nself-attention and discuss its advantages over models such as [17, 18] and [9].\n3\nModel Architecture\nMost competitive neural sequence transduction models have an encoder-decoder structure [5, 2, 35].\nHere, the encoder maps an input sequence of symbol representations (x1, ..., xn) to a sequence\nof continuous representations z = (z1, ..., zn). Given z, the decoder then generates an output\nsequence (y1, ..., ym) of symbols one element at a time. At each step the model is auto-regressive\n[10], consuming the previously generated symbols as additional input when generating the next.\n2\n\n\n## PDF page 3\n\nFigure 1: The Transformer - model architecture.\nThe Transformer follows this overall architecture using stacked self-attention and point-wise, fully\nconnected layers for both the encoder and decoder, shown in the left and right halves of Figure 1,\nrespectively.\n3.1\nEncoder and Decoder Stacks\nEncoder:\nThe encoder is composed of a stack of N = 6 identical layers. Each layer has two\nsub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, position-\nwise fully connected feed-forward network. We employ a residual connection [11] around each of\nthe two sub-layers, followed by layer normalization [1]. That is, the output of each sub-layer is\nLayerNorm(x + Sublayer(x)), where Sublayer(x) is the function implemented by the sub-layer\nitself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding\nlayers, produce outputs of dimension dmodel = 512.\nDecoder:\nThe decoder is also composed of a stack of N = 6 identical layers. In addition to the two\nsub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head\nattention over the output of the encoder stack. Similar to the encoder, we employ residual connections\naround each of the sub-layers, followed by layer normalization. We also modify the self-attention\nsub-layer in the decoder stack to prevent positions from attending to subsequent positions. This\nmasking, combined with fact that the output embeddings are offset by one position, ensures that the\npredictions for position i can depend only on the known outputs at positions less than i.\n3.2\nAttention\nAn attention function can be described as mapping a query and a set of key-value pairs to an output,\nwhere the query, keys, values, and output are all vectors. The output is computed as a weighted sum\n3\n\n\n## PDF page 4\n\nScaled Dot-Product Attention\nMulti-Head Attention\nFigure 2: (left) Scaled Dot-Product Attention. (right) Multi-Head Attention consists of several\nattention layers running in parallel.\nof the values, where the weight assigned to each value is computed by a compatibility function of the\nquery with the corresponding key.\n3.2.1\nScaled Dot-Product Attention\nWe call our particular attention \"Scaled Dot-Product Attention\" (Figure 2). The input consists of\nqueries and keys of dimension dk, and values of dimension dv. We compute the dot products of the\nquery with all keys, divide each by √dk, and apply a softmax function to obtain the weights on the\nvalues.\nIn practice, we compute the attention function on a set of queries simultaneously, packed together\ninto a matrix Q. The keys and values are also packed together into matrices K and V . We compute\nthe matrix of outputs as:\nAttention(Q, K, V ) = softmax(QKT\n√dk\n)V\n(1)\nThe two most commonly used attention functions are additive attention [2], and dot-product (multi-\nplicative) attention. Dot-product attention is identical to our algorithm, except for the scaling factor\nof\n1\n√dk . Additive attention computes the compatibility function using a feed-forward network with\na single hidden layer. While the two are similar in theoretical complexity, dot-product attention is\nmuch faster and more space-efficient in practice, since it can be implemented using highly optimized\nmatrix multiplication code.\nWhile for small values of dk the two mechanisms perform similarly, additive attention outperforms\ndot product attention without scaling for larger values of dk [3]. We suspect that for large values of\ndk, the dot products grow large in magnitude, pushing the softmax function into regions where it has\nextremely small gradients 4. To counteract this effect, we scale the dot products by\n1\n√dk .\n3.2.2\nMulti-Head Attention\nInstead of performing a single attention function with dmodel-dimensional keys, values and queries,\nwe found it beneficial to linearly project the queries, keys and values h times with different, learned\nlinear projections to dk, dk and dv dimensions, respectively. On each of these projected versions of\nqueries, keys and values we then perform the attention function in parallel, yielding dv-dimensional\n4To illustrate why the dot products get large, assume that the components of q and k are independent random\nvariables with mean 0 and variance 1. Then their dot product, q · k = Pdk\ni=1 qiki, has mean 0 and variance dk.\n4\n\n\n## PDF page 5\n\noutput values. These are concatenated and once again projected, resulting in the final values, as\ndepicted in Figure 2.\nMulti-head attention allows the model to jointly attend to information from different representation\nsubspaces at different positions. With a single attention head, averaging inhibits this.\nMultiHead(Q, K, V ) = Concat(head1, ..., headh)W O\nwhere headi = Attention(QW Q\ni , KW K\ni , V W V\ni )\nWhere the projections are parameter matrices W Q\ni\n∈Rdmodel×dk, W K\ni\n∈Rdmodel×dk, W V\ni\n∈Rdmodel×dv\nand W O ∈Rhdv×dmodel.\nIn this work we employ h = 8 parallel attention layers, or heads. For each of these we use\ndk = dv = dmodel/h = 64. Due to the reduced dimension of each head, the total computational cost\nis similar to that of single-head attention with full dimensionality.\n3.2.3\nApplications of Attention in our Model\nThe Transformer uses multi-head attention in three different ways:\n• In \"encoder-decoder attention\" layers, the queries come from the previous decoder layer,\nand the memory keys and values come from the output of the encoder. This allows every\nposition in the decoder to attend over all positions in the input sequence. This mimics the\ntypical encoder-decoder attention mechanisms in sequence-to-sequence models such as\n[38, 2, 9].\n• The encoder contains self-attention layers. In a self-attention layer all of the keys, values\nand queries come from the same place, in this case, the output of the previous layer in the\nencoder. Each position in the encoder can attend to all positions in the previous layer of the\nencoder.\n• Similarly, self-attention layers in the decoder allow each position in the decoder to attend to\nall positions in the decoder up to and including that position. We need to prevent leftward\ninformation flow in the decoder to preserve the auto-regressive property. We implement this\ninside of scaled dot-product attention by masking out (setting to −∞) all values in the input\nof the softmax which correspond to illegal connections. See Figure 2.\n3.3\nPosition-wise Feed-Forward Networks\nIn addition to attention sub-layers, each of the layers in our encoder and decoder contains a fully\nconnected feed-forward network, which is applied to each position separately and identically. This\nconsists of two linear transformations with a ReLU activation in between.\nFFN(x) = max(0, xW1 + b1)W2 + b2\n(2)\nWhile the linear transformations are the same across different positions, they use different parameters\nfrom layer to layer. Another way of describing this is as two convolutions with kernel size 1.\nThe dimensionality of input and output is dmodel = 512, and the inner-layer has dimensionality\ndff = 2048.\n3.4\nEmbeddings and Softmax\nSimilarly to other sequence transduction models, we use learned embeddings to convert the input\ntokens and output tokens to vectors of dimension dmodel. We also use the usual learned linear transfor-\nmation and softmax function to convert the decoder output to predicted next-token probabilities. In\nour model, we share the same weight matrix between the two embedding layers and the pre-softmax\nlinear transformation, similar to [30]. In the embedding layers, we multiply those weights by √dmodel.\n5\n\n\n## PDF page 6\n\nTable 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations\nfor different layer types. n is the sequence length, d is the representation dimension, k is the kernel\nsize of convolutions and r the size of the neighborhood in restricted self-attention.\nLayer Type\nComplexity per Layer\nSequential\nMaximum Path Length\nOperations\nSelf-Attention\nO(n2 · d)\nO(1)\nO(1)\nRecurrent\nO(n · d2)\nO(n)\nO(n)\nConvolutional\nO(k · n · d2)\nO(1)\nO(logk(n))\nSelf-Attention (restricted)\nO(r · n · d)\nO(1)\nO(n/r)\n3.5\nPositional Encoding\nSince our model contains no recurrence and no convolution, in order for the model to make use of the\norder of the sequence, we must inject some information about the relative or absolute position of the\ntokens in the sequence. To this end, we add \"positional encodings\" to the input embeddings at the\nbottoms of the encoder and decoder stacks. The positional encodings have the same dimension dmodel\nas the embeddings, so that the two can be summed. There are many choices of positional encodings,\nlearned and fixed [9].\nIn this work, we use sine and cosine functions of different frequencies:\nPE(pos,2i) = sin(pos/100002i/dmodel)\nPE(pos,2i+1) = cos(pos/100002i/dmodel)\nwhere pos is the position and i is the dimension. That is, each dimension of the positional encoding\ncorresponds to a sinusoid. The wavelengths form a geometric progression from 2π to 10000 · 2π. We\nchose this function because we hypothesized it would allow the model to easily learn to attend by\nrelative positions, since for any fixed offset k, PEpos+k can be represented as a linear function of\nPEpos.\nWe also experimented with using learned positional embeddings [9] instead, and found that the two\nversions produced nearly identical results (see Table 3 row (E)). We chose the sinusoidal version\nbecause it may allow the model to extrapolate to sequence lengths longer than the ones encountered\nduring training.\n4\nWhy Self-Attention\nIn this section we compare various aspects of self-attention layers to the recurrent and convolu-\ntional layers commonly used for mapping one variable-length sequence of symbol representations\n(x1, ..., xn) to another sequence of equal length (z1, ..., zn), with xi, zi ∈Rd, such as a hidden\nlayer in a typical sequence transduction encoder or decoder. Motivating our use of self-attention we\nconsider three desiderata.\nOne is the total computational complexity per layer. Another is the amount of computation that can\nbe parallelized, as measured by the minimum number of sequential operations required.\nThe third is the path length between long-range dependencies in the network. Learning long-range\ndependencies is a key challenge in many sequence transduction tasks. One key factor affecting the\nability to learn such dependencies is the length of the paths forward and backward signals have to\ntraverse in the network. The shorter these paths between any combination of positions in the input\nand output sequences, the easier it is to learn long-range dependencies [12]. Hence we also compare\nthe maximum path length between any two input and output positions in networks composed of the\ndifferent layer types.\nAs noted in Table 1, a self-attention layer connects all positions with a constant number of sequentially\nexecuted operations, whereas a recurrent layer requires O(n) sequential operations. In terms of\ncomputational complexity, self-attention layers are faster than recurrent layers when the sequence\n6\n\n\n## PDF page 7\n\nlength n is smaller than the representation dimensionality d, which is most often the case with\nsentence representations used by state-of-the-art models in machine translations, such as word-piece\n[38] and byte-pair [31] representations. To improve computational performance for tasks involving\nvery long sequences, self-attention could be restricted to considering only a neighborhood of size r in\nthe input sequence centered around the respective output position. This would increase the maximum\npath length to O(n/r). We plan to investigate this approach further in future work.\nA single convolutional layer with kernel width k < n does not connect all pairs of input and output\npositions. Doing so requires a stack of O(n/k) convolutional layers in the case of contiguous kernels,\nor O(logk(n)) in the case of dilated convolutions [18], increasing the length of the longest paths\nbetween any two positions in the network. Convolutional layers are generally more expensive than\nrecurrent layers, by a factor of k. Separable convolutions [6], however, decrease the complexity\nconsiderably, to O(k · n · d + n · d2). Even with k = n, however, the complexity of a separable\nconvolution is equal to the combination of a self-attention layer and a point-wise feed-forward layer,\nthe approach we take in our model.\nAs side benefit, self-attention could yield more interpretable models. We inspect attention distributions\nfrom our models and present and discuss examples in the appendix. Not only do individual attention\nheads clearly learn to perform different tasks, many appear to exhibit behavior related to the syntactic\nand semantic structure of the sentences.\n5\nTraining\nThis section describes the training regime for our models.\n5.1\nTraining Data and Batching\nWe trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million\nsentence pairs. Sentences were encoded using byte-pair encoding [3], which has a shared source-\ntarget vocabulary of about 37000 tokens. For English-French, we used the significantly larger WMT\n2014 English-French dataset consisting of 36M sentences and split tokens into a 32000 word-piece\nvocabulary [38]. Sentence pairs were batched together by approximate sequence length. Each training\nbatch contained a set of sentence pairs containing approximately 25000 source tokens and 25000\ntarget tokens.\n5.2\nHardware and Schedule\nWe trained our models on one machine with 8 NVIDIA P100 GPUs. For our base models using\nthe hyperparameters described throughout the paper, each training step took about 0.4 seconds. We\ntrained the base models for a total of 100,000 steps or 12 hours. For our big models,(described on the\nbottom line of table 3), step time was 1.0 seconds. The big models were trained for 300,000 steps\n(3.5 days).\n5.3\nOptimizer\nWe used the Adam optimizer [20] with β1 = 0.9, β2 = 0.98 and ϵ = 109. We varied the learning\nrate over the course of training, according to the formula:\nlrate = d0.5\nmodel · min(step_num0.5, step_num · warmup_steps1.5)\n(3)\nThis corresponds to increasing the learning rate linearly for the first warmup_steps training steps,\nand decreasing it thereafter proportionally to the inverse square root of the step number. We used\nwarmup_steps = 4000.\n5.4\nRegularization\nWe employ three types of regularization during training:\n7\n\n\n## PDF page 8\n\nTable 2: The Transformer achieves better BLEU scores than previous state-of-the-art models on the\nEnglish-to-German and English-to-French newstest2014 tests at a fraction of the training cost.\nModel\nBLEU\nTraining Cost (FLOPs)\nEN-DE\nEN-FR\nEN-DE\nEN-FR\nByteNet [18]\n23.75\nDeep-Att + PosUnk [39]\n39.2\n1.0 · 1020\nGNMT + RL [38]\n24.6\n39.92\n2.3 · 1019\n1.4 · 1020\nConvS2S [9]\n25.16\n40.46\n9.6 · 1018\n1.5 · 1020\nMoE [32]\n26.03\n40.56\n2.0 · 1019\n1.2 · 1020\nDeep-Att + PosUnk Ensemble [39]\n40.4\n8.0 · 1020\nGNMT + RL Ensemble [38]\n26.30\n41.16\n1.8 · 1020\n1.1 · 1021\nConvS2S Ensemble [9]\n26.36\n41.29\n7.7 · 1019\n1.2 · 1021\nTransformer (base model)\n27.3\n38.1\n3.3 · 1018\nTransformer (big)\n28.4\n41.8\n2.3 · 1019\nResidual Dropout\nWe apply dropout [33] to the output of each sub-layer, before it is added to the\nsub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the\npositional encodings in both the encoder and decoder stacks. For the base model, we use a rate of\nPdrop = 0.1.\nLabel Smoothing\nDuring training, we employed label smoothing of value ϵls = 0.1 [36]. This\nhurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.\n6\nResults\n6.1\nMachine Translation\nOn the WMT 2014 English-to-German translation task, the big transformer model (Transformer (big)\nin Table 2) outperforms the best previously reported models (including ensembles) by more than 2.0\nBLEU, establishing a new state-of-the-art BLEU score of 28.4. The configuration of this model is\nlisted in the bottom line of Table 3. Training took 3.5 days on 8 P100 GPUs. Even our base model\nsurpasses all previously published models and ensembles, at a fraction of the training cost of any of\nthe competitive models.\nOn the WMT 2014 English-to-French translation task, our big model achieves a BLEU score of 41.0,\noutperforming all of the previously published single models, at less than 1/4 the training cost of the\nprevious state-of-the-art model. The Transformer (big) model trained for English-to-French used\ndropout rate Pdrop = 0.1, instead of 0.3.\nFor the base models, we used a single model obtained by averaging the last 5 checkpoints, which\nwere written at 10-minute intervals. For the big models, we averaged the last 20 checkpoints. We\nused beam search with a beam size of 4 and length penalty α = 0.6 [38]. These hyperparameters\nwere chosen after experimentation on the development set. We set the maximum output length during\ninference to input length + 50, but terminate early when possible [38].\nTable 2 summarizes our results and compares our translation quality and training costs to other model\narchitectures from the literature. We estimate the number of floating point operations used to train a\nmodel by multiplying the training time, the number of GPUs used, and an estimate of the sustained\nsingle-precision floating-point capacity of each GPU 5.\n6.2\nModel Variations\nTo evaluate the importance of different components of the Transformer, we varied our base model\nin different ways, measuring the change in performance on English-to-German translation on the\n5We used values of 2.8, 3.7, 6.0 and 9.5 TFLOPS for K80, K40, M40 and P100, respectively.\n8\n\n\n## PDF page 9\n\nTable 3: Variations on the Transformer architecture. Unlisted values are identical to those of the base\nmodel. All metrics are on the English-to-German translation development set, newstest2013. Listed\nperplexities are per-wordpiece, according to our byte-pair encoding, and should not be compared to\nper-word perplexities.\nN\ndmodel\ndff\nh\ndk\ndv\nPdrop\nϵls\ntrain\nPPL\nBLEU\nparams\nsteps\n(dev)\n(dev)\n×106\nbase\n6\n512\n2048\n8\n64\n64\n0.1\n0.1\n100K\n4.92\n25.8\n65\n(A)\n1\n512\n512\n5.29\n24.9\n4\n128\n128\n5.00\n25.5\n16\n32\n32\n4.91\n25.8\n32\n16\n16\n5.01\n25.4\n(B)\n16\n5.16\n25.1\n58\n32\n5.01\n25.4\n60\n(C)\n2\n6.11\n23.7\n36\n4\n5.19\n25.3\n50\n8\n4.88\n25.5\n80\n256\n32\n32\n5.75\n24.5\n28\n1024\n128\n128\n4.66\n26.0\n168\n1024\n5.12\n25.4\n53\n4096\n4.75\n26.2\n90\n(D)\n0.0\n5.77\n24.6\n0.2\n4.95\n25.5\n0.0\n4.67\n25.3\n0.2\n5.47\n25.7\n(E)\npositional embedding instead of sinusoids\n4.92\n25.7\nbig\n6\n1024\n4096\n16\n0.3\n300K\n4.33\n26.4\n213\ndevelopment set, newstest2013. We used beam search as described in the previous section, but no\ncheckpoint averaging. We present these results in Table 3.\nIn Table 3 rows (A), we vary the number of attention heads and the attention key and value dimensions,\nkeeping the amount of computation constant, as described in Section 3.2.2. While single-head\nattention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.\nIn Table 3 rows (B), we observe that reducing the attention key size dk hurts model quality. This\nsuggests that determining compatibility is not easy and that a more sophisticated compatibility\nfunction than dot product may be beneficial. We further observe in rows (C) and (D) that, as expected,\nbigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our\nsinusoidal positional encoding with learned positional embeddings [9], and observe nearly identical\nresults to the base model.\n6.3\nEnglish Constituency Parsing\nTo evaluate if the Transformer can generalize to other tasks we performed experiments on English\nconstituency parsing. This task presents specific challenges: the output is subject to strong structural\nconstraints and is significantly longer than the input. Furthermore, RNN sequence-to-sequence\nmodels have not been able to attain state-of-the-art results in small-data regimes [37].\nWe trained a 4-layer transformer with dmodel = 1024 on the Wall Street Journal (WSJ) portion of the\nPenn Treebank [25], about 40K training sentences. We also trained it in a semi-supervised setting,\nusing the larger high-confidence and BerkleyParser corpora from with approximately 17M sentences\n[37]. We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens\nfor the semi-supervised setting.\nWe performed only a small number of experiments to select the dropout, both attention and residual\n(section 5.4), learning rates and beam size on the Section 22 development set, all other parameters\nremained unchanged from the English-to-German base translation model. During inference, we\n9\n\n\n## PDF page 10\n\nTable 4: The Transformer generalizes well to English constituency parsing (Results are on Section 23\nof WSJ)\nParser\nTraining\nWSJ 23 F1\nVinyals & Kaiser el al. (2014) [37]\nWSJ only, discriminative\n88.3\nPetrov et al. (2006) [29]\nWSJ only, discriminative\n90.4\nZhu et al. (2013) [40]\nWSJ only, discriminative\n90.4\nDyer et al. (2016) [8]\nWSJ only, discriminative\n91.7\nTransformer (4 layers)\nWSJ only, discriminative\n91.3\nZhu et al. (2013) [40]\nsemi-supervised\n91.3\nHuang & Harper (2009) [14]\nsemi-supervised\n91.3\nMcClosky et al. (2006) [26]\nsemi-supervised\n92.1\nVinyals & Kaiser el al. (2014) [37]\nsemi-supervised\n92.1\nTransformer (4 layers)\nsemi-supervised\n92.7\nLuong et al. (2015) [23]\nmulti-task\n93.0\nDyer et al. (2016) [8]\ngenerative\n93.3\nincreased the maximum output length to input length + 300. We used a beam size of 21 and α = 0.3\nfor both WSJ only and the semi-supervised setting.\nOur results in Table 4 show that despite the lack of task-specific tuning our model performs sur-\nprisingly well, yielding better results than all previously reported models with the exception of the\nRecurrent Neural Network Grammar [8].\nIn contrast to RNN sequence-to-sequence models [37], the Transformer outperforms the Berkeley-\nParser [29] even when training only on the WSJ training set of 40K sentences.\n7\nConclusion\nIn this work, we presented the Transformer, the first sequence transduction model based entirely on\nattention, replacing the recurrent layers most commonly used in encoder-decoder architectures with\nmulti-headed self-attention.\nFor translation tasks, the Transformer can be trained significantly faster than architectures based\non recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014\nEnglish-to-French translation tasks, we achieve a new state of the art. In the former task our best\nmodel outperforms even all previously reported ensembles.\nWe are excited about the future of attention-based models and plan to apply them to other tasks. We\nplan to extend the Transformer to problems involving input and output modalities other than text and\nto investigate local, restricted attention mechanisms to efficiently handle large inputs and outputs\nsuch as images, audio and video. Making generation less sequential is another research goals of ours.\nThe code we used to train and evaluate our models is available at https://github.com/\ntensorflow/tensor2tensor.\nAcknowledgements\nWe are grateful to Nal Kalchbrenner and Stephan Gouws for their fruitful\ncomments, corrections and inspiration.\nReferences\n[1] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint\narXiv:1607.06450, 2016.\n[2] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly\nlearning to align and translate. CoRR, abs/1409.0473, 2014.\n[3] Denny Britz, Anna Goldie, Minh-Thang Luong, and Quoc V. Le. Massive exploration of neural\nmachine translation architectures. CoRR, abs/1703.03906, 2017.\n[4] Jianpeng Cheng, Li Dong, and Mirella Lapata. Long short-term memory-networks for machine\nreading. arXiv preprint arXiv:1601.06733, 2016.\n10\n\n\n## PDF page 11\n\n[5] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk,\nand Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical\nmachine translation. CoRR, abs/1406.1078, 2014.\n[6] Francois Chollet. Xception: Deep learning with depthwise separable convolutions. arXiv\npreprint arXiv:1610.02357, 2016.\n[7] Junyoung Chung, Çaglar Gülçehre, Kyunghyun Cho, and Yoshua Bengio. Empirical evaluation\nof gated recurrent neural networks on sequence modeling. CoRR, abs/1412.3555, 2014.\n[8] Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, and Noah A. Smith. Recurrent neural\nnetwork grammars. In Proc. of NAACL, 2016.\n[9] Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. Convolu-\ntional sequence to sequence learning. arXiv preprint arXiv:1705.03122v2, 2017.\n[10] Alex Graves.\nGenerating sequences with recurrent neural networks.\narXiv preprint\narXiv:1308.0850, 2013.\n[11] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for im-\nage recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern\nRecognition, pages 770778, 2016.\n[12] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber. Gradient flow in\nrecurrent nets: the difficulty of learning long-term dependencies, 2001.\n[13] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation,\n9(8):17351780, 1997.\n[14] Zhongqiang Huang and Mary Harper. Self-training PCFG grammars with latent annotations\nacross languages. In Proceedings of the 2009 Conference on Empirical Methods in Natural\nLanguage Processing, pages 832841. ACL, August 2009.\n[15] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring\nthe limits of language modeling. arXiv preprint arXiv:1602.02410, 2016.\n[16] Łukasz Kaiser and Samy Bengio. Can active memory replace attention? In Advances in Neural\nInformation Processing Systems, (NIPS), 2016.\n[17] Łukasz Kaiser and Ilya Sutskever. Neural GPUs learn algorithms. In International Conference\non Learning Representations (ICLR), 2016.\n[18] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Ko-\nray Kavukcuoglu. Neural machine translation in linear time. arXiv preprint arXiv:1610.10099v2,\n2017.\n[19] Yoon Kim, Carl Denton, Luong Hoang, and Alexander M. Rush. Structured attention networks.\nIn International Conference on Learning Representations, 2017.\n[20] Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.\n[21] Oleksii Kuchaiev and Boris Ginsburg. Factorization tricks for LSTM networks. arXiv preprint\narXiv:1703.10722, 2017.\n[22] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen\nZhou, and Yoshua Bengio. A structured self-attentive sentence embedding. arXiv preprint\narXiv:1703.03130, 2017.\n[23] Minh-Thang Luong, Quoc V. Le, Ilya Sutskever, Oriol Vinyals, and Lukasz Kaiser. Multi-task\nsequence to sequence learning. arXiv preprint arXiv:1511.06114, 2015.\n[24] Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-\nbased neural machine translation. arXiv preprint arXiv:1508.04025, 2015.\n11\n\n\n## PDF page 12\n\n[25] Mitchell P Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. Building a large annotated\ncorpus of english: The penn treebank. Computational linguistics, 19(2):313330, 1993.\n[26] David McClosky, Eugene Charniak, and Mark Johnson. Effective self-training for parsing. In\nProceedings of the Human Language Technology Conference of the NAACL, Main Conference,\npages 152159. ACL, June 2006.\n[27] Ankur Parikh, Oscar Täckström, Dipanjan Das, and Jakob Uszkoreit. A decomposable attention\nmodel. In Empirical Methods in Natural Language Processing, 2016.\n[28] Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive\nsummarization. arXiv preprint arXiv:1705.04304, 2017.\n[29] Slav Petrov, Leon Barrett, Romain Thibaux, and Dan Klein. Learning accurate, compact,\nand interpretable tree annotation. In Proceedings of the 21st International Conference on\nComputational Linguistics and 44th Annual Meeting of the ACL, pages 433440. ACL, July\n2006.\n[30] Ofir Press and Lior Wolf. Using the output embedding to improve language models. arXiv\npreprint arXiv:1608.05859, 2016.\n[31] Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words\nwith subword units. arXiv preprint arXiv:1508.07909, 2015.\n[32] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton,\nand Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts\nlayer. arXiv preprint arXiv:1701.06538, 2017.\n[33] Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdi-\nnov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine\nLearning Research, 15(1):19291958, 2014.\n[34] Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory\nnetworks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors,\nAdvances in Neural Information Processing Systems 28, pages 24402448. Curran Associates,\nInc., 2015.\n[35] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. Sequence to sequence learning with neural\nnetworks. In Advances in Neural Information Processing Systems, pages 31043112, 2014.\n[36] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna.\nRethinking the inception architecture for computer vision. CoRR, abs/1512.00567, 2015.\n[37] Vinyals & Kaiser, Koo, Petrov, Sutskever, and Hinton. Grammar as a foreign language. In\nAdvances in Neural Information Processing Systems, 2015.\n[38] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang\nMacherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Googles neural machine\ntranslation system: Bridging the gap between human and machine translation. arXiv preprint\narXiv:1609.08144, 2016.\n[39] Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. Deep recurrent models with\nfast-forward connections for neural machine translation. CoRR, abs/1606.04199, 2016.\n[40] Muhua Zhu, Yue Zhang, Wenliang Chen, Min Zhang, and Jingbo Zhu. Fast and accurate\nshift-reduce constituent parsing. In Proceedings of the 51st Annual Meeting of the ACL (Volume\n1: Long Papers), pages 434443. ACL, August 2013.\n12\n\n\n## PDF page 13\n\nAttention Visualizations\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nFigure 3: An example of the attention mechanism following long-distance dependencies in the\nencoder self-attention in layer 5 of 6. Many of the attention heads attend to a distant dependency of\nthe verb making, completing the phrase making...more difficult. Attentions here shown only for\nthe word making. Different colors represent different heads. Best viewed in color.\n13\n\n\n## PDF page 14\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 4: Two attention heads, also in layer 5 of 6, apparently involved in anaphora resolution. Top:\nFull attentions for head 5. Bottom: Isolated attentions from just the word its for attention heads 5\nand 6. Note that the attentions are very sharp for this word.\n14\n\n\n## PDF page 15\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 5: Many of the attention heads exhibit behaviour that seems related to the structure of the\nsentence. We give two such examples above, from two different heads from the encoder self-attention\nat layer 5 of 6. The heads clearly learned to perform different tasks.\n15\n\n\n可直接引用的图表文件:\n- paper_figure_1_transformer.pngFigure 1 from PDF page 3: The Transformer model architecture.\n- paper_figure_3_long_distance.pngFigure 3 from PDF page 13: Encoder self-attention following long-distance dependencies.\n- paper_figure_4_anaphora.pngFigure 4 from PDF page 14: Attention heads involved in anaphora resolution.\n\n请生成一版 10-20 页的完整初稿。内容必须忠于论文,至少引用上面列出的三张原论文图,并覆盖问题、Transformer 架构、注意力机制、训练、主要实验、局限和结论。不要复制长段原文;每页保持听众可读的信息密度。生成完整的 slides.md。"
}
],
"temperature": 0.3
},
"response": {
"id": "021785385449917fba75098d9ee455dd9478ca57adcb3fd4f2b78",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "```markdown\n---\ntheme: default\n---\n\n# Attention Is All You Need\n## A Revolutionary Architecture for Sequence Transduction\n\nAshish Vaswani et al. \nNIPS 2017\n\n---\n\n## Problem Statement\n\n- Traditional sequence models rely on RNNs or CNNs\n- RNNs have inherent sequential computation (hard to parallelize)\n- CNNs require multiple layers to capture long-range dependencies\n- Both have increasing path lengths between distant positions\n\n**Key Insight**: Replace recurrence and convolution with attention mechanisms\n\n---\n\n## The Transformer: Model Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n- Encoder-decoder structure with stacked self-attention layers\n- No recurrence or convolution\n- Significantly more parallelizable\n\n---\n\n## Encoder Stack\n\n- 6 identical layers\n- Each layer has two sub-layers:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization around each sub-layer\n- Output dimension: d<sub>model</sub> = 512\n\n---\n\n## Decoder Stack\n\n- 6 identical layers\n- Three sub-layers per layer:\n 1. Masked multi-head self-attention\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Masking prevents attending to future positions\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- Queries (Q), Keys (K), Values (V) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradient vanishing\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-40 mx-auto\" />\n\n- Project Q, K, V h times with different linear projections\n- Perform attention in parallel on each projection\n- Concatenate results and project again\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**:\n - Queries from decoder, keys/values from encoder\n - Allows decoder to attend to all input positions\n\n2. **Encoder self-attention**:\n - All Q, K, V from previous encoder layer\n - Each position attends to all positions\n\n3. **Decoder self-attention**:\n - All Q, K, V from previous decoder layer\n - Masked to prevent attending to future positions\n\n---\n\n## Positional Encoding\n\nSince model has no recurrence/convolution, we add positional information:\n\n$$PE_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$PE_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Sinusoidal functions with varying frequencies\n- Allows model to learn relative position information\n- Performed as well as learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------|------------|----------------|-----------------|\n| Self-Attention | O(n²·d) | O(1) | O(1) |\n| Recurrent | O(n·d²) | O(n) | O(n) |\n| Convolutional | O(k·n·d²) | O(1) | O(logₖn) |\n\n- Better parallelization than RNNs\n- Shorter path lengths than CNNs/RNNs\n- More interpretable attention patterns\n\n---\n\n## Training Details\n\n- **Datasets**: WMT 2014 EN-DE (4.5M) and EN-FR (36M)\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Optimizer**: Adam (β₁=0.9, β₂=0.98, ϵ=10⁻⁹)\n- **Learning Rate**: $lrate = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step_num}^{-0.5}, \\text{step_num} \\cdot \\text{warmup_steps}^{-1.5})$\n- **Regularization**: Dropout (P=0.1), Label Smoothing (ϵ=0.1)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|------------------------|\n| GNMT + RL | 24.6 | 39.92 | 2.3·10¹⁹ |\n| ConvS2S | 25.16 | 40.46 | 9.6·10¹⁸ |\n| Transformer (base) | 27.3 | 38.1 | 3.3·10¹⁸ |\n| **Transformer (big)** | **28.4** | **41.8** | **2.3·10¹⁹** |\n\n- Transformer (big) outperforms all previous state-of-the-art\n- Achieves new SOTA with significantly less training cost\n\n---\n\n## Model Variations\n\n| Configuration | Dev PPL | Dev BLEU |\n|---------------|---------|----------|\n| Base | 4.92 | 25.8 |\n| 1 attention head | 5.29 | 24.9 |\n| 32 attention heads | 5.01 | 25.4 |\n| No dropout | 5.77 | 24.6 |\n| Learned positional embeddings | 4.92 | 25.7 |\n| Big model | 4.33 | 26.4 |\n\n- Multiple attention heads improve performance\n- Dropout is crucial for generalization\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Achieves competitive results with minimal task-specific modifications\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n- Attention heads follow distant dependencies\n- Example: Verb \"making\" attends to \"more difficult\"\n- Different colors represent different attention heads\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n- Some heads specialize in resolving pronouns\n- Example: \"its\" clearly attends to \"The Law\"\n- Sharp attention patterns for coreference resolution\n\n---\n\n## Limitations and Future Work\n\n### Limitations:\n- High memory consumption with long sequences (O(n²))\n- Still generates output sequentially\n\n### Future Work:\n- Local, restricted attention mechanisms for large inputs\n- Extend to other modalities (images, audio, video)\n- Make generation less sequential\n- Explore more efficient attention variants\n\n---\n\n## Conclusion\n\n- Transformer is the first transduction model based entirely on attention\n- Replaces RNNs/CNNs with multi-headed self-attention\n- Significantly faster training with better parallelization\n- Achieves new state-of-the-art in machine translation\n- Generalizes well to other sequence tasks like constituency parsing\n\n**Code**: https://github.com/tensorflow/tensor2tensor\n\n---\n\n## Thank You!\n```"
},
"usage": {
"prompt_tokens": 11758,
"completion_tokens": 2188,
"total_tokens": 13946,
"cached_prompt_tokens": 0
}
},
{
"meter": "SingleAgent(自审, 图片累积)",
"called_at_utc": "2026-07-30T04:25:58.947603+00:00",
"latency_s": 50.559,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名擅长把学术论文转化为演示文稿的 Proposer Agent。\n你用 Slidev 框架(Markdown + HTML)编写 PPT 源码 slides.md。\n\nSlidev 语法要点:\n- 文件开头是 YAML frontmatter--- 包裹),设置 theme: default。\n- 用单独一行的 `---`(前后空行)分隔每一页幻灯片。\n- 首页通常放标题、作者、会议。\n- 引用图片用 markdown![说明](/图片文件名.png),可用 HTML 控制尺寸,\n 例如 <img src=\"/speedup_bar.png\" class=\"h-60 mx-auto\" />。\n- 可用 Windi/Uno CSS 工具类控制排版(如 text-sm、grid grid-cols-2 gap-4)。\n\n要求:\n- 最终生成 10-20 页,覆盖论文的标题、背景/动机、方法、实验结果、局限与结论。\n- 至少在 3 页中使用提供的图表/表格,且图文匹配。\n- 每页信息量适中、不要塞太多字,宁可拆页也不要溢出。\n- 只输出 slides.md 的完整内容,用 ```markdown 代码块包裹,不要额外解释。\n\n此外,你还要**自我审查**:当收到自己 PPT 的渲染截图时,先在心里按下列标准找出问题\n(文字溢出、内容拥挤、图片尺寸、可读性、布局),再据此输出修订后的完整 slides.md。"
},
{
"role": "user",
"content": "以下是论文全文(Markdown):\n\n# Attention Is All You Need\n\nAuthors: Ashish Vaswani et al.\n\n\n## PDF page 1\n\nProvided proper attribution is provided, Google hereby grants permission to\nreproduce the tables and figures in this paper solely for use in journalistic or\nscholarly works.\nAttention Is All You Need\nAshish Vaswani\nGoogle Brain\navaswani@google.com\nNoam Shazeer\nGoogle Brain\nnoam@google.com\nNiki Parmar\nGoogle Research\nnikip@google.com\nJakob Uszkoreit\nGoogle Research\nusz@google.com\nLlion Jones\nGoogle Research\nllion@google.com\nAidan N. Gomez∗†\nUniversity of Toronto\naidan@cs.toronto.edu\nŁukasz Kaiser\nGoogle Brain\nlukaszkaiser@google.com\nIllia Polosukhin∗‡\nillia.polosukhin@gmail.com\nAbstract\nThe dominant sequence transduction models are based on complex recurrent or\nconvolutional neural networks that include an encoder and a decoder. The best\nperforming models also connect the encoder and decoder through an attention\nmechanism. We propose a new simple network architecture, the Transformer,\nbased solely on attention mechanisms, dispensing with recurrence and convolutions\nentirely. Experiments on two machine translation tasks show these models to\nbe superior in quality while being more parallelizable and requiring significantly\nless time to train. Our model achieves 28.4 BLEU on the WMT 2014 English-\nto-German translation task, improving over the existing best results, including\nensembles, by over 2 BLEU. On the WMT 2014 English-to-French translation task,\nour model establishes a new single-model state-of-the-art BLEU score of 41.8 after\ntraining for 3.5 days on eight GPUs, a small fraction of the training costs of the\nbest models from the literature. We show that the Transformer generalizes well to\nother tasks by applying it successfully to English constituency parsing both with\nlarge and limited training data.\nEqual contribution. Listing order is random. Jakob proposed replacing RNNs with self-attention and started\nthe effort to evaluate this idea. Ashish, with Illia, designed and implemented the first Transformer models and\nhas been crucially involved in every aspect of this work. Noam proposed scaled dot-product attention, multi-head\nattention and the parameter-free position representation and became the other person involved in nearly every\ndetail. Niki designed, implemented, tuned and evaluated countless model variants in our original codebase and\ntensor2tensor. Llion also experimented with novel model variants, was responsible for our initial codebase, and\nefficient inference and visualizations. Lukasz and Aidan spent countless long days designing various parts of and\nimplementing tensor2tensor, replacing our earlier codebase, greatly improving results and massively accelerating\nour research.\n†Work performed while at Google Brain.\n‡Work performed while at Google Research.\n31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA.\narXiv:1706.03762v7 [cs.CL] 2 Aug 2023\n\n\n## PDF page 2\n\n1\nIntroduction\nRecurrent neural networks, long short-term memory [13] and gated recurrent [7] neural networks\nin particular, have been firmly established as state of the art approaches in sequence modeling and\ntransduction problems such as language modeling and machine translation [35, 2, 5]. Numerous\nefforts have since continued to push the boundaries of recurrent language models and encoder-decoder\narchitectures [38, 24, 15].\nRecurrent models typically factor computation along the symbol positions of the input and output\nsequences. Aligning the positions to steps in computation time, they generate a sequence of hidden\nstates ht, as a function of the previous hidden state ht1 and the input for position t. This inherently\nsequential nature precludes parallelization within training examples, which becomes critical at longer\nsequence lengths, as memory constraints limit batching across examples. Recent work has achieved\nsignificant improvements in computational efficiency through factorization tricks [21] and conditional\ncomputation [32], while also improving model performance in case of the latter. The fundamental\nconstraint of sequential computation, however, remains.\nAttention mechanisms have become an integral part of compelling sequence modeling and transduc-\ntion models in various tasks, allowing modeling of dependencies without regard to their distance in\nthe input or output sequences [2, 19]. In all but a few cases [27], however, such attention mechanisms\nare used in conjunction with a recurrent network.\nIn this work we propose the Transformer, a model architecture eschewing recurrence and instead\nrelying entirely on an attention mechanism to draw global dependencies between input and output.\nThe Transformer allows for significantly more parallelization and can reach a new state of the art in\ntranslation quality after being trained for as little as twelve hours on eight P100 GPUs.\n2\nBackground\nThe goal of reducing sequential computation also forms the foundation of the Extended Neural GPU\n[16], ByteNet [18] and ConvS2S [9], all of which use convolutional neural networks as basic building\nblock, computing hidden representations in parallel for all input and output positions. In these models,\nthe number of operations required to relate signals from two arbitrary input or output positions grows\nin the distance between positions, linearly for ConvS2S and logarithmically for ByteNet. This makes\nit more difficult to learn dependencies between distant positions [12]. In the Transformer this is\nreduced to a constant number of operations, albeit at the cost of reduced effective resolution due\nto averaging attention-weighted positions, an effect we counteract with Multi-Head Attention as\ndescribed in section 3.2.\nSelf-attention, sometimes called intra-attention is an attention mechanism relating different positions\nof a single sequence in order to compute a representation of the sequence. Self-attention has been\nused successfully in a variety of tasks including reading comprehension, abstractive summarization,\ntextual entailment and learning task-independent sentence representations [4, 27, 28, 22].\nEnd-to-end memory networks are based on a recurrent attention mechanism instead of sequence-\naligned recurrence and have been shown to perform well on simple-language question answering and\nlanguage modeling tasks [34].\nTo the best of our knowledge, however, the Transformer is the first transduction model relying\nentirely on self-attention to compute representations of its input and output without using sequence-\naligned RNNs or convolution. In the following sections, we will describe the Transformer, motivate\nself-attention and discuss its advantages over models such as [17, 18] and [9].\n3\nModel Architecture\nMost competitive neural sequence transduction models have an encoder-decoder structure [5, 2, 35].\nHere, the encoder maps an input sequence of symbol representations (x1, ..., xn) to a sequence\nof continuous representations z = (z1, ..., zn). Given z, the decoder then generates an output\nsequence (y1, ..., ym) of symbols one element at a time. At each step the model is auto-regressive\n[10], consuming the previously generated symbols as additional input when generating the next.\n2\n\n\n## PDF page 3\n\nFigure 1: The Transformer - model architecture.\nThe Transformer follows this overall architecture using stacked self-attention and point-wise, fully\nconnected layers for both the encoder and decoder, shown in the left and right halves of Figure 1,\nrespectively.\n3.1\nEncoder and Decoder Stacks\nEncoder:\nThe encoder is composed of a stack of N = 6 identical layers. Each layer has two\nsub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, position-\nwise fully connected feed-forward network. We employ a residual connection [11] around each of\nthe two sub-layers, followed by layer normalization [1]. That is, the output of each sub-layer is\nLayerNorm(x + Sublayer(x)), where Sublayer(x) is the function implemented by the sub-layer\nitself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding\nlayers, produce outputs of dimension dmodel = 512.\nDecoder:\nThe decoder is also composed of a stack of N = 6 identical layers. In addition to the two\nsub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head\nattention over the output of the encoder stack. Similar to the encoder, we employ residual connections\naround each of the sub-layers, followed by layer normalization. We also modify the self-attention\nsub-layer in the decoder stack to prevent positions from attending to subsequent positions. This\nmasking, combined with fact that the output embeddings are offset by one position, ensures that the\npredictions for position i can depend only on the known outputs at positions less than i.\n3.2\nAttention\nAn attention function can be described as mapping a query and a set of key-value pairs to an output,\nwhere the query, keys, values, and output are all vectors. The output is computed as a weighted sum\n3\n\n\n## PDF page 4\n\nScaled Dot-Product Attention\nMulti-Head Attention\nFigure 2: (left) Scaled Dot-Product Attention. (right) Multi-Head Attention consists of several\nattention layers running in parallel.\nof the values, where the weight assigned to each value is computed by a compatibility function of the\nquery with the corresponding key.\n3.2.1\nScaled Dot-Product Attention\nWe call our particular attention \"Scaled Dot-Product Attention\" (Figure 2). The input consists of\nqueries and keys of dimension dk, and values of dimension dv. We compute the dot products of the\nquery with all keys, divide each by √dk, and apply a softmax function to obtain the weights on the\nvalues.\nIn practice, we compute the attention function on a set of queries simultaneously, packed together\ninto a matrix Q. The keys and values are also packed together into matrices K and V . We compute\nthe matrix of outputs as:\nAttention(Q, K, V ) = softmax(QKT\n√dk\n)V\n(1)\nThe two most commonly used attention functions are additive attention [2], and dot-product (multi-\nplicative) attention. Dot-product attention is identical to our algorithm, except for the scaling factor\nof\n1\n√dk . Additive attention computes the compatibility function using a feed-forward network with\na single hidden layer. While the two are similar in theoretical complexity, dot-product attention is\nmuch faster and more space-efficient in practice, since it can be implemented using highly optimized\nmatrix multiplication code.\nWhile for small values of dk the two mechanisms perform similarly, additive attention outperforms\ndot product attention without scaling for larger values of dk [3]. We suspect that for large values of\ndk, the dot products grow large in magnitude, pushing the softmax function into regions where it has\nextremely small gradients 4. To counteract this effect, we scale the dot products by\n1\n√dk .\n3.2.2\nMulti-Head Attention\nInstead of performing a single attention function with dmodel-dimensional keys, values and queries,\nwe found it beneficial to linearly project the queries, keys and values h times with different, learned\nlinear projections to dk, dk and dv dimensions, respectively. On each of these projected versions of\nqueries, keys and values we then perform the attention function in parallel, yielding dv-dimensional\n4To illustrate why the dot products get large, assume that the components of q and k are independent random\nvariables with mean 0 and variance 1. Then their dot product, q · k = Pdk\ni=1 qiki, has mean 0 and variance dk.\n4\n\n\n## PDF page 5\n\noutput values. These are concatenated and once again projected, resulting in the final values, as\ndepicted in Figure 2.\nMulti-head attention allows the model to jointly attend to information from different representation\nsubspaces at different positions. With a single attention head, averaging inhibits this.\nMultiHead(Q, K, V ) = Concat(head1, ..., headh)W O\nwhere headi = Attention(QW Q\ni , KW K\ni , V W V\ni )\nWhere the projections are parameter matrices W Q\ni\n∈Rdmodel×dk, W K\ni\n∈Rdmodel×dk, W V\ni\n∈Rdmodel×dv\nand W O ∈Rhdv×dmodel.\nIn this work we employ h = 8 parallel attention layers, or heads. For each of these we use\ndk = dv = dmodel/h = 64. Due to the reduced dimension of each head, the total computational cost\nis similar to that of single-head attention with full dimensionality.\n3.2.3\nApplications of Attention in our Model\nThe Transformer uses multi-head attention in three different ways:\n• In \"encoder-decoder attention\" layers, the queries come from the previous decoder layer,\nand the memory keys and values come from the output of the encoder. This allows every\nposition in the decoder to attend over all positions in the input sequence. This mimics the\ntypical encoder-decoder attention mechanisms in sequence-to-sequence models such as\n[38, 2, 9].\n• The encoder contains self-attention layers. In a self-attention layer all of the keys, values\nand queries come from the same place, in this case, the output of the previous layer in the\nencoder. Each position in the encoder can attend to all positions in the previous layer of the\nencoder.\n• Similarly, self-attention layers in the decoder allow each position in the decoder to attend to\nall positions in the decoder up to and including that position. We need to prevent leftward\ninformation flow in the decoder to preserve the auto-regressive property. We implement this\ninside of scaled dot-product attention by masking out (setting to −∞) all values in the input\nof the softmax which correspond to illegal connections. See Figure 2.\n3.3\nPosition-wise Feed-Forward Networks\nIn addition to attention sub-layers, each of the layers in our encoder and decoder contains a fully\nconnected feed-forward network, which is applied to each position separately and identically. This\nconsists of two linear transformations with a ReLU activation in between.\nFFN(x) = max(0, xW1 + b1)W2 + b2\n(2)\nWhile the linear transformations are the same across different positions, they use different parameters\nfrom layer to layer. Another way of describing this is as two convolutions with kernel size 1.\nThe dimensionality of input and output is dmodel = 512, and the inner-layer has dimensionality\ndff = 2048.\n3.4\nEmbeddings and Softmax\nSimilarly to other sequence transduction models, we use learned embeddings to convert the input\ntokens and output tokens to vectors of dimension dmodel. We also use the usual learned linear transfor-\nmation and softmax function to convert the decoder output to predicted next-token probabilities. In\nour model, we share the same weight matrix between the two embedding layers and the pre-softmax\nlinear transformation, similar to [30]. In the embedding layers, we multiply those weights by √dmodel.\n5\n\n\n## PDF page 6\n\nTable 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations\nfor different layer types. n is the sequence length, d is the representation dimension, k is the kernel\nsize of convolutions and r the size of the neighborhood in restricted self-attention.\nLayer Type\nComplexity per Layer\nSequential\nMaximum Path Length\nOperations\nSelf-Attention\nO(n2 · d)\nO(1)\nO(1)\nRecurrent\nO(n · d2)\nO(n)\nO(n)\nConvolutional\nO(k · n · d2)\nO(1)\nO(logk(n))\nSelf-Attention (restricted)\nO(r · n · d)\nO(1)\nO(n/r)\n3.5\nPositional Encoding\nSince our model contains no recurrence and no convolution, in order for the model to make use of the\norder of the sequence, we must inject some information about the relative or absolute position of the\ntokens in the sequence. To this end, we add \"positional encodings\" to the input embeddings at the\nbottoms of the encoder and decoder stacks. The positional encodings have the same dimension dmodel\nas the embeddings, so that the two can be summed. There are many choices of positional encodings,\nlearned and fixed [9].\nIn this work, we use sine and cosine functions of different frequencies:\nPE(pos,2i) = sin(pos/100002i/dmodel)\nPE(pos,2i+1) = cos(pos/100002i/dmodel)\nwhere pos is the position and i is the dimension. That is, each dimension of the positional encoding\ncorresponds to a sinusoid. The wavelengths form a geometric progression from 2π to 10000 · 2π. We\nchose this function because we hypothesized it would allow the model to easily learn to attend by\nrelative positions, since for any fixed offset k, PEpos+k can be represented as a linear function of\nPEpos.\nWe also experimented with using learned positional embeddings [9] instead, and found that the two\nversions produced nearly identical results (see Table 3 row (E)). We chose the sinusoidal version\nbecause it may allow the model to extrapolate to sequence lengths longer than the ones encountered\nduring training.\n4\nWhy Self-Attention\nIn this section we compare various aspects of self-attention layers to the recurrent and convolu-\ntional layers commonly used for mapping one variable-length sequence of symbol representations\n(x1, ..., xn) to another sequence of equal length (z1, ..., zn), with xi, zi ∈Rd, such as a hidden\nlayer in a typical sequence transduction encoder or decoder. Motivating our use of self-attention we\nconsider three desiderata.\nOne is the total computational complexity per layer. Another is the amount of computation that can\nbe parallelized, as measured by the minimum number of sequential operations required.\nThe third is the path length between long-range dependencies in the network. Learning long-range\ndependencies is a key challenge in many sequence transduction tasks. One key factor affecting the\nability to learn such dependencies is the length of the paths forward and backward signals have to\ntraverse in the network. The shorter these paths between any combination of positions in the input\nand output sequences, the easier it is to learn long-range dependencies [12]. Hence we also compare\nthe maximum path length between any two input and output positions in networks composed of the\ndifferent layer types.\nAs noted in Table 1, a self-attention layer connects all positions with a constant number of sequentially\nexecuted operations, whereas a recurrent layer requires O(n) sequential operations. In terms of\ncomputational complexity, self-attention layers are faster than recurrent layers when the sequence\n6\n\n\n## PDF page 7\n\nlength n is smaller than the representation dimensionality d, which is most often the case with\nsentence representations used by state-of-the-art models in machine translations, such as word-piece\n[38] and byte-pair [31] representations. To improve computational performance for tasks involving\nvery long sequences, self-attention could be restricted to considering only a neighborhood of size r in\nthe input sequence centered around the respective output position. This would increase the maximum\npath length to O(n/r). We plan to investigate this approach further in future work.\nA single convolutional layer with kernel width k < n does not connect all pairs of input and output\npositions. Doing so requires a stack of O(n/k) convolutional layers in the case of contiguous kernels,\nor O(logk(n)) in the case of dilated convolutions [18], increasing the length of the longest paths\nbetween any two positions in the network. Convolutional layers are generally more expensive than\nrecurrent layers, by a factor of k. Separable convolutions [6], however, decrease the complexity\nconsiderably, to O(k · n · d + n · d2). Even with k = n, however, the complexity of a separable\nconvolution is equal to the combination of a self-attention layer and a point-wise feed-forward layer,\nthe approach we take in our model.\nAs side benefit, self-attention could yield more interpretable models. We inspect attention distributions\nfrom our models and present and discuss examples in the appendix. Not only do individual attention\nheads clearly learn to perform different tasks, many appear to exhibit behavior related to the syntactic\nand semantic structure of the sentences.\n5\nTraining\nThis section describes the training regime for our models.\n5.1\nTraining Data and Batching\nWe trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million\nsentence pairs. Sentences were encoded using byte-pair encoding [3], which has a shared source-\ntarget vocabulary of about 37000 tokens. For English-French, we used the significantly larger WMT\n2014 English-French dataset consisting of 36M sentences and split tokens into a 32000 word-piece\nvocabulary [38]. Sentence pairs were batched together by approximate sequence length. Each training\nbatch contained a set of sentence pairs containing approximately 25000 source tokens and 25000\ntarget tokens.\n5.2\nHardware and Schedule\nWe trained our models on one machine with 8 NVIDIA P100 GPUs. For our base models using\nthe hyperparameters described throughout the paper, each training step took about 0.4 seconds. We\ntrained the base models for a total of 100,000 steps or 12 hours. For our big models,(described on the\nbottom line of table 3), step time was 1.0 seconds. The big models were trained for 300,000 steps\n(3.5 days).\n5.3\nOptimizer\nWe used the Adam optimizer [20] with β1 = 0.9, β2 = 0.98 and ϵ = 109. We varied the learning\nrate over the course of training, according to the formula:\nlrate = d0.5\nmodel · min(step_num0.5, step_num · warmup_steps1.5)\n(3)\nThis corresponds to increasing the learning rate linearly for the first warmup_steps training steps,\nand decreasing it thereafter proportionally to the inverse square root of the step number. We used\nwarmup_steps = 4000.\n5.4\nRegularization\nWe employ three types of regularization during training:\n7\n\n\n## PDF page 8\n\nTable 2: The Transformer achieves better BLEU scores than previous state-of-the-art models on the\nEnglish-to-German and English-to-French newstest2014 tests at a fraction of the training cost.\nModel\nBLEU\nTraining Cost (FLOPs)\nEN-DE\nEN-FR\nEN-DE\nEN-FR\nByteNet [18]\n23.75\nDeep-Att + PosUnk [39]\n39.2\n1.0 · 1020\nGNMT + RL [38]\n24.6\n39.92\n2.3 · 1019\n1.4 · 1020\nConvS2S [9]\n25.16\n40.46\n9.6 · 1018\n1.5 · 1020\nMoE [32]\n26.03\n40.56\n2.0 · 1019\n1.2 · 1020\nDeep-Att + PosUnk Ensemble [39]\n40.4\n8.0 · 1020\nGNMT + RL Ensemble [38]\n26.30\n41.16\n1.8 · 1020\n1.1 · 1021\nConvS2S Ensemble [9]\n26.36\n41.29\n7.7 · 1019\n1.2 · 1021\nTransformer (base model)\n27.3\n38.1\n3.3 · 1018\nTransformer (big)\n28.4\n41.8\n2.3 · 1019\nResidual Dropout\nWe apply dropout [33] to the output of each sub-layer, before it is added to the\nsub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the\npositional encodings in both the encoder and decoder stacks. For the base model, we use a rate of\nPdrop = 0.1.\nLabel Smoothing\nDuring training, we employed label smoothing of value ϵls = 0.1 [36]. This\nhurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.\n6\nResults\n6.1\nMachine Translation\nOn the WMT 2014 English-to-German translation task, the big transformer model (Transformer (big)\nin Table 2) outperforms the best previously reported models (including ensembles) by more than 2.0\nBLEU, establishing a new state-of-the-art BLEU score of 28.4. The configuration of this model is\nlisted in the bottom line of Table 3. Training took 3.5 days on 8 P100 GPUs. Even our base model\nsurpasses all previously published models and ensembles, at a fraction of the training cost of any of\nthe competitive models.\nOn the WMT 2014 English-to-French translation task, our big model achieves a BLEU score of 41.0,\noutperforming all of the previously published single models, at less than 1/4 the training cost of the\nprevious state-of-the-art model. The Transformer (big) model trained for English-to-French used\ndropout rate Pdrop = 0.1, instead of 0.3.\nFor the base models, we used a single model obtained by averaging the last 5 checkpoints, which\nwere written at 10-minute intervals. For the big models, we averaged the last 20 checkpoints. We\nused beam search with a beam size of 4 and length penalty α = 0.6 [38]. These hyperparameters\nwere chosen after experimentation on the development set. We set the maximum output length during\ninference to input length + 50, but terminate early when possible [38].\nTable 2 summarizes our results and compares our translation quality and training costs to other model\narchitectures from the literature. We estimate the number of floating point operations used to train a\nmodel by multiplying the training time, the number of GPUs used, and an estimate of the sustained\nsingle-precision floating-point capacity of each GPU 5.\n6.2\nModel Variations\nTo evaluate the importance of different components of the Transformer, we varied our base model\nin different ways, measuring the change in performance on English-to-German translation on the\n5We used values of 2.8, 3.7, 6.0 and 9.5 TFLOPS for K80, K40, M40 and P100, respectively.\n8\n\n\n## PDF page 9\n\nTable 3: Variations on the Transformer architecture. Unlisted values are identical to those of the base\nmodel. All metrics are on the English-to-German translation development set, newstest2013. Listed\nperplexities are per-wordpiece, according to our byte-pair encoding, and should not be compared to\nper-word perplexities.\nN\ndmodel\ndff\nh\ndk\ndv\nPdrop\nϵls\ntrain\nPPL\nBLEU\nparams\nsteps\n(dev)\n(dev)\n×106\nbase\n6\n512\n2048\n8\n64\n64\n0.1\n0.1\n100K\n4.92\n25.8\n65\n(A)\n1\n512\n512\n5.29\n24.9\n4\n128\n128\n5.00\n25.5\n16\n32\n32\n4.91\n25.8\n32\n16\n16\n5.01\n25.4\n(B)\n16\n5.16\n25.1\n58\n32\n5.01\n25.4\n60\n(C)\n2\n6.11\n23.7\n36\n4\n5.19\n25.3\n50\n8\n4.88\n25.5\n80\n256\n32\n32\n5.75\n24.5\n28\n1024\n128\n128\n4.66\n26.0\n168\n1024\n5.12\n25.4\n53\n4096\n4.75\n26.2\n90\n(D)\n0.0\n5.77\n24.6\n0.2\n4.95\n25.5\n0.0\n4.67\n25.3\n0.2\n5.47\n25.7\n(E)\npositional embedding instead of sinusoids\n4.92\n25.7\nbig\n6\n1024\n4096\n16\n0.3\n300K\n4.33\n26.4\n213\ndevelopment set, newstest2013. We used beam search as described in the previous section, but no\ncheckpoint averaging. We present these results in Table 3.\nIn Table 3 rows (A), we vary the number of attention heads and the attention key and value dimensions,\nkeeping the amount of computation constant, as described in Section 3.2.2. While single-head\nattention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.\nIn Table 3 rows (B), we observe that reducing the attention key size dk hurts model quality. This\nsuggests that determining compatibility is not easy and that a more sophisticated compatibility\nfunction than dot product may be beneficial. We further observe in rows (C) and (D) that, as expected,\nbigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our\nsinusoidal positional encoding with learned positional embeddings [9], and observe nearly identical\nresults to the base model.\n6.3\nEnglish Constituency Parsing\nTo evaluate if the Transformer can generalize to other tasks we performed experiments on English\nconstituency parsing. This task presents specific challenges: the output is subject to strong structural\nconstraints and is significantly longer than the input. Furthermore, RNN sequence-to-sequence\nmodels have not been able to attain state-of-the-art results in small-data regimes [37].\nWe trained a 4-layer transformer with dmodel = 1024 on the Wall Street Journal (WSJ) portion of the\nPenn Treebank [25], about 40K training sentences. We also trained it in a semi-supervised setting,\nusing the larger high-confidence and BerkleyParser corpora from with approximately 17M sentences\n[37]. We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens\nfor the semi-supervised setting.\nWe performed only a small number of experiments to select the dropout, both attention and residual\n(section 5.4), learning rates and beam size on the Section 22 development set, all other parameters\nremained unchanged from the English-to-German base translation model. During inference, we\n9\n\n\n## PDF page 10\n\nTable 4: The Transformer generalizes well to English constituency parsing (Results are on Section 23\nof WSJ)\nParser\nTraining\nWSJ 23 F1\nVinyals & Kaiser el al. (2014) [37]\nWSJ only, discriminative\n88.3\nPetrov et al. (2006) [29]\nWSJ only, discriminative\n90.4\nZhu et al. (2013) [40]\nWSJ only, discriminative\n90.4\nDyer et al. (2016) [8]\nWSJ only, discriminative\n91.7\nTransformer (4 layers)\nWSJ only, discriminative\n91.3\nZhu et al. (2013) [40]\nsemi-supervised\n91.3\nHuang & Harper (2009) [14]\nsemi-supervised\n91.3\nMcClosky et al. (2006) [26]\nsemi-supervised\n92.1\nVinyals & Kaiser el al. (2014) [37]\nsemi-supervised\n92.1\nTransformer (4 layers)\nsemi-supervised\n92.7\nLuong et al. (2015) [23]\nmulti-task\n93.0\nDyer et al. (2016) [8]\ngenerative\n93.3\nincreased the maximum output length to input length + 300. We used a beam size of 21 and α = 0.3\nfor both WSJ only and the semi-supervised setting.\nOur results in Table 4 show that despite the lack of task-specific tuning our model performs sur-\nprisingly well, yielding better results than all previously reported models with the exception of the\nRecurrent Neural Network Grammar [8].\nIn contrast to RNN sequence-to-sequence models [37], the Transformer outperforms the Berkeley-\nParser [29] even when training only on the WSJ training set of 40K sentences.\n7\nConclusion\nIn this work, we presented the Transformer, the first sequence transduction model based entirely on\nattention, replacing the recurrent layers most commonly used in encoder-decoder architectures with\nmulti-headed self-attention.\nFor translation tasks, the Transformer can be trained significantly faster than architectures based\non recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014\nEnglish-to-French translation tasks, we achieve a new state of the art. In the former task our best\nmodel outperforms even all previously reported ensembles.\nWe are excited about the future of attention-based models and plan to apply them to other tasks. We\nplan to extend the Transformer to problems involving input and output modalities other than text and\nto investigate local, restricted attention mechanisms to efficiently handle large inputs and outputs\nsuch as images, audio and video. Making generation less sequential is another research goals of ours.\nThe code we used to train and evaluate our models is available at https://github.com/\ntensorflow/tensor2tensor.\nAcknowledgements\nWe are grateful to Nal Kalchbrenner and Stephan Gouws for their fruitful\ncomments, corrections and inspiration.\nReferences\n[1] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint\narXiv:1607.06450, 2016.\n[2] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly\nlearning to align and translate. CoRR, abs/1409.0473, 2014.\n[3] Denny Britz, Anna Goldie, Minh-Thang Luong, and Quoc V. Le. Massive exploration of neural\nmachine translation architectures. CoRR, abs/1703.03906, 2017.\n[4] Jianpeng Cheng, Li Dong, and Mirella Lapata. Long short-term memory-networks for machine\nreading. arXiv preprint arXiv:1601.06733, 2016.\n10\n\n\n## PDF page 11\n\n[5] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk,\nand Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical\nmachine translation. CoRR, abs/1406.1078, 2014.\n[6] Francois Chollet. Xception: Deep learning with depthwise separable convolutions. arXiv\npreprint arXiv:1610.02357, 2016.\n[7] Junyoung Chung, Çaglar Gülçehre, Kyunghyun Cho, and Yoshua Bengio. Empirical evaluation\nof gated recurrent neural networks on sequence modeling. CoRR, abs/1412.3555, 2014.\n[8] Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, and Noah A. Smith. Recurrent neural\nnetwork grammars. In Proc. of NAACL, 2016.\n[9] Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. Convolu-\ntional sequence to sequence learning. arXiv preprint arXiv:1705.03122v2, 2017.\n[10] Alex Graves.\nGenerating sequences with recurrent neural networks.\narXiv preprint\narXiv:1308.0850, 2013.\n[11] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for im-\nage recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern\nRecognition, pages 770778, 2016.\n[12] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber. Gradient flow in\nrecurrent nets: the difficulty of learning long-term dependencies, 2001.\n[13] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation,\n9(8):17351780, 1997.\n[14] Zhongqiang Huang and Mary Harper. Self-training PCFG grammars with latent annotations\nacross languages. In Proceedings of the 2009 Conference on Empirical Methods in Natural\nLanguage Processing, pages 832841. ACL, August 2009.\n[15] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring\nthe limits of language modeling. arXiv preprint arXiv:1602.02410, 2016.\n[16] Łukasz Kaiser and Samy Bengio. Can active memory replace attention? In Advances in Neural\nInformation Processing Systems, (NIPS), 2016.\n[17] Łukasz Kaiser and Ilya Sutskever. Neural GPUs learn algorithms. In International Conference\non Learning Representations (ICLR), 2016.\n[18] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Ko-\nray Kavukcuoglu. Neural machine translation in linear time. arXiv preprint arXiv:1610.10099v2,\n2017.\n[19] Yoon Kim, Carl Denton, Luong Hoang, and Alexander M. Rush. Structured attention networks.\nIn International Conference on Learning Representations, 2017.\n[20] Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.\n[21] Oleksii Kuchaiev and Boris Ginsburg. Factorization tricks for LSTM networks. arXiv preprint\narXiv:1703.10722, 2017.\n[22] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen\nZhou, and Yoshua Bengio. A structured self-attentive sentence embedding. arXiv preprint\narXiv:1703.03130, 2017.\n[23] Minh-Thang Luong, Quoc V. Le, Ilya Sutskever, Oriol Vinyals, and Lukasz Kaiser. Multi-task\nsequence to sequence learning. arXiv preprint arXiv:1511.06114, 2015.\n[24] Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-\nbased neural machine translation. arXiv preprint arXiv:1508.04025, 2015.\n11\n\n\n## PDF page 12\n\n[25] Mitchell P Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. Building a large annotated\ncorpus of english: The penn treebank. Computational linguistics, 19(2):313330, 1993.\n[26] David McClosky, Eugene Charniak, and Mark Johnson. Effective self-training for parsing. In\nProceedings of the Human Language Technology Conference of the NAACL, Main Conference,\npages 152159. ACL, June 2006.\n[27] Ankur Parikh, Oscar Täckström, Dipanjan Das, and Jakob Uszkoreit. A decomposable attention\nmodel. In Empirical Methods in Natural Language Processing, 2016.\n[28] Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive\nsummarization. arXiv preprint arXiv:1705.04304, 2017.\n[29] Slav Petrov, Leon Barrett, Romain Thibaux, and Dan Klein. Learning accurate, compact,\nand interpretable tree annotation. In Proceedings of the 21st International Conference on\nComputational Linguistics and 44th Annual Meeting of the ACL, pages 433440. ACL, July\n2006.\n[30] Ofir Press and Lior Wolf. Using the output embedding to improve language models. arXiv\npreprint arXiv:1608.05859, 2016.\n[31] Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words\nwith subword units. arXiv preprint arXiv:1508.07909, 2015.\n[32] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton,\nand Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts\nlayer. arXiv preprint arXiv:1701.06538, 2017.\n[33] Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdi-\nnov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine\nLearning Research, 15(1):19291958, 2014.\n[34] Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory\nnetworks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors,\nAdvances in Neural Information Processing Systems 28, pages 24402448. Curran Associates,\nInc., 2015.\n[35] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. Sequence to sequence learning with neural\nnetworks. In Advances in Neural Information Processing Systems, pages 31043112, 2014.\n[36] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna.\nRethinking the inception architecture for computer vision. CoRR, abs/1512.00567, 2015.\n[37] Vinyals & Kaiser, Koo, Petrov, Sutskever, and Hinton. Grammar as a foreign language. In\nAdvances in Neural Information Processing Systems, 2015.\n[38] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang\nMacherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Googles neural machine\ntranslation system: Bridging the gap between human and machine translation. arXiv preprint\narXiv:1609.08144, 2016.\n[39] Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. Deep recurrent models with\nfast-forward connections for neural machine translation. CoRR, abs/1606.04199, 2016.\n[40] Muhua Zhu, Yue Zhang, Wenliang Chen, Min Zhang, and Jingbo Zhu. Fast and accurate\nshift-reduce constituent parsing. In Proceedings of the 51st Annual Meeting of the ACL (Volume\n1: Long Papers), pages 434443. ACL, August 2013.\n12\n\n\n## PDF page 13\n\nAttention Visualizations\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nFigure 3: An example of the attention mechanism following long-distance dependencies in the\nencoder self-attention in layer 5 of 6. Many of the attention heads attend to a distant dependency of\nthe verb making, completing the phrase making...more difficult. Attentions here shown only for\nthe word making. Different colors represent different heads. Best viewed in color.\n13\n\n\n## PDF page 14\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 4: Two attention heads, also in layer 5 of 6, apparently involved in anaphora resolution. Top:\nFull attentions for head 5. Bottom: Isolated attentions from just the word its for attention heads 5\nand 6. Note that the attentions are very sharp for this word.\n14\n\n\n## PDF page 15\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 5: Many of the attention heads exhibit behaviour that seems related to the structure of the\nsentence. We give two such examples above, from two different heads from the encoder self-attention\nat layer 5 of 6. The heads clearly learned to perform different tasks.\n15\n\n\n可直接引用的图表文件:\n- paper_figure_1_transformer.pngFigure 1 from PDF page 3: The Transformer model architecture.\n- paper_figure_3_long_distance.pngFigure 3 from PDF page 13: Encoder self-attention following long-distance dependencies.\n- paper_figure_4_anaphora.pngFigure 4 from PDF page 14: Attention heads involved in anaphora resolution.\n\n请生成一版 10-20 页的完整初稿。内容必须忠于论文,至少引用上面列出的三张原论文图,并覆盖问题、Transformer 架构、注意力机制、训练、主要实验、局限和结论。不要复制长段原文;每页保持听众可读的信息密度。生成完整的 slides.md。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\n---\n\n# Attention Is All You Need\n## A Revolutionary Architecture for Sequence Transduction\n\nAshish Vaswani et al. \nNIPS 2017\n\n---\n\n## Problem Statement\n\n- Traditional sequence models rely on RNNs or CNNs\n- RNNs have inherent sequential computation (hard to parallelize)\n- CNNs require multiple layers to capture long-range dependencies\n- Both have increasing path lengths between distant positions\n\n**Key Insight**: Replace recurrence and convolution with attention mechanisms\n\n---\n\n## The Transformer: Model Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n- Encoder-decoder structure with stacked self-attention layers\n- No recurrence or convolution\n- Significantly more parallelizable\n\n---\n\n## Encoder Stack\n\n- 6 identical layers\n- Each layer has two sub-layers:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization around each sub-layer\n- Output dimension: d<sub>model</sub> = 512\n\n---\n\n## Decoder Stack\n\n- 6 identical layers\n- Three sub-layers per layer:\n 1. Masked multi-head self-attention\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Masking prevents attending to future positions\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- Queries (Q), Keys (K), Values (V) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradient vanishing\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-40 mx-auto\" />\n\n- Project Q, K, V h times with different linear projections\n- Perform attention in parallel on each projection\n- Concatenate results and project again\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**:\n - Queries from decoder, keys/values from encoder\n - Allows decoder to attend to all input positions\n\n2. **Encoder self-attention**:\n - All Q, K, V from previous encoder layer\n - Each position attends to all positions\n\n3. **Decoder self-attention**:\n - All Q, K, V from previous decoder layer\n - Masked to prevent attending to future positions\n\n---\n\n## Positional Encoding\n\nSince model has no recurrence/convolution, we add positional information:\n\n$$PE_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$PE_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Sinusoidal functions with varying frequencies\n- Allows model to learn relative position information\n- Performed as well as learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------|------------|----------------|-----------------|\n| Self-Attention | O(n²·d) | O(1) | O(1) |\n| Recurrent | O(n·d²) | O(n) | O(n) |\n| Convolutional | O(k·n·d²) | O(1) | O(logₖn) |\n\n- Better parallelization than RNNs\n- Shorter path lengths than CNNs/RNNs\n- More interpretable attention patterns\n\n---\n\n## Training Details\n\n- **Datasets**: WMT 2014 EN-DE (4.5M) and EN-FR (36M)\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Optimizer**: Adam (β₁=0.9, β₂=0.98, ϵ=10⁻⁹)\n- **Learning Rate**: $lrate = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step_num}^{-0.5}, \\text{step_num} \\cdot \\text{warmup_steps}^{-1.5})$\n- **Regularization**: Dropout (P=0.1), Label Smoothing (ϵ=0.1)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|------------------------|\n| GNMT + RL | 24.6 | 39.92 | 2.3·10¹⁹ |\n| ConvS2S | 25.16 | 40.46 | 9.6·10¹⁸ |\n| Transformer (base) | 27.3 | 38.1 | 3.3·10¹⁸ |\n| **Transformer (big)** | **28.4** | **41.8** | **2.3·10¹⁹** |\n\n- Transformer (big) outperforms all previous state-of-the-art\n- Achieves new SOTA with significantly less training cost\n\n---\n\n## Model Variations\n\n| Configuration | Dev PPL | Dev BLEU |\n|---------------|---------|----------|\n| Base | 4.92 | 25.8 |\n| 1 attention head | 5.29 | 24.9 |\n| 32 attention heads | 5.01 | 25.4 |\n| No dropout | 5.77 | 24.6 |\n| Learned positional embeddings | 4.92 | 25.7 |\n| Big model | 4.33 | 26.4 |\n\n- Multiple attention heads improve performance\n- Dropout is crucial for generalization\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Achieves competitive results with minimal task-specific modifications\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n- Attention heads follow distant dependencies\n- Example: Verb \"making\" attends to \"more difficult\"\n- Different colors represent different attention heads\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n- Some heads specialize in resolving pronouns\n- Example: \"its\" clearly attends to \"The Law\"\n- Sharp attention patterns for coreference resolution\n\n---\n\n## Limitations and Future Work\n\n### Limitations:\n- High memory consumption with long sequences (O(n²))\n- Still generates output sequentially\n\n### Future Work:\n- Local, restricted attention mechanisms for large inputs\n- Extend to other modalities (images, audio, video)\n- Make generation less sequential\n- Explore more efficient attention variants\n\n---\n\n## Conclusion\n\n- Transformer is the first transduction model based entirely on attention\n- Replaces RNNs/CNNs with multi-headed self-attention\n- Significantly faster training with better parallelization\n- Achieves new state-of-the-art in machine translation\n- Generalizes well to other sequence tasks like constituency parsing\n\n**Code**: https://github.com/tensorflow/tensor2tensor\n\n---\n\n## Thank You!\n```"
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "这是你上一版 slides.md 渲染出的 19 页截图。请自我审查(文字溢出/拥挤/图片尺寸/可读性/布局),然后输出修订后的完整 slides.md。修订后硬性保持 10–20 页,并保留三张原论文图。"
},
{
"type": "text",
"text": "第 1 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "43e962b781454c3d5eac7723de28844f9fe12cee5370e89387f0273d1c119d0a",
"characters": 89538,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 2 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "38663a48b255317d1b215719cae21f7aa164d6a06e18c33db0fbcb1521e07b08",
"characters": 127194,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 3 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "f2c32e54430c4248aef8efe88184b4ac4e651b33bb90a9363b232e9f6c31b849",
"characters": 163894,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 4 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a133c25660777e180a5ce25bbebc5ec3cf9b4ee399094503834f94b5a19249fb",
"characters": 100590,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 5 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9bbe983962c98389fd510d680ae999581f8df804965e242cb0c188667ffe180a",
"characters": 110394,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 6 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "446675777a3f374f452bfb70617bf46328990e9884d9997a1da802408c9d3d49",
"characters": 109418,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 7 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "d6add7843373ed4062f7f33e3cef9538da774244ac5ef15281a24d9c90b52cd4",
"characters": 125982,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 8 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "d126da4d299d6123fc4fcc5bef77fd481f57c5c379f6ac87c7995961c3d4dd32",
"characters": 145338,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 9 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "39a056fc9e4982e85821c808947c903f85a3cd3236c204fe22887f850db717b0",
"characters": 136346,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 10 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a89b46f3ef9f56d231e8c3c0a0e15d085a0cd45d75a11d7fcef2c3abfe20d33d",
"characters": 123138,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 11 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "1684df3822c5f232dfcc6f42539e91e5b2bb16e383fbbbb25fff3c4bc2d7ff8e",
"characters": 134618,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 12 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "65d72181f5930398c2e0ad9e29ddde08a324c168de9e183a3072a430e03dfcd1",
"characters": 137678,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 13 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "cfd076741770b767919a9b20b0589a6e2b9b48b189b5e2019396fd8ddd89e2a1",
"characters": 142406,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 14 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "8fa0de2217a29efdc146e957d16f97a02293a370513bc67d1dd9eae6870ae056",
"characters": 152318,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 15 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "0d2304a0c4ac2ea569ed1113df08ea926fb94d10a7cb174c8cc3221b1db97481",
"characters": 172402,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 16 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "859bd832f8a544f10d2f4f4d0539f969538126f038d394792e98caede1739d7d",
"characters": 175410,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 17 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "bd8b103b3619b1ff7c24f1846725a3d7dbe9e6788e9ed59145bd98a4a9d777d5",
"characters": 133230,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 18 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "0584853789dc51eb555b312710b70f51538d671471bc1f01af77052331ca4535",
"characters": 137474,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 19 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "e62c27dc16880a560b7826ed349aa24fbacea989919063c5539777d6accbb28e",
"characters": 14014,
"media_type": "image/png"
},
"detail": "high"
}
}
]
}
],
"temperature": 0.3
},
"response": {
"id": "021785385508645355cac89e6d983ae8d30678a5b54f9aff462b8",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "```markdown\n---\ntheme: default\n---\n\n# Attention Is All You Need\n## A Revolutionary Architecture for Sequence Transduction\n\nAshish Vaswani et al. \nNIPS 2017\n\n---\n\n## Problem Statement\n\n- Traditional sequence models rely on RNNs or CNNs\n- RNNs have inherent sequential computation (hard to parallelize)\n- CNNs require multiple layers to capture long-range dependencies\n- Both have increasing path lengths between distant positions\n\n**Key Insight**: Replace recurrence and convolution with attention mechanisms\n\n---\n\n## The Transformer: Model Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-96 mx-auto\" />\n\n- Encoder-decoder structure with stacked self-attention layers\n- No recurrence or convolution\n- Significantly more parallelizable\n\n---\n\n## Encoder Stack\n\n- 6 identical layers with two sub-layers each:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Output dimension: d<sub>model</sub> = 512\n\n---\n\n## Decoder Stack\n\n- 6 identical layers with three sub-layers each:\n 1. Masked multi-head self-attention\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Masking prevents attending to future positions\n\n---\n\n## Scaled Dot-Product Attention\n\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- Queries (Q), Keys (K), Values (V) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradient vanishing\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-60 mx-auto\" />\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- Project Q, K, V h times with different linear projections\n- Perform attention in parallel on each projection\n- Concatenate results and project again\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**:\n - Queries from decoder, keys/values from encoder\n\n2. **Encoder self-attention**:\n - All Q, K, V from previous encoder layer\n - Each position attends to all positions\n\n3. **Decoder self-attention**:\n - All Q, K, V from previous decoder layer\n - Masked to prevent attending to future positions\n\n---\n\n## Positional Encoding\n\nSince model has no recurrence/convolution, we add positional information:\n\n$$PE_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$PE_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Sinusoidal functions with varying frequencies\n- Allows model to learn relative position information\n- Performed as well as learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------|------------|----------------|-----------------|\n| Self-Attention | O(n²·d) | O(1) | O(1) |\n| Recurrent | O(n·d²) | O(n) | O(n) |\n| Convolutional | O(k·n·d²) | O(1) | O(logₖn) |\n\n- Better parallelization than RNNs\n- Shorter path lengths than CNNs/RNNs\n- More interpretable attention patterns\n\n---\n\n## Training Details\n\n- **Datasets**: WMT 2014 EN-DE (4.5M) and EN-FR (36M)\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Optimizer**: Adam (β₁=0.9, β₂=0.98, ϵ=10⁻⁹)\n- **Learning Rate**: \n $$lrate = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step\\_num}^{-0.5}, \\text{step\\_num} \\cdot \\text{warmup\\_steps}^{-1.5})$$\n- **Regularization**: Dropout (P=0.1), Label Smoothing (ϵ=0.1)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|------------------------|\n| GNMT + RL | 24.6 | 39.92 | 2.3·10¹⁹ |\n| ConvS2S | 25.16 | 40.46 | 9.6·10¹⁸ |\n| Transformer (base) | 27.3 | 38.1 | 3.3·10¹⁸ |\n| **Transformer (big)** | **28.4** | **41.8** | **2.3·10¹⁹** |\n\n- Transformer (big) outperforms all previous state-of-the-art\n- Achieves new SOTA with significantly less training cost\n\n---\n\n## Model Variations\n\n| Configuration | Dev PPL | Dev BLEU |\n|---------------|---------|----------|\n| Base | 4.92 | 25.8 |\n| 1 attention head | 5.29 | 24.9 |\n| 32 attention heads | 5.01 | 25.4 |\n| No dropout | 5.77 | 24.6 |\n| Learned positional embeddings | 4.92 | 25.7 |\n| Big model | 4.33 | 26.4 |\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-80 mx-auto\" />\n\n- Attention heads follow distant dependencies\n- Example: Verb \"making\" attends to \"more difficult\"\n- Different colors represent different attention heads\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-80 mx-auto\" />\n\n- Some heads specialize in resolving pronouns\n- Example: \"its\" clearly attends to \"The Law\"\n- Sharp attention patterns for coreference resolution\n\n---\n\n## Limitations and Future Work\n\n### Limitations:\n- High memory consumption with long sequences (O(n²))\n- Still generates output sequentially\n\n### Future Work:\n- Local, restricted attention mechanisms for large inputs\n- Extend to other modalities (images, audio, video)\n- Make generation less sequential\n\n---\n\n## Conclusion\n\n- Transformer is the first transduction model based entirely on attention\n- Replaces RNNs/CNNs with multi-headed self-attention\n- Significantly faster training with better parallelization\n- Achieves new state-of-the-art in machine translation\n- Generalizes well to other sequence tasks like constituency parsing\n\n**Code**: https://github.com/tensorflow/tensor2tensor\n```"
},
"usage": {
"prompt_tokens": 36197,
"completion_tokens": 2188,
"total_tokens": 38385,
"cached_prompt_tokens": 0
}
},
{
"meter": "SingleAgent(自审, 图片累积)",
"called_at_utc": "2026-07-30T04:27:06.044339+00:00",
"latency_s": 57.985,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名擅长把学术论文转化为演示文稿的 Proposer Agent。\n你用 Slidev 框架(Markdown + HTML)编写 PPT 源码 slides.md。\n\nSlidev 语法要点:\n- 文件开头是 YAML frontmatter--- 包裹),设置 theme: default。\n- 用单独一行的 `---`(前后空行)分隔每一页幻灯片。\n- 首页通常放标题、作者、会议。\n- 引用图片用 markdown![说明](/图片文件名.png),可用 HTML 控制尺寸,\n 例如 <img src=\"/speedup_bar.png\" class=\"h-60 mx-auto\" />。\n- 可用 Windi/Uno CSS 工具类控制排版(如 text-sm、grid grid-cols-2 gap-4)。\n\n要求:\n- 最终生成 10-20 页,覆盖论文的标题、背景/动机、方法、实验结果、局限与结论。\n- 至少在 3 页中使用提供的图表/表格,且图文匹配。\n- 每页信息量适中、不要塞太多字,宁可拆页也不要溢出。\n- 只输出 slides.md 的完整内容,用 ```markdown 代码块包裹,不要额外解释。\n\n此外,你还要**自我审查**:当收到自己 PPT 的渲染截图时,先在心里按下列标准找出问题\n(文字溢出、内容拥挤、图片尺寸、可读性、布局),再据此输出修订后的完整 slides.md。"
},
{
"role": "user",
"content": "以下是论文全文(Markdown):\n\n# Attention Is All You Need\n\nAuthors: Ashish Vaswani et al.\n\n\n## PDF page 1\n\nProvided proper attribution is provided, Google hereby grants permission to\nreproduce the tables and figures in this paper solely for use in journalistic or\nscholarly works.\nAttention Is All You Need\nAshish Vaswani\nGoogle Brain\navaswani@google.com\nNoam Shazeer\nGoogle Brain\nnoam@google.com\nNiki Parmar\nGoogle Research\nnikip@google.com\nJakob Uszkoreit\nGoogle Research\nusz@google.com\nLlion Jones\nGoogle Research\nllion@google.com\nAidan N. Gomez∗†\nUniversity of Toronto\naidan@cs.toronto.edu\nŁukasz Kaiser\nGoogle Brain\nlukaszkaiser@google.com\nIllia Polosukhin∗‡\nillia.polosukhin@gmail.com\nAbstract\nThe dominant sequence transduction models are based on complex recurrent or\nconvolutional neural networks that include an encoder and a decoder. The best\nperforming models also connect the encoder and decoder through an attention\nmechanism. We propose a new simple network architecture, the Transformer,\nbased solely on attention mechanisms, dispensing with recurrence and convolutions\nentirely. Experiments on two machine translation tasks show these models to\nbe superior in quality while being more parallelizable and requiring significantly\nless time to train. Our model achieves 28.4 BLEU on the WMT 2014 English-\nto-German translation task, improving over the existing best results, including\nensembles, by over 2 BLEU. On the WMT 2014 English-to-French translation task,\nour model establishes a new single-model state-of-the-art BLEU score of 41.8 after\ntraining for 3.5 days on eight GPUs, a small fraction of the training costs of the\nbest models from the literature. We show that the Transformer generalizes well to\nother tasks by applying it successfully to English constituency parsing both with\nlarge and limited training data.\nEqual contribution. Listing order is random. Jakob proposed replacing RNNs with self-attention and started\nthe effort to evaluate this idea. Ashish, with Illia, designed and implemented the first Transformer models and\nhas been crucially involved in every aspect of this work. Noam proposed scaled dot-product attention, multi-head\nattention and the parameter-free position representation and became the other person involved in nearly every\ndetail. Niki designed, implemented, tuned and evaluated countless model variants in our original codebase and\ntensor2tensor. Llion also experimented with novel model variants, was responsible for our initial codebase, and\nefficient inference and visualizations. Lukasz and Aidan spent countless long days designing various parts of and\nimplementing tensor2tensor, replacing our earlier codebase, greatly improving results and massively accelerating\nour research.\n†Work performed while at Google Brain.\n‡Work performed while at Google Research.\n31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA.\narXiv:1706.03762v7 [cs.CL] 2 Aug 2023\n\n\n## PDF page 2\n\n1\nIntroduction\nRecurrent neural networks, long short-term memory [13] and gated recurrent [7] neural networks\nin particular, have been firmly established as state of the art approaches in sequence modeling and\ntransduction problems such as language modeling and machine translation [35, 2, 5]. Numerous\nefforts have since continued to push the boundaries of recurrent language models and encoder-decoder\narchitectures [38, 24, 15].\nRecurrent models typically factor computation along the symbol positions of the input and output\nsequences. Aligning the positions to steps in computation time, they generate a sequence of hidden\nstates ht, as a function of the previous hidden state ht1 and the input for position t. This inherently\nsequential nature precludes parallelization within training examples, which becomes critical at longer\nsequence lengths, as memory constraints limit batching across examples. Recent work has achieved\nsignificant improvements in computational efficiency through factorization tricks [21] and conditional\ncomputation [32], while also improving model performance in case of the latter. The fundamental\nconstraint of sequential computation, however, remains.\nAttention mechanisms have become an integral part of compelling sequence modeling and transduc-\ntion models in various tasks, allowing modeling of dependencies without regard to their distance in\nthe input or output sequences [2, 19]. In all but a few cases [27], however, such attention mechanisms\nare used in conjunction with a recurrent network.\nIn this work we propose the Transformer, a model architecture eschewing recurrence and instead\nrelying entirely on an attention mechanism to draw global dependencies between input and output.\nThe Transformer allows for significantly more parallelization and can reach a new state of the art in\ntranslation quality after being trained for as little as twelve hours on eight P100 GPUs.\n2\nBackground\nThe goal of reducing sequential computation also forms the foundation of the Extended Neural GPU\n[16], ByteNet [18] and ConvS2S [9], all of which use convolutional neural networks as basic building\nblock, computing hidden representations in parallel for all input and output positions. In these models,\nthe number of operations required to relate signals from two arbitrary input or output positions grows\nin the distance between positions, linearly for ConvS2S and logarithmically for ByteNet. This makes\nit more difficult to learn dependencies between distant positions [12]. In the Transformer this is\nreduced to a constant number of operations, albeit at the cost of reduced effective resolution due\nto averaging attention-weighted positions, an effect we counteract with Multi-Head Attention as\ndescribed in section 3.2.\nSelf-attention, sometimes called intra-attention is an attention mechanism relating different positions\nof a single sequence in order to compute a representation of the sequence. Self-attention has been\nused successfully in a variety of tasks including reading comprehension, abstractive summarization,\ntextual entailment and learning task-independent sentence representations [4, 27, 28, 22].\nEnd-to-end memory networks are based on a recurrent attention mechanism instead of sequence-\naligned recurrence and have been shown to perform well on simple-language question answering and\nlanguage modeling tasks [34].\nTo the best of our knowledge, however, the Transformer is the first transduction model relying\nentirely on self-attention to compute representations of its input and output without using sequence-\naligned RNNs or convolution. In the following sections, we will describe the Transformer, motivate\nself-attention and discuss its advantages over models such as [17, 18] and [9].\n3\nModel Architecture\nMost competitive neural sequence transduction models have an encoder-decoder structure [5, 2, 35].\nHere, the encoder maps an input sequence of symbol representations (x1, ..., xn) to a sequence\nof continuous representations z = (z1, ..., zn). Given z, the decoder then generates an output\nsequence (y1, ..., ym) of symbols one element at a time. At each step the model is auto-regressive\n[10], consuming the previously generated symbols as additional input when generating the next.\n2\n\n\n## PDF page 3\n\nFigure 1: The Transformer - model architecture.\nThe Transformer follows this overall architecture using stacked self-attention and point-wise, fully\nconnected layers for both the encoder and decoder, shown in the left and right halves of Figure 1,\nrespectively.\n3.1\nEncoder and Decoder Stacks\nEncoder:\nThe encoder is composed of a stack of N = 6 identical layers. Each layer has two\nsub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, position-\nwise fully connected feed-forward network. We employ a residual connection [11] around each of\nthe two sub-layers, followed by layer normalization [1]. That is, the output of each sub-layer is\nLayerNorm(x + Sublayer(x)), where Sublayer(x) is the function implemented by the sub-layer\nitself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding\nlayers, produce outputs of dimension dmodel = 512.\nDecoder:\nThe decoder is also composed of a stack of N = 6 identical layers. In addition to the two\nsub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head\nattention over the output of the encoder stack. Similar to the encoder, we employ residual connections\naround each of the sub-layers, followed by layer normalization. We also modify the self-attention\nsub-layer in the decoder stack to prevent positions from attending to subsequent positions. This\nmasking, combined with fact that the output embeddings are offset by one position, ensures that the\npredictions for position i can depend only on the known outputs at positions less than i.\n3.2\nAttention\nAn attention function can be described as mapping a query and a set of key-value pairs to an output,\nwhere the query, keys, values, and output are all vectors. The output is computed as a weighted sum\n3\n\n\n## PDF page 4\n\nScaled Dot-Product Attention\nMulti-Head Attention\nFigure 2: (left) Scaled Dot-Product Attention. (right) Multi-Head Attention consists of several\nattention layers running in parallel.\nof the values, where the weight assigned to each value is computed by a compatibility function of the\nquery with the corresponding key.\n3.2.1\nScaled Dot-Product Attention\nWe call our particular attention \"Scaled Dot-Product Attention\" (Figure 2). The input consists of\nqueries and keys of dimension dk, and values of dimension dv. We compute the dot products of the\nquery with all keys, divide each by √dk, and apply a softmax function to obtain the weights on the\nvalues.\nIn practice, we compute the attention function on a set of queries simultaneously, packed together\ninto a matrix Q. The keys and values are also packed together into matrices K and V . We compute\nthe matrix of outputs as:\nAttention(Q, K, V ) = softmax(QKT\n√dk\n)V\n(1)\nThe two most commonly used attention functions are additive attention [2], and dot-product (multi-\nplicative) attention. Dot-product attention is identical to our algorithm, except for the scaling factor\nof\n1\n√dk . Additive attention computes the compatibility function using a feed-forward network with\na single hidden layer. While the two are similar in theoretical complexity, dot-product attention is\nmuch faster and more space-efficient in practice, since it can be implemented using highly optimized\nmatrix multiplication code.\nWhile for small values of dk the two mechanisms perform similarly, additive attention outperforms\ndot product attention without scaling for larger values of dk [3]. We suspect that for large values of\ndk, the dot products grow large in magnitude, pushing the softmax function into regions where it has\nextremely small gradients 4. To counteract this effect, we scale the dot products by\n1\n√dk .\n3.2.2\nMulti-Head Attention\nInstead of performing a single attention function with dmodel-dimensional keys, values and queries,\nwe found it beneficial to linearly project the queries, keys and values h times with different, learned\nlinear projections to dk, dk and dv dimensions, respectively. On each of these projected versions of\nqueries, keys and values we then perform the attention function in parallel, yielding dv-dimensional\n4To illustrate why the dot products get large, assume that the components of q and k are independent random\nvariables with mean 0 and variance 1. Then their dot product, q · k = Pdk\ni=1 qiki, has mean 0 and variance dk.\n4\n\n\n## PDF page 5\n\noutput values. These are concatenated and once again projected, resulting in the final values, as\ndepicted in Figure 2.\nMulti-head attention allows the model to jointly attend to information from different representation\nsubspaces at different positions. With a single attention head, averaging inhibits this.\nMultiHead(Q, K, V ) = Concat(head1, ..., headh)W O\nwhere headi = Attention(QW Q\ni , KW K\ni , V W V\ni )\nWhere the projections are parameter matrices W Q\ni\n∈Rdmodel×dk, W K\ni\n∈Rdmodel×dk, W V\ni\n∈Rdmodel×dv\nand W O ∈Rhdv×dmodel.\nIn this work we employ h = 8 parallel attention layers, or heads. For each of these we use\ndk = dv = dmodel/h = 64. Due to the reduced dimension of each head, the total computational cost\nis similar to that of single-head attention with full dimensionality.\n3.2.3\nApplications of Attention in our Model\nThe Transformer uses multi-head attention in three different ways:\n• In \"encoder-decoder attention\" layers, the queries come from the previous decoder layer,\nand the memory keys and values come from the output of the encoder. This allows every\nposition in the decoder to attend over all positions in the input sequence. This mimics the\ntypical encoder-decoder attention mechanisms in sequence-to-sequence models such as\n[38, 2, 9].\n• The encoder contains self-attention layers. In a self-attention layer all of the keys, values\nand queries come from the same place, in this case, the output of the previous layer in the\nencoder. Each position in the encoder can attend to all positions in the previous layer of the\nencoder.\n• Similarly, self-attention layers in the decoder allow each position in the decoder to attend to\nall positions in the decoder up to and including that position. We need to prevent leftward\ninformation flow in the decoder to preserve the auto-regressive property. We implement this\ninside of scaled dot-product attention by masking out (setting to −∞) all values in the input\nof the softmax which correspond to illegal connections. See Figure 2.\n3.3\nPosition-wise Feed-Forward Networks\nIn addition to attention sub-layers, each of the layers in our encoder and decoder contains a fully\nconnected feed-forward network, which is applied to each position separately and identically. This\nconsists of two linear transformations with a ReLU activation in between.\nFFN(x) = max(0, xW1 + b1)W2 + b2\n(2)\nWhile the linear transformations are the same across different positions, they use different parameters\nfrom layer to layer. Another way of describing this is as two convolutions with kernel size 1.\nThe dimensionality of input and output is dmodel = 512, and the inner-layer has dimensionality\ndff = 2048.\n3.4\nEmbeddings and Softmax\nSimilarly to other sequence transduction models, we use learned embeddings to convert the input\ntokens and output tokens to vectors of dimension dmodel. We also use the usual learned linear transfor-\nmation and softmax function to convert the decoder output to predicted next-token probabilities. In\nour model, we share the same weight matrix between the two embedding layers and the pre-softmax\nlinear transformation, similar to [30]. In the embedding layers, we multiply those weights by √dmodel.\n5\n\n\n## PDF page 6\n\nTable 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations\nfor different layer types. n is the sequence length, d is the representation dimension, k is the kernel\nsize of convolutions and r the size of the neighborhood in restricted self-attention.\nLayer Type\nComplexity per Layer\nSequential\nMaximum Path Length\nOperations\nSelf-Attention\nO(n2 · d)\nO(1)\nO(1)\nRecurrent\nO(n · d2)\nO(n)\nO(n)\nConvolutional\nO(k · n · d2)\nO(1)\nO(logk(n))\nSelf-Attention (restricted)\nO(r · n · d)\nO(1)\nO(n/r)\n3.5\nPositional Encoding\nSince our model contains no recurrence and no convolution, in order for the model to make use of the\norder of the sequence, we must inject some information about the relative or absolute position of the\ntokens in the sequence. To this end, we add \"positional encodings\" to the input embeddings at the\nbottoms of the encoder and decoder stacks. The positional encodings have the same dimension dmodel\nas the embeddings, so that the two can be summed. There are many choices of positional encodings,\nlearned and fixed [9].\nIn this work, we use sine and cosine functions of different frequencies:\nPE(pos,2i) = sin(pos/100002i/dmodel)\nPE(pos,2i+1) = cos(pos/100002i/dmodel)\nwhere pos is the position and i is the dimension. That is, each dimension of the positional encoding\ncorresponds to a sinusoid. The wavelengths form a geometric progression from 2π to 10000 · 2π. We\nchose this function because we hypothesized it would allow the model to easily learn to attend by\nrelative positions, since for any fixed offset k, PEpos+k can be represented as a linear function of\nPEpos.\nWe also experimented with using learned positional embeddings [9] instead, and found that the two\nversions produced nearly identical results (see Table 3 row (E)). We chose the sinusoidal version\nbecause it may allow the model to extrapolate to sequence lengths longer than the ones encountered\nduring training.\n4\nWhy Self-Attention\nIn this section we compare various aspects of self-attention layers to the recurrent and convolu-\ntional layers commonly used for mapping one variable-length sequence of symbol representations\n(x1, ..., xn) to another sequence of equal length (z1, ..., zn), with xi, zi ∈Rd, such as a hidden\nlayer in a typical sequence transduction encoder or decoder. Motivating our use of self-attention we\nconsider three desiderata.\nOne is the total computational complexity per layer. Another is the amount of computation that can\nbe parallelized, as measured by the minimum number of sequential operations required.\nThe third is the path length between long-range dependencies in the network. Learning long-range\ndependencies is a key challenge in many sequence transduction tasks. One key factor affecting the\nability to learn such dependencies is the length of the paths forward and backward signals have to\ntraverse in the network. The shorter these paths between any combination of positions in the input\nand output sequences, the easier it is to learn long-range dependencies [12]. Hence we also compare\nthe maximum path length between any two input and output positions in networks composed of the\ndifferent layer types.\nAs noted in Table 1, a self-attention layer connects all positions with a constant number of sequentially\nexecuted operations, whereas a recurrent layer requires O(n) sequential operations. In terms of\ncomputational complexity, self-attention layers are faster than recurrent layers when the sequence\n6\n\n\n## PDF page 7\n\nlength n is smaller than the representation dimensionality d, which is most often the case with\nsentence representations used by state-of-the-art models in machine translations, such as word-piece\n[38] and byte-pair [31] representations. To improve computational performance for tasks involving\nvery long sequences, self-attention could be restricted to considering only a neighborhood of size r in\nthe input sequence centered around the respective output position. This would increase the maximum\npath length to O(n/r). We plan to investigate this approach further in future work.\nA single convolutional layer with kernel width k < n does not connect all pairs of input and output\npositions. Doing so requires a stack of O(n/k) convolutional layers in the case of contiguous kernels,\nor O(logk(n)) in the case of dilated convolutions [18], increasing the length of the longest paths\nbetween any two positions in the network. Convolutional layers are generally more expensive than\nrecurrent layers, by a factor of k. Separable convolutions [6], however, decrease the complexity\nconsiderably, to O(k · n · d + n · d2). Even with k = n, however, the complexity of a separable\nconvolution is equal to the combination of a self-attention layer and a point-wise feed-forward layer,\nthe approach we take in our model.\nAs side benefit, self-attention could yield more interpretable models. We inspect attention distributions\nfrom our models and present and discuss examples in the appendix. Not only do individual attention\nheads clearly learn to perform different tasks, many appear to exhibit behavior related to the syntactic\nand semantic structure of the sentences.\n5\nTraining\nThis section describes the training regime for our models.\n5.1\nTraining Data and Batching\nWe trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million\nsentence pairs. Sentences were encoded using byte-pair encoding [3], which has a shared source-\ntarget vocabulary of about 37000 tokens. For English-French, we used the significantly larger WMT\n2014 English-French dataset consisting of 36M sentences and split tokens into a 32000 word-piece\nvocabulary [38]. Sentence pairs were batched together by approximate sequence length. Each training\nbatch contained a set of sentence pairs containing approximately 25000 source tokens and 25000\ntarget tokens.\n5.2\nHardware and Schedule\nWe trained our models on one machine with 8 NVIDIA P100 GPUs. For our base models using\nthe hyperparameters described throughout the paper, each training step took about 0.4 seconds. We\ntrained the base models for a total of 100,000 steps or 12 hours. For our big models,(described on the\nbottom line of table 3), step time was 1.0 seconds. The big models were trained for 300,000 steps\n(3.5 days).\n5.3\nOptimizer\nWe used the Adam optimizer [20] with β1 = 0.9, β2 = 0.98 and ϵ = 109. We varied the learning\nrate over the course of training, according to the formula:\nlrate = d0.5\nmodel · min(step_num0.5, step_num · warmup_steps1.5)\n(3)\nThis corresponds to increasing the learning rate linearly for the first warmup_steps training steps,\nand decreasing it thereafter proportionally to the inverse square root of the step number. We used\nwarmup_steps = 4000.\n5.4\nRegularization\nWe employ three types of regularization during training:\n7\n\n\n## PDF page 8\n\nTable 2: The Transformer achieves better BLEU scores than previous state-of-the-art models on the\nEnglish-to-German and English-to-French newstest2014 tests at a fraction of the training cost.\nModel\nBLEU\nTraining Cost (FLOPs)\nEN-DE\nEN-FR\nEN-DE\nEN-FR\nByteNet [18]\n23.75\nDeep-Att + PosUnk [39]\n39.2\n1.0 · 1020\nGNMT + RL [38]\n24.6\n39.92\n2.3 · 1019\n1.4 · 1020\nConvS2S [9]\n25.16\n40.46\n9.6 · 1018\n1.5 · 1020\nMoE [32]\n26.03\n40.56\n2.0 · 1019\n1.2 · 1020\nDeep-Att + PosUnk Ensemble [39]\n40.4\n8.0 · 1020\nGNMT + RL Ensemble [38]\n26.30\n41.16\n1.8 · 1020\n1.1 · 1021\nConvS2S Ensemble [9]\n26.36\n41.29\n7.7 · 1019\n1.2 · 1021\nTransformer (base model)\n27.3\n38.1\n3.3 · 1018\nTransformer (big)\n28.4\n41.8\n2.3 · 1019\nResidual Dropout\nWe apply dropout [33] to the output of each sub-layer, before it is added to the\nsub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the\npositional encodings in both the encoder and decoder stacks. For the base model, we use a rate of\nPdrop = 0.1.\nLabel Smoothing\nDuring training, we employed label smoothing of value ϵls = 0.1 [36]. This\nhurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.\n6\nResults\n6.1\nMachine Translation\nOn the WMT 2014 English-to-German translation task, the big transformer model (Transformer (big)\nin Table 2) outperforms the best previously reported models (including ensembles) by more than 2.0\nBLEU, establishing a new state-of-the-art BLEU score of 28.4. The configuration of this model is\nlisted in the bottom line of Table 3. Training took 3.5 days on 8 P100 GPUs. Even our base model\nsurpasses all previously published models and ensembles, at a fraction of the training cost of any of\nthe competitive models.\nOn the WMT 2014 English-to-French translation task, our big model achieves a BLEU score of 41.0,\noutperforming all of the previously published single models, at less than 1/4 the training cost of the\nprevious state-of-the-art model. The Transformer (big) model trained for English-to-French used\ndropout rate Pdrop = 0.1, instead of 0.3.\nFor the base models, we used a single model obtained by averaging the last 5 checkpoints, which\nwere written at 10-minute intervals. For the big models, we averaged the last 20 checkpoints. We\nused beam search with a beam size of 4 and length penalty α = 0.6 [38]. These hyperparameters\nwere chosen after experimentation on the development set. We set the maximum output length during\ninference to input length + 50, but terminate early when possible [38].\nTable 2 summarizes our results and compares our translation quality and training costs to other model\narchitectures from the literature. We estimate the number of floating point operations used to train a\nmodel by multiplying the training time, the number of GPUs used, and an estimate of the sustained\nsingle-precision floating-point capacity of each GPU 5.\n6.2\nModel Variations\nTo evaluate the importance of different components of the Transformer, we varied our base model\nin different ways, measuring the change in performance on English-to-German translation on the\n5We used values of 2.8, 3.7, 6.0 and 9.5 TFLOPS for K80, K40, M40 and P100, respectively.\n8\n\n\n## PDF page 9\n\nTable 3: Variations on the Transformer architecture. Unlisted values are identical to those of the base\nmodel. All metrics are on the English-to-German translation development set, newstest2013. Listed\nperplexities are per-wordpiece, according to our byte-pair encoding, and should not be compared to\nper-word perplexities.\nN\ndmodel\ndff\nh\ndk\ndv\nPdrop\nϵls\ntrain\nPPL\nBLEU\nparams\nsteps\n(dev)\n(dev)\n×106\nbase\n6\n512\n2048\n8\n64\n64\n0.1\n0.1\n100K\n4.92\n25.8\n65\n(A)\n1\n512\n512\n5.29\n24.9\n4\n128\n128\n5.00\n25.5\n16\n32\n32\n4.91\n25.8\n32\n16\n16\n5.01\n25.4\n(B)\n16\n5.16\n25.1\n58\n32\n5.01\n25.4\n60\n(C)\n2\n6.11\n23.7\n36\n4\n5.19\n25.3\n50\n8\n4.88\n25.5\n80\n256\n32\n32\n5.75\n24.5\n28\n1024\n128\n128\n4.66\n26.0\n168\n1024\n5.12\n25.4\n53\n4096\n4.75\n26.2\n90\n(D)\n0.0\n5.77\n24.6\n0.2\n4.95\n25.5\n0.0\n4.67\n25.3\n0.2\n5.47\n25.7\n(E)\npositional embedding instead of sinusoids\n4.92\n25.7\nbig\n6\n1024\n4096\n16\n0.3\n300K\n4.33\n26.4\n213\ndevelopment set, newstest2013. We used beam search as described in the previous section, but no\ncheckpoint averaging. We present these results in Table 3.\nIn Table 3 rows (A), we vary the number of attention heads and the attention key and value dimensions,\nkeeping the amount of computation constant, as described in Section 3.2.2. While single-head\nattention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.\nIn Table 3 rows (B), we observe that reducing the attention key size dk hurts model quality. This\nsuggests that determining compatibility is not easy and that a more sophisticated compatibility\nfunction than dot product may be beneficial. We further observe in rows (C) and (D) that, as expected,\nbigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our\nsinusoidal positional encoding with learned positional embeddings [9], and observe nearly identical\nresults to the base model.\n6.3\nEnglish Constituency Parsing\nTo evaluate if the Transformer can generalize to other tasks we performed experiments on English\nconstituency parsing. This task presents specific challenges: the output is subject to strong structural\nconstraints and is significantly longer than the input. Furthermore, RNN sequence-to-sequence\nmodels have not been able to attain state-of-the-art results in small-data regimes [37].\nWe trained a 4-layer transformer with dmodel = 1024 on the Wall Street Journal (WSJ) portion of the\nPenn Treebank [25], about 40K training sentences. We also trained it in a semi-supervised setting,\nusing the larger high-confidence and BerkleyParser corpora from with approximately 17M sentences\n[37]. We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens\nfor the semi-supervised setting.\nWe performed only a small number of experiments to select the dropout, both attention and residual\n(section 5.4), learning rates and beam size on the Section 22 development set, all other parameters\nremained unchanged from the English-to-German base translation model. During inference, we\n9\n\n\n## PDF page 10\n\nTable 4: The Transformer generalizes well to English constituency parsing (Results are on Section 23\nof WSJ)\nParser\nTraining\nWSJ 23 F1\nVinyals & Kaiser el al. (2014) [37]\nWSJ only, discriminative\n88.3\nPetrov et al. (2006) [29]\nWSJ only, discriminative\n90.4\nZhu et al. (2013) [40]\nWSJ only, discriminative\n90.4\nDyer et al. (2016) [8]\nWSJ only, discriminative\n91.7\nTransformer (4 layers)\nWSJ only, discriminative\n91.3\nZhu et al. (2013) [40]\nsemi-supervised\n91.3\nHuang & Harper (2009) [14]\nsemi-supervised\n91.3\nMcClosky et al. (2006) [26]\nsemi-supervised\n92.1\nVinyals & Kaiser el al. (2014) [37]\nsemi-supervised\n92.1\nTransformer (4 layers)\nsemi-supervised\n92.7\nLuong et al. (2015) [23]\nmulti-task\n93.0\nDyer et al. (2016) [8]\ngenerative\n93.3\nincreased the maximum output length to input length + 300. We used a beam size of 21 and α = 0.3\nfor both WSJ only and the semi-supervised setting.\nOur results in Table 4 show that despite the lack of task-specific tuning our model performs sur-\nprisingly well, yielding better results than all previously reported models with the exception of the\nRecurrent Neural Network Grammar [8].\nIn contrast to RNN sequence-to-sequence models [37], the Transformer outperforms the Berkeley-\nParser [29] even when training only on the WSJ training set of 40K sentences.\n7\nConclusion\nIn this work, we presented the Transformer, the first sequence transduction model based entirely on\nattention, replacing the recurrent layers most commonly used in encoder-decoder architectures with\nmulti-headed self-attention.\nFor translation tasks, the Transformer can be trained significantly faster than architectures based\non recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014\nEnglish-to-French translation tasks, we achieve a new state of the art. In the former task our best\nmodel outperforms even all previously reported ensembles.\nWe are excited about the future of attention-based models and plan to apply them to other tasks. We\nplan to extend the Transformer to problems involving input and output modalities other than text and\nto investigate local, restricted attention mechanisms to efficiently handle large inputs and outputs\nsuch as images, audio and video. Making generation less sequential is another research goals of ours.\nThe code we used to train and evaluate our models is available at https://github.com/\ntensorflow/tensor2tensor.\nAcknowledgements\nWe are grateful to Nal Kalchbrenner and Stephan Gouws for their fruitful\ncomments, corrections and inspiration.\nReferences\n[1] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint\narXiv:1607.06450, 2016.\n[2] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly\nlearning to align and translate. CoRR, abs/1409.0473, 2014.\n[3] Denny Britz, Anna Goldie, Minh-Thang Luong, and Quoc V. Le. Massive exploration of neural\nmachine translation architectures. CoRR, abs/1703.03906, 2017.\n[4] Jianpeng Cheng, Li Dong, and Mirella Lapata. Long short-term memory-networks for machine\nreading. arXiv preprint arXiv:1601.06733, 2016.\n10\n\n\n## PDF page 11\n\n[5] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk,\nand Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical\nmachine translation. CoRR, abs/1406.1078, 2014.\n[6] Francois Chollet. Xception: Deep learning with depthwise separable convolutions. arXiv\npreprint arXiv:1610.02357, 2016.\n[7] Junyoung Chung, Çaglar Gülçehre, Kyunghyun Cho, and Yoshua Bengio. Empirical evaluation\nof gated recurrent neural networks on sequence modeling. CoRR, abs/1412.3555, 2014.\n[8] Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, and Noah A. Smith. Recurrent neural\nnetwork grammars. In Proc. of NAACL, 2016.\n[9] Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. Convolu-\ntional sequence to sequence learning. arXiv preprint arXiv:1705.03122v2, 2017.\n[10] Alex Graves.\nGenerating sequences with recurrent neural networks.\narXiv preprint\narXiv:1308.0850, 2013.\n[11] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for im-\nage recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern\nRecognition, pages 770778, 2016.\n[12] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber. Gradient flow in\nrecurrent nets: the difficulty of learning long-term dependencies, 2001.\n[13] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation,\n9(8):17351780, 1997.\n[14] Zhongqiang Huang and Mary Harper. Self-training PCFG grammars with latent annotations\nacross languages. In Proceedings of the 2009 Conference on Empirical Methods in Natural\nLanguage Processing, pages 832841. ACL, August 2009.\n[15] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring\nthe limits of language modeling. arXiv preprint arXiv:1602.02410, 2016.\n[16] Łukasz Kaiser and Samy Bengio. Can active memory replace attention? In Advances in Neural\nInformation Processing Systems, (NIPS), 2016.\n[17] Łukasz Kaiser and Ilya Sutskever. Neural GPUs learn algorithms. In International Conference\non Learning Representations (ICLR), 2016.\n[18] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Ko-\nray Kavukcuoglu. Neural machine translation in linear time. arXiv preprint arXiv:1610.10099v2,\n2017.\n[19] Yoon Kim, Carl Denton, Luong Hoang, and Alexander M. Rush. Structured attention networks.\nIn International Conference on Learning Representations, 2017.\n[20] Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.\n[21] Oleksii Kuchaiev and Boris Ginsburg. Factorization tricks for LSTM networks. arXiv preprint\narXiv:1703.10722, 2017.\n[22] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen\nZhou, and Yoshua Bengio. A structured self-attentive sentence embedding. arXiv preprint\narXiv:1703.03130, 2017.\n[23] Minh-Thang Luong, Quoc V. Le, Ilya Sutskever, Oriol Vinyals, and Lukasz Kaiser. Multi-task\nsequence to sequence learning. arXiv preprint arXiv:1511.06114, 2015.\n[24] Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-\nbased neural machine translation. arXiv preprint arXiv:1508.04025, 2015.\n11\n\n\n## PDF page 12\n\n[25] Mitchell P Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. Building a large annotated\ncorpus of english: The penn treebank. Computational linguistics, 19(2):313330, 1993.\n[26] David McClosky, Eugene Charniak, and Mark Johnson. Effective self-training for parsing. In\nProceedings of the Human Language Technology Conference of the NAACL, Main Conference,\npages 152159. ACL, June 2006.\n[27] Ankur Parikh, Oscar Täckström, Dipanjan Das, and Jakob Uszkoreit. A decomposable attention\nmodel. In Empirical Methods in Natural Language Processing, 2016.\n[28] Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive\nsummarization. arXiv preprint arXiv:1705.04304, 2017.\n[29] Slav Petrov, Leon Barrett, Romain Thibaux, and Dan Klein. Learning accurate, compact,\nand interpretable tree annotation. In Proceedings of the 21st International Conference on\nComputational Linguistics and 44th Annual Meeting of the ACL, pages 433440. ACL, July\n2006.\n[30] Ofir Press and Lior Wolf. Using the output embedding to improve language models. arXiv\npreprint arXiv:1608.05859, 2016.\n[31] Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words\nwith subword units. arXiv preprint arXiv:1508.07909, 2015.\n[32] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton,\nand Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts\nlayer. arXiv preprint arXiv:1701.06538, 2017.\n[33] Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdi-\nnov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine\nLearning Research, 15(1):19291958, 2014.\n[34] Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory\nnetworks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors,\nAdvances in Neural Information Processing Systems 28, pages 24402448. Curran Associates,\nInc., 2015.\n[35] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. Sequence to sequence learning with neural\nnetworks. In Advances in Neural Information Processing Systems, pages 31043112, 2014.\n[36] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna.\nRethinking the inception architecture for computer vision. CoRR, abs/1512.00567, 2015.\n[37] Vinyals & Kaiser, Koo, Petrov, Sutskever, and Hinton. Grammar as a foreign language. In\nAdvances in Neural Information Processing Systems, 2015.\n[38] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang\nMacherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Googles neural machine\ntranslation system: Bridging the gap between human and machine translation. arXiv preprint\narXiv:1609.08144, 2016.\n[39] Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. Deep recurrent models with\nfast-forward connections for neural machine translation. CoRR, abs/1606.04199, 2016.\n[40] Muhua Zhu, Yue Zhang, Wenliang Chen, Min Zhang, and Jingbo Zhu. Fast and accurate\nshift-reduce constituent parsing. In Proceedings of the 51st Annual Meeting of the ACL (Volume\n1: Long Papers), pages 434443. ACL, August 2013.\n12\n\n\n## PDF page 13\n\nAttention Visualizations\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nFigure 3: An example of the attention mechanism following long-distance dependencies in the\nencoder self-attention in layer 5 of 6. Many of the attention heads attend to a distant dependency of\nthe verb making, completing the phrase making...more difficult. Attentions here shown only for\nthe word making. Different colors represent different heads. Best viewed in color.\n13\n\n\n## PDF page 14\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 4: Two attention heads, also in layer 5 of 6, apparently involved in anaphora resolution. Top:\nFull attentions for head 5. Bottom: Isolated attentions from just the word its for attention heads 5\nand 6. Note that the attentions are very sharp for this word.\n14\n\n\n## PDF page 15\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 5: Many of the attention heads exhibit behaviour that seems related to the structure of the\nsentence. We give two such examples above, from two different heads from the encoder self-attention\nat layer 5 of 6. The heads clearly learned to perform different tasks.\n15\n\n\n可直接引用的图表文件:\n- paper_figure_1_transformer.pngFigure 1 from PDF page 3: The Transformer model architecture.\n- paper_figure_3_long_distance.pngFigure 3 from PDF page 13: Encoder self-attention following long-distance dependencies.\n- paper_figure_4_anaphora.pngFigure 4 from PDF page 14: Attention heads involved in anaphora resolution.\n\n请生成一版 10-20 页的完整初稿。内容必须忠于论文,至少引用上面列出的三张原论文图,并覆盖问题、Transformer 架构、注意力机制、训练、主要实验、局限和结论。不要复制长段原文;每页保持听众可读的信息密度。生成完整的 slides.md。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\n---\n\n# Attention Is All You Need\n## A Revolutionary Architecture for Sequence Transduction\n\nAshish Vaswani et al. \nNIPS 2017\n\n---\n\n## Problem Statement\n\n- Traditional sequence models rely on RNNs or CNNs\n- RNNs have inherent sequential computation (hard to parallelize)\n- CNNs require multiple layers to capture long-range dependencies\n- Both have increasing path lengths between distant positions\n\n**Key Insight**: Replace recurrence and convolution with attention mechanisms\n\n---\n\n## The Transformer: Model Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n- Encoder-decoder structure with stacked self-attention layers\n- No recurrence or convolution\n- Significantly more parallelizable\n\n---\n\n## Encoder Stack\n\n- 6 identical layers\n- Each layer has two sub-layers:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization around each sub-layer\n- Output dimension: d<sub>model</sub> = 512\n\n---\n\n## Decoder Stack\n\n- 6 identical layers\n- Three sub-layers per layer:\n 1. Masked multi-head self-attention\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Masking prevents attending to future positions\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- Queries (Q), Keys (K), Values (V) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradient vanishing\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-40 mx-auto\" />\n\n- Project Q, K, V h times with different linear projections\n- Perform attention in parallel on each projection\n- Concatenate results and project again\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**:\n - Queries from decoder, keys/values from encoder\n - Allows decoder to attend to all input positions\n\n2. **Encoder self-attention**:\n - All Q, K, V from previous encoder layer\n - Each position attends to all positions\n\n3. **Decoder self-attention**:\n - All Q, K, V from previous decoder layer\n - Masked to prevent attending to future positions\n\n---\n\n## Positional Encoding\n\nSince model has no recurrence/convolution, we add positional information:\n\n$$PE_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$PE_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Sinusoidal functions with varying frequencies\n- Allows model to learn relative position information\n- Performed as well as learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------|------------|----------------|-----------------|\n| Self-Attention | O(n²·d) | O(1) | O(1) |\n| Recurrent | O(n·d²) | O(n) | O(n) |\n| Convolutional | O(k·n·d²) | O(1) | O(logₖn) |\n\n- Better parallelization than RNNs\n- Shorter path lengths than CNNs/RNNs\n- More interpretable attention patterns\n\n---\n\n## Training Details\n\n- **Datasets**: WMT 2014 EN-DE (4.5M) and EN-FR (36M)\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Optimizer**: Adam (β₁=0.9, β₂=0.98, ϵ=10⁻⁹)\n- **Learning Rate**: $lrate = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step_num}^{-0.5}, \\text{step_num} \\cdot \\text{warmup_steps}^{-1.5})$\n- **Regularization**: Dropout (P=0.1), Label Smoothing (ϵ=0.1)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|------------------------|\n| GNMT + RL | 24.6 | 39.92 | 2.3·10¹⁹ |\n| ConvS2S | 25.16 | 40.46 | 9.6·10¹⁸ |\n| Transformer (base) | 27.3 | 38.1 | 3.3·10¹⁸ |\n| **Transformer (big)** | **28.4** | **41.8** | **2.3·10¹⁹** |\n\n- Transformer (big) outperforms all previous state-of-the-art\n- Achieves new SOTA with significantly less training cost\n\n---\n\n## Model Variations\n\n| Configuration | Dev PPL | Dev BLEU |\n|---------------|---------|----------|\n| Base | 4.92 | 25.8 |\n| 1 attention head | 5.29 | 24.9 |\n| 32 attention heads | 5.01 | 25.4 |\n| No dropout | 5.77 | 24.6 |\n| Learned positional embeddings | 4.92 | 25.7 |\n| Big model | 4.33 | 26.4 |\n\n- Multiple attention heads improve performance\n- Dropout is crucial for generalization\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Achieves competitive results with minimal task-specific modifications\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n- Attention heads follow distant dependencies\n- Example: Verb \"making\" attends to \"more difficult\"\n- Different colors represent different attention heads\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n- Some heads specialize in resolving pronouns\n- Example: \"its\" clearly attends to \"The Law\"\n- Sharp attention patterns for coreference resolution\n\n---\n\n## Limitations and Future Work\n\n### Limitations:\n- High memory consumption with long sequences (O(n²))\n- Still generates output sequentially\n\n### Future Work:\n- Local, restricted attention mechanisms for large inputs\n- Extend to other modalities (images, audio, video)\n- Make generation less sequential\n- Explore more efficient attention variants\n\n---\n\n## Conclusion\n\n- Transformer is the first transduction model based entirely on attention\n- Replaces RNNs/CNNs with multi-headed self-attention\n- Significantly faster training with better parallelization\n- Achieves new state-of-the-art in machine translation\n- Generalizes well to other sequence tasks like constituency parsing\n\n**Code**: https://github.com/tensorflow/tensor2tensor\n\n---\n\n## Thank You!\n```"
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "这是你上一版 slides.md 渲染出的 19 页截图。请自我审查(文字溢出/拥挤/图片尺寸/可读性/布局),然后输出修订后的完整 slides.md。修订后硬性保持 10–20 页,并保留三张原论文图。"
},
{
"type": "text",
"text": "第 1 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "43e962b781454c3d5eac7723de28844f9fe12cee5370e89387f0273d1c119d0a",
"characters": 89538,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 2 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "38663a48b255317d1b215719cae21f7aa164d6a06e18c33db0fbcb1521e07b08",
"characters": 127194,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 3 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "f2c32e54430c4248aef8efe88184b4ac4e651b33bb90a9363b232e9f6c31b849",
"characters": 163894,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 4 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a133c25660777e180a5ce25bbebc5ec3cf9b4ee399094503834f94b5a19249fb",
"characters": 100590,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 5 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9bbe983962c98389fd510d680ae999581f8df804965e242cb0c188667ffe180a",
"characters": 110394,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 6 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "446675777a3f374f452bfb70617bf46328990e9884d9997a1da802408c9d3d49",
"characters": 109418,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 7 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "d6add7843373ed4062f7f33e3cef9538da774244ac5ef15281a24d9c90b52cd4",
"characters": 125982,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 8 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "d126da4d299d6123fc4fcc5bef77fd481f57c5c379f6ac87c7995961c3d4dd32",
"characters": 145338,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 9 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "39a056fc9e4982e85821c808947c903f85a3cd3236c204fe22887f850db717b0",
"characters": 136346,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 10 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a89b46f3ef9f56d231e8c3c0a0e15d085a0cd45d75a11d7fcef2c3abfe20d33d",
"characters": 123138,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 11 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "1684df3822c5f232dfcc6f42539e91e5b2bb16e383fbbbb25fff3c4bc2d7ff8e",
"characters": 134618,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 12 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "65d72181f5930398c2e0ad9e29ddde08a324c168de9e183a3072a430e03dfcd1",
"characters": 137678,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 13 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "cfd076741770b767919a9b20b0589a6e2b9b48b189b5e2019396fd8ddd89e2a1",
"characters": 142406,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 14 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "8fa0de2217a29efdc146e957d16f97a02293a370513bc67d1dd9eae6870ae056",
"characters": 152318,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 15 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "0d2304a0c4ac2ea569ed1113df08ea926fb94d10a7cb174c8cc3221b1db97481",
"characters": 172402,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 16 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "859bd832f8a544f10d2f4f4d0539f969538126f038d394792e98caede1739d7d",
"characters": 175410,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 17 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "bd8b103b3619b1ff7c24f1846725a3d7dbe9e6788e9ed59145bd98a4a9d777d5",
"characters": 133230,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 18 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "0584853789dc51eb555b312710b70f51538d671471bc1f01af77052331ca4535",
"characters": 137474,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 19 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "e62c27dc16880a560b7826ed349aa24fbacea989919063c5539777d6accbb28e",
"characters": 14014,
"media_type": "image/png"
},
"detail": "high"
}
}
]
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\n---\n\n# Attention Is All You Need\n## A Revolutionary Architecture for Sequence Transduction\n\nAshish Vaswani et al. \nNIPS 2017\n\n---\n\n## Problem Statement\n\n- Traditional sequence models rely on RNNs or CNNs\n- RNNs have inherent sequential computation (hard to parallelize)\n- CNNs require multiple layers to capture long-range dependencies\n- Both have increasing path lengths between distant positions\n\n**Key Insight**: Replace recurrence and convolution with attention mechanisms\n\n---\n\n## The Transformer: Model Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-96 mx-auto\" />\n\n- Encoder-decoder structure with stacked self-attention layers\n- No recurrence or convolution\n- Significantly more parallelizable\n\n---\n\n## Encoder Stack\n\n- 6 identical layers with two sub-layers each:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Output dimension: d<sub>model</sub> = 512\n\n---\n\n## Decoder Stack\n\n- 6 identical layers with three sub-layers each:\n 1. Masked multi-head self-attention\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Masking prevents attending to future positions\n\n---\n\n## Scaled Dot-Product Attention\n\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- Queries (Q), Keys (K), Values (V) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradient vanishing\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-60 mx-auto\" />\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- Project Q, K, V h times with different linear projections\n- Perform attention in parallel on each projection\n- Concatenate results and project again\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**:\n - Queries from decoder, keys/values from encoder\n\n2. **Encoder self-attention**:\n - All Q, K, V from previous encoder layer\n - Each position attends to all positions\n\n3. **Decoder self-attention**:\n - All Q, K, V from previous decoder layer\n - Masked to prevent attending to future positions\n\n---\n\n## Positional Encoding\n\nSince model has no recurrence/convolution, we add positional information:\n\n$$PE_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$PE_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Sinusoidal functions with varying frequencies\n- Allows model to learn relative position information\n- Performed as well as learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------|------------|----------------|-----------------|\n| Self-Attention | O(n²·d) | O(1) | O(1) |\n| Recurrent | O(n·d²) | O(n) | O(n) |\n| Convolutional | O(k·n·d²) | O(1) | O(logₖn) |\n\n- Better parallelization than RNNs\n- Shorter path lengths than CNNs/RNNs\n- More interpretable attention patterns\n\n---\n\n## Training Details\n\n- **Datasets**: WMT 2014 EN-DE (4.5M) and EN-FR (36M)\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Optimizer**: Adam (β₁=0.9, β₂=0.98, ϵ=10⁻⁹)\n- **Learning Rate**: \n $$lrate = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step\\_num}^{-0.5}, \\text{step\\_num} \\cdot \\text{warmup\\_steps}^{-1.5})$$\n- **Regularization**: Dropout (P=0.1), Label Smoothing (ϵ=0.1)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|------------------------|\n| GNMT + RL | 24.6 | 39.92 | 2.3·10¹⁹ |\n| ConvS2S | 25.16 | 40.46 | 9.6·10¹⁸ |\n| Transformer (base) | 27.3 | 38.1 | 3.3·10¹⁸ |\n| **Transformer (big)** | **28.4** | **41.8** | **2.3·10¹⁹** |\n\n- Transformer (big) outperforms all previous state-of-the-art\n- Achieves new SOTA with significantly less training cost\n\n---\n\n## Model Variations\n\n| Configuration | Dev PPL | Dev BLEU |\n|---------------|---------|----------|\n| Base | 4.92 | 25.8 |\n| 1 attention head | 5.29 | 24.9 |\n| 32 attention heads | 5.01 | 25.4 |\n| No dropout | 5.77 | 24.6 |\n| Learned positional embeddings | 4.92 | 25.7 |\n| Big model | 4.33 | 26.4 |\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-80 mx-auto\" />\n\n- Attention heads follow distant dependencies\n- Example: Verb \"making\" attends to \"more difficult\"\n- Different colors represent different attention heads\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-80 mx-auto\" />\n\n- Some heads specialize in resolving pronouns\n- Example: \"its\" clearly attends to \"The Law\"\n- Sharp attention patterns for coreference resolution\n\n---\n\n## Limitations and Future Work\n\n### Limitations:\n- High memory consumption with long sequences (O(n²))\n- Still generates output sequentially\n\n### Future Work:\n- Local, restricted attention mechanisms for large inputs\n- Extend to other modalities (images, audio, video)\n- Make generation less sequential\n\n---\n\n## Conclusion\n\n- Transformer is the first transduction model based entirely on attention\n- Replaces RNNs/CNNs with multi-headed self-attention\n- Significantly faster training with better parallelization\n- Achieves new state-of-the-art in machine translation\n- Generalizes well to other sequence tasks like constituency parsing\n\n**Code**: https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "这是你上一版 slides.md 渲染出的 18 页截图。请自我审查(文字溢出/拥挤/图片尺寸/可读性/布局),然后输出修订后的完整 slides.md。修订后硬性保持 10–20 页,并保留三张原论文图。"
},
{
"type": "text",
"text": "第 1 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "43e962b781454c3d5eac7723de28844f9fe12cee5370e89387f0273d1c119d0a",
"characters": 89538,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 2 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "38663a48b255317d1b215719cae21f7aa164d6a06e18c33db0fbcb1521e07b08",
"characters": 127194,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 3 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "77dfdf7da2c0b7cf2e2d4aa89b146a667500702bbd71ef2a4d2c6af66f0bad4d",
"characters": 189514,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 4 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "cd1b38eeafbf59ed2346609539f07c6c44d10c384be05f51a7f51492c131c0dc",
"characters": 90918,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 5 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "7dfdcbfbdcacc0070e72ced8abf51e2d71316c90c2946cf0e5abe98e4e36e7f2",
"characters": 109930,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 6 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "72fd664cb0eb9254ef2a1e781cd6f9542c221adbfe4a63f3e2d76a51bd6de371",
"characters": 100542,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 7 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "1da47031d1ca1dccf72460f3961eec5fba5633f2b407faaeebd7688d4b1cfa54",
"characters": 150498,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 8 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "2838056a82ff7c63766cbe6e3bba6611cd42162a354df629da52c40267540211",
"characters": 128842,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 9 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "39a056fc9e4982e85821c808947c903f85a3cd3236c204fe22887f850db717b0",
"characters": 136346,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 10 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a89b46f3ef9f56d231e8c3c0a0e15d085a0cd45d75a11d7fcef2c3abfe20d33d",
"characters": 123138,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 11 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9bb99e180f6c7b8384b0d30b31d729b8ceb13dd62eaa01caf91b00ef71b4fb9b",
"characters": 123246,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 12 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "65d72181f5930398c2e0ad9e29ddde08a324c168de9e183a3072a430e03dfcd1",
"characters": 137678,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 13 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "f472a496e8d188487b6ec46151eac0c60465ad412ad1d6e9592472b21af2b449",
"characters": 93350,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 14 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "e156855f85bd50f0feb74b8aa3d93b1a19ec6c5c96a60bd2f648e6220e8ee964",
"characters": 129414,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 15 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "6a406803a2572b7f3db4791dcf104562be21f59d7873ce0364c774e411533a5d",
"characters": 189734,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 16 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "670f9f30f8abf7c62d674ad098177449535487f19962dab65d4ab60154d22f52",
"characters": 194886,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 17 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "97d0320dcb23cb0a8f74db51cd40f029296fabd62303eac5488defbc2e2fcc00",
"characters": 118866,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 18 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "0584853789dc51eb555b312710b70f51538d671471bc1f01af77052331ca4535",
"characters": 137474,
"media_type": "image/png"
},
"detail": "high"
}
}
]
}
],
"temperature": 0.3
},
"response": {
"id": "021785385568331275a44fd862e8b57dcd33414ced196962f2cc0",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "```markdown\n---\ntheme: default\n---\n\n# Attention Is All You Need\n## A Revolutionary Architecture for Sequence Transduction\n\nAshish Vaswani et al. \nNIPS 2017\n\n---\n\n## Problem Statement\n\nTraditional sequence models rely on RNNs or CNNs with critical limitations:\n- **RNNs**: Inherently sequential computation (hard to parallelize)\n- **CNNs**: Require multiple layers to capture long-range dependencies\n- **Both**: Increasing path lengths between distant positions\n\n**Key Insight**: Replace recurrence and convolution with attention mechanisms\n\n---\n\n## The Transformer: Model Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n- Encoder-decoder structure with stacked self-attention layers\n- No recurrence or convolution\n- Significantly more parallelizable\n\n---\n\n## Encoder Stack\n\n- 6 identical layers with two sub-layers each:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Output dimension: d<sub>model</sub> = 512\n\n---\n\n## Decoder Stack\n\n- 6 identical layers with three sub-layers each:\n 1. Masked multi-head self-attention\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Masking prevents attending to future positions\n\n---\n\n## Scaled Dot-Product Attention\n\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- Queries (Q), Keys (K), Values (V) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradient vanishing\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- Project Q, K, V h times with different linear projections\n- Perform attention in parallel on each projection\n- Concatenate results and project again\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**:\n - Queries from decoder, keys/values from encoder\n\n2. **Encoder self-attention**:\n - All Q, K, V from previous encoder layer\n - Each position attends to all positions\n\n3. **Decoder self-attention**:\n - All Q, K, V from previous decoder layer\n - Masked to prevent attending to future positions\n\n---\n\n## Positional Encoding\n\nSince model has no recurrence/convolution, we add positional information:\n\n$$PE_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$PE_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Sinusoidal functions with varying frequencies\n- Allows model to learn relative position information\n- Performed as well as learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------|------------|----------------|-----------------|\n| Self-Attention | O(n²·d) | O(1) | O(1) |\n| Recurrent | O(n·d²) | O(n) | O(n) |\n| Convolutional | O(k·n·d²) | O(1) | O(logₖn) |\n\n- Better parallelization than RNNs\n- Shorter path lengths than CNNs/RNNs\n- More interpretable attention patterns\n\n---\n\n## Training Details\n\n- **Datasets**: WMT 2014 EN-DE (4.5M) and EN-FR (36M)\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Optimizer**: Adam (β₁=0.9, β₂=0.98, ϵ=10⁻⁹)\n- **Learning Rate**: \n $$lrate = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step\\_num}^{-0.5}, \\text{step\\_num} \\cdot \\text{warmup\\_steps}^{-1.5})$$\n- **Regularization**: Dropout (P=0.1), Label Smoothing (ϵ=0.1)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|------------------------|\n| GNMT + RL | 24.6 | 39.92 | 2.3·10¹⁹ |\n| ConvS2S | 25.16 | 40.46 | 9.6·10¹⁸ |\n| Transformer (base) | 27.3 | 38.1 | 3.3·10¹⁸ |\n| **Transformer (big)** | **28.4** | **41.8** | **2.3·10¹⁹** |\n\n- Transformer (big) outperforms all previous state-of-the-art\n- Achieves new SOTA with significantly less training cost\n\n---\n\n## Model Variations\n\n| Configuration | Dev PPL | Dev BLEU |\n|---------------|---------|----------|\n| Base | 4.92 | 25.8 |\n| 1 attention head | 5.29 | 24.9 |\n| 32 attention heads | 5.01 | 25.4 |\n| No dropout | 5.77 | 24.6 |\n| Learned positional embeddings | 4.92 | 25.7 |\n| Big model | 4.33 | 26.4 |\n\n**Key Findings**:\n- Multiple attention heads improve performance\n- Dropout is crucial for generalization\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Achieves competitive results with minimal task-specific modifications\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-72 mx-auto\" />\n\n- Attention heads follow distant dependencies\n- Example: Verb \"making\" attends to \"more difficult\"\n- Different colors represent different attention heads\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-72 mx-auto\" />\n\n- Some heads specialize in resolving pronouns\n- Example: \"its\" clearly attends to \"The Law\"\n- Sharp attention patterns for coreference resolution\n\n---\n\n## Limitations and Future Work\n\n### Limitations:\n- High memory consumption with long sequences (O(n²))\n- Still generates output sequentially\n\n### Future Work:\n- Local, restricted attention mechanisms for large inputs\n- Extend to other modalities (images, audio, video)\n- Make generation less sequential\n\n---\n\n## Conclusion\n\n- Transformer is the first transduction model based entirely on attention\n- Replaces RNNs/CNNs with multi-headed self-attention\n- Significantly faster training with better parallelization\n- Achieves new state-of-the-art in machine translation\n- Generalizes well to other sequence tasks like constituency parsing\n```"
},
"usage": {
"prompt_tokens": 59379,
"completion_tokens": 2210,
"total_tokens": 61589,
"cached_prompt_tokens": 0
}
},
{
"meter": "SingleAgent(自审, 图片累积)",
"called_at_utc": "2026-07-30T04:28:13.827892+00:00",
"latency_s": 58.601,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名擅长把学术论文转化为演示文稿的 Proposer Agent。\n你用 Slidev 框架(Markdown + HTML)编写 PPT 源码 slides.md。\n\nSlidev 语法要点:\n- 文件开头是 YAML frontmatter--- 包裹),设置 theme: default。\n- 用单独一行的 `---`(前后空行)分隔每一页幻灯片。\n- 首页通常放标题、作者、会议。\n- 引用图片用 markdown![说明](/图片文件名.png),可用 HTML 控制尺寸,\n 例如 <img src=\"/speedup_bar.png\" class=\"h-60 mx-auto\" />。\n- 可用 Windi/Uno CSS 工具类控制排版(如 text-sm、grid grid-cols-2 gap-4)。\n\n要求:\n- 最终生成 10-20 页,覆盖论文的标题、背景/动机、方法、实验结果、局限与结论。\n- 至少在 3 页中使用提供的图表/表格,且图文匹配。\n- 每页信息量适中、不要塞太多字,宁可拆页也不要溢出。\n- 只输出 slides.md 的完整内容,用 ```markdown 代码块包裹,不要额外解释。\n\n此外,你还要**自我审查**:当收到自己 PPT 的渲染截图时,先在心里按下列标准找出问题\n(文字溢出、内容拥挤、图片尺寸、可读性、布局),再据此输出修订后的完整 slides.md。"
},
{
"role": "user",
"content": "以下是论文全文(Markdown):\n\n# Attention Is All You Need\n\nAuthors: Ashish Vaswani et al.\n\n\n## PDF page 1\n\nProvided proper attribution is provided, Google hereby grants permission to\nreproduce the tables and figures in this paper solely for use in journalistic or\nscholarly works.\nAttention Is All You Need\nAshish Vaswani\nGoogle Brain\navaswani@google.com\nNoam Shazeer\nGoogle Brain\nnoam@google.com\nNiki Parmar\nGoogle Research\nnikip@google.com\nJakob Uszkoreit\nGoogle Research\nusz@google.com\nLlion Jones\nGoogle Research\nllion@google.com\nAidan N. Gomez∗†\nUniversity of Toronto\naidan@cs.toronto.edu\nŁukasz Kaiser\nGoogle Brain\nlukaszkaiser@google.com\nIllia Polosukhin∗‡\nillia.polosukhin@gmail.com\nAbstract\nThe dominant sequence transduction models are based on complex recurrent or\nconvolutional neural networks that include an encoder and a decoder. The best\nperforming models also connect the encoder and decoder through an attention\nmechanism. We propose a new simple network architecture, the Transformer,\nbased solely on attention mechanisms, dispensing with recurrence and convolutions\nentirely. Experiments on two machine translation tasks show these models to\nbe superior in quality while being more parallelizable and requiring significantly\nless time to train. Our model achieves 28.4 BLEU on the WMT 2014 English-\nto-German translation task, improving over the existing best results, including\nensembles, by over 2 BLEU. On the WMT 2014 English-to-French translation task,\nour model establishes a new single-model state-of-the-art BLEU score of 41.8 after\ntraining for 3.5 days on eight GPUs, a small fraction of the training costs of the\nbest models from the literature. We show that the Transformer generalizes well to\nother tasks by applying it successfully to English constituency parsing both with\nlarge and limited training data.\nEqual contribution. Listing order is random. Jakob proposed replacing RNNs with self-attention and started\nthe effort to evaluate this idea. Ashish, with Illia, designed and implemented the first Transformer models and\nhas been crucially involved in every aspect of this work. Noam proposed scaled dot-product attention, multi-head\nattention and the parameter-free position representation and became the other person involved in nearly every\ndetail. Niki designed, implemented, tuned and evaluated countless model variants in our original codebase and\ntensor2tensor. Llion also experimented with novel model variants, was responsible for our initial codebase, and\nefficient inference and visualizations. Lukasz and Aidan spent countless long days designing various parts of and\nimplementing tensor2tensor, replacing our earlier codebase, greatly improving results and massively accelerating\nour research.\n†Work performed while at Google Brain.\n‡Work performed while at Google Research.\n31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA.\narXiv:1706.03762v7 [cs.CL] 2 Aug 2023\n\n\n## PDF page 2\n\n1\nIntroduction\nRecurrent neural networks, long short-term memory [13] and gated recurrent [7] neural networks\nin particular, have been firmly established as state of the art approaches in sequence modeling and\ntransduction problems such as language modeling and machine translation [35, 2, 5]. Numerous\nefforts have since continued to push the boundaries of recurrent language models and encoder-decoder\narchitectures [38, 24, 15].\nRecurrent models typically factor computation along the symbol positions of the input and output\nsequences. Aligning the positions to steps in computation time, they generate a sequence of hidden\nstates ht, as a function of the previous hidden state ht1 and the input for position t. This inherently\nsequential nature precludes parallelization within training examples, which becomes critical at longer\nsequence lengths, as memory constraints limit batching across examples. Recent work has achieved\nsignificant improvements in computational efficiency through factorization tricks [21] and conditional\ncomputation [32], while also improving model performance in case of the latter. The fundamental\nconstraint of sequential computation, however, remains.\nAttention mechanisms have become an integral part of compelling sequence modeling and transduc-\ntion models in various tasks, allowing modeling of dependencies without regard to their distance in\nthe input or output sequences [2, 19]. In all but a few cases [27], however, such attention mechanisms\nare used in conjunction with a recurrent network.\nIn this work we propose the Transformer, a model architecture eschewing recurrence and instead\nrelying entirely on an attention mechanism to draw global dependencies between input and output.\nThe Transformer allows for significantly more parallelization and can reach a new state of the art in\ntranslation quality after being trained for as little as twelve hours on eight P100 GPUs.\n2\nBackground\nThe goal of reducing sequential computation also forms the foundation of the Extended Neural GPU\n[16], ByteNet [18] and ConvS2S [9], all of which use convolutional neural networks as basic building\nblock, computing hidden representations in parallel for all input and output positions. In these models,\nthe number of operations required to relate signals from two arbitrary input or output positions grows\nin the distance between positions, linearly for ConvS2S and logarithmically for ByteNet. This makes\nit more difficult to learn dependencies between distant positions [12]. In the Transformer this is\nreduced to a constant number of operations, albeit at the cost of reduced effective resolution due\nto averaging attention-weighted positions, an effect we counteract with Multi-Head Attention as\ndescribed in section 3.2.\nSelf-attention, sometimes called intra-attention is an attention mechanism relating different positions\nof a single sequence in order to compute a representation of the sequence. Self-attention has been\nused successfully in a variety of tasks including reading comprehension, abstractive summarization,\ntextual entailment and learning task-independent sentence representations [4, 27, 28, 22].\nEnd-to-end memory networks are based on a recurrent attention mechanism instead of sequence-\naligned recurrence and have been shown to perform well on simple-language question answering and\nlanguage modeling tasks [34].\nTo the best of our knowledge, however, the Transformer is the first transduction model relying\nentirely on self-attention to compute representations of its input and output without using sequence-\naligned RNNs or convolution. In the following sections, we will describe the Transformer, motivate\nself-attention and discuss its advantages over models such as [17, 18] and [9].\n3\nModel Architecture\nMost competitive neural sequence transduction models have an encoder-decoder structure [5, 2, 35].\nHere, the encoder maps an input sequence of symbol representations (x1, ..., xn) to a sequence\nof continuous representations z = (z1, ..., zn). Given z, the decoder then generates an output\nsequence (y1, ..., ym) of symbols one element at a time. At each step the model is auto-regressive\n[10], consuming the previously generated symbols as additional input when generating the next.\n2\n\n\n## PDF page 3\n\nFigure 1: The Transformer - model architecture.\nThe Transformer follows this overall architecture using stacked self-attention and point-wise, fully\nconnected layers for both the encoder and decoder, shown in the left and right halves of Figure 1,\nrespectively.\n3.1\nEncoder and Decoder Stacks\nEncoder:\nThe encoder is composed of a stack of N = 6 identical layers. Each layer has two\nsub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, position-\nwise fully connected feed-forward network. We employ a residual connection [11] around each of\nthe two sub-layers, followed by layer normalization [1]. That is, the output of each sub-layer is\nLayerNorm(x + Sublayer(x)), where Sublayer(x) is the function implemented by the sub-layer\nitself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding\nlayers, produce outputs of dimension dmodel = 512.\nDecoder:\nThe decoder is also composed of a stack of N = 6 identical layers. In addition to the two\nsub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head\nattention over the output of the encoder stack. Similar to the encoder, we employ residual connections\naround each of the sub-layers, followed by layer normalization. We also modify the self-attention\nsub-layer in the decoder stack to prevent positions from attending to subsequent positions. This\nmasking, combined with fact that the output embeddings are offset by one position, ensures that the\npredictions for position i can depend only on the known outputs at positions less than i.\n3.2\nAttention\nAn attention function can be described as mapping a query and a set of key-value pairs to an output,\nwhere the query, keys, values, and output are all vectors. The output is computed as a weighted sum\n3\n\n\n## PDF page 4\n\nScaled Dot-Product Attention\nMulti-Head Attention\nFigure 2: (left) Scaled Dot-Product Attention. (right) Multi-Head Attention consists of several\nattention layers running in parallel.\nof the values, where the weight assigned to each value is computed by a compatibility function of the\nquery with the corresponding key.\n3.2.1\nScaled Dot-Product Attention\nWe call our particular attention \"Scaled Dot-Product Attention\" (Figure 2). The input consists of\nqueries and keys of dimension dk, and values of dimension dv. We compute the dot products of the\nquery with all keys, divide each by √dk, and apply a softmax function to obtain the weights on the\nvalues.\nIn practice, we compute the attention function on a set of queries simultaneously, packed together\ninto a matrix Q. The keys and values are also packed together into matrices K and V . We compute\nthe matrix of outputs as:\nAttention(Q, K, V ) = softmax(QKT\n√dk\n)V\n(1)\nThe two most commonly used attention functions are additive attention [2], and dot-product (multi-\nplicative) attention. Dot-product attention is identical to our algorithm, except for the scaling factor\nof\n1\n√dk . Additive attention computes the compatibility function using a feed-forward network with\na single hidden layer. While the two are similar in theoretical complexity, dot-product attention is\nmuch faster and more space-efficient in practice, since it can be implemented using highly optimized\nmatrix multiplication code.\nWhile for small values of dk the two mechanisms perform similarly, additive attention outperforms\ndot product attention without scaling for larger values of dk [3]. We suspect that for large values of\ndk, the dot products grow large in magnitude, pushing the softmax function into regions where it has\nextremely small gradients 4. To counteract this effect, we scale the dot products by\n1\n√dk .\n3.2.2\nMulti-Head Attention\nInstead of performing a single attention function with dmodel-dimensional keys, values and queries,\nwe found it beneficial to linearly project the queries, keys and values h times with different, learned\nlinear projections to dk, dk and dv dimensions, respectively. On each of these projected versions of\nqueries, keys and values we then perform the attention function in parallel, yielding dv-dimensional\n4To illustrate why the dot products get large, assume that the components of q and k are independent random\nvariables with mean 0 and variance 1. Then their dot product, q · k = Pdk\ni=1 qiki, has mean 0 and variance dk.\n4\n\n\n## PDF page 5\n\noutput values. These are concatenated and once again projected, resulting in the final values, as\ndepicted in Figure 2.\nMulti-head attention allows the model to jointly attend to information from different representation\nsubspaces at different positions. With a single attention head, averaging inhibits this.\nMultiHead(Q, K, V ) = Concat(head1, ..., headh)W O\nwhere headi = Attention(QW Q\ni , KW K\ni , V W V\ni )\nWhere the projections are parameter matrices W Q\ni\n∈Rdmodel×dk, W K\ni\n∈Rdmodel×dk, W V\ni\n∈Rdmodel×dv\nand W O ∈Rhdv×dmodel.\nIn this work we employ h = 8 parallel attention layers, or heads. For each of these we use\ndk = dv = dmodel/h = 64. Due to the reduced dimension of each head, the total computational cost\nis similar to that of single-head attention with full dimensionality.\n3.2.3\nApplications of Attention in our Model\nThe Transformer uses multi-head attention in three different ways:\n• In \"encoder-decoder attention\" layers, the queries come from the previous decoder layer,\nand the memory keys and values come from the output of the encoder. This allows every\nposition in the decoder to attend over all positions in the input sequence. This mimics the\ntypical encoder-decoder attention mechanisms in sequence-to-sequence models such as\n[38, 2, 9].\n• The encoder contains self-attention layers. In a self-attention layer all of the keys, values\nand queries come from the same place, in this case, the output of the previous layer in the\nencoder. Each position in the encoder can attend to all positions in the previous layer of the\nencoder.\n• Similarly, self-attention layers in the decoder allow each position in the decoder to attend to\nall positions in the decoder up to and including that position. We need to prevent leftward\ninformation flow in the decoder to preserve the auto-regressive property. We implement this\ninside of scaled dot-product attention by masking out (setting to −∞) all values in the input\nof the softmax which correspond to illegal connections. See Figure 2.\n3.3\nPosition-wise Feed-Forward Networks\nIn addition to attention sub-layers, each of the layers in our encoder and decoder contains a fully\nconnected feed-forward network, which is applied to each position separately and identically. This\nconsists of two linear transformations with a ReLU activation in between.\nFFN(x) = max(0, xW1 + b1)W2 + b2\n(2)\nWhile the linear transformations are the same across different positions, they use different parameters\nfrom layer to layer. Another way of describing this is as two convolutions with kernel size 1.\nThe dimensionality of input and output is dmodel = 512, and the inner-layer has dimensionality\ndff = 2048.\n3.4\nEmbeddings and Softmax\nSimilarly to other sequence transduction models, we use learned embeddings to convert the input\ntokens and output tokens to vectors of dimension dmodel. We also use the usual learned linear transfor-\nmation and softmax function to convert the decoder output to predicted next-token probabilities. In\nour model, we share the same weight matrix between the two embedding layers and the pre-softmax\nlinear transformation, similar to [30]. In the embedding layers, we multiply those weights by √dmodel.\n5\n\n\n## PDF page 6\n\nTable 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations\nfor different layer types. n is the sequence length, d is the representation dimension, k is the kernel\nsize of convolutions and r the size of the neighborhood in restricted self-attention.\nLayer Type\nComplexity per Layer\nSequential\nMaximum Path Length\nOperations\nSelf-Attention\nO(n2 · d)\nO(1)\nO(1)\nRecurrent\nO(n · d2)\nO(n)\nO(n)\nConvolutional\nO(k · n · d2)\nO(1)\nO(logk(n))\nSelf-Attention (restricted)\nO(r · n · d)\nO(1)\nO(n/r)\n3.5\nPositional Encoding\nSince our model contains no recurrence and no convolution, in order for the model to make use of the\norder of the sequence, we must inject some information about the relative or absolute position of the\ntokens in the sequence. To this end, we add \"positional encodings\" to the input embeddings at the\nbottoms of the encoder and decoder stacks. The positional encodings have the same dimension dmodel\nas the embeddings, so that the two can be summed. There are many choices of positional encodings,\nlearned and fixed [9].\nIn this work, we use sine and cosine functions of different frequencies:\nPE(pos,2i) = sin(pos/100002i/dmodel)\nPE(pos,2i+1) = cos(pos/100002i/dmodel)\nwhere pos is the position and i is the dimension. That is, each dimension of the positional encoding\ncorresponds to a sinusoid. The wavelengths form a geometric progression from 2π to 10000 · 2π. We\nchose this function because we hypothesized it would allow the model to easily learn to attend by\nrelative positions, since for any fixed offset k, PEpos+k can be represented as a linear function of\nPEpos.\nWe also experimented with using learned positional embeddings [9] instead, and found that the two\nversions produced nearly identical results (see Table 3 row (E)). We chose the sinusoidal version\nbecause it may allow the model to extrapolate to sequence lengths longer than the ones encountered\nduring training.\n4\nWhy Self-Attention\nIn this section we compare various aspects of self-attention layers to the recurrent and convolu-\ntional layers commonly used for mapping one variable-length sequence of symbol representations\n(x1, ..., xn) to another sequence of equal length (z1, ..., zn), with xi, zi ∈Rd, such as a hidden\nlayer in a typical sequence transduction encoder or decoder. Motivating our use of self-attention we\nconsider three desiderata.\nOne is the total computational complexity per layer. Another is the amount of computation that can\nbe parallelized, as measured by the minimum number of sequential operations required.\nThe third is the path length between long-range dependencies in the network. Learning long-range\ndependencies is a key challenge in many sequence transduction tasks. One key factor affecting the\nability to learn such dependencies is the length of the paths forward and backward signals have to\ntraverse in the network. The shorter these paths between any combination of positions in the input\nand output sequences, the easier it is to learn long-range dependencies [12]. Hence we also compare\nthe maximum path length between any two input and output positions in networks composed of the\ndifferent layer types.\nAs noted in Table 1, a self-attention layer connects all positions with a constant number of sequentially\nexecuted operations, whereas a recurrent layer requires O(n) sequential operations. In terms of\ncomputational complexity, self-attention layers are faster than recurrent layers when the sequence\n6\n\n\n## PDF page 7\n\nlength n is smaller than the representation dimensionality d, which is most often the case with\nsentence representations used by state-of-the-art models in machine translations, such as word-piece\n[38] and byte-pair [31] representations. To improve computational performance for tasks involving\nvery long sequences, self-attention could be restricted to considering only a neighborhood of size r in\nthe input sequence centered around the respective output position. This would increase the maximum\npath length to O(n/r). We plan to investigate this approach further in future work.\nA single convolutional layer with kernel width k < n does not connect all pairs of input and output\npositions. Doing so requires a stack of O(n/k) convolutional layers in the case of contiguous kernels,\nor O(logk(n)) in the case of dilated convolutions [18], increasing the length of the longest paths\nbetween any two positions in the network. Convolutional layers are generally more expensive than\nrecurrent layers, by a factor of k. Separable convolutions [6], however, decrease the complexity\nconsiderably, to O(k · n · d + n · d2). Even with k = n, however, the complexity of a separable\nconvolution is equal to the combination of a self-attention layer and a point-wise feed-forward layer,\nthe approach we take in our model.\nAs side benefit, self-attention could yield more interpretable models. We inspect attention distributions\nfrom our models and present and discuss examples in the appendix. Not only do individual attention\nheads clearly learn to perform different tasks, many appear to exhibit behavior related to the syntactic\nand semantic structure of the sentences.\n5\nTraining\nThis section describes the training regime for our models.\n5.1\nTraining Data and Batching\nWe trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million\nsentence pairs. Sentences were encoded using byte-pair encoding [3], which has a shared source-\ntarget vocabulary of about 37000 tokens. For English-French, we used the significantly larger WMT\n2014 English-French dataset consisting of 36M sentences and split tokens into a 32000 word-piece\nvocabulary [38]. Sentence pairs were batched together by approximate sequence length. Each training\nbatch contained a set of sentence pairs containing approximately 25000 source tokens and 25000\ntarget tokens.\n5.2\nHardware and Schedule\nWe trained our models on one machine with 8 NVIDIA P100 GPUs. For our base models using\nthe hyperparameters described throughout the paper, each training step took about 0.4 seconds. We\ntrained the base models for a total of 100,000 steps or 12 hours. For our big models,(described on the\nbottom line of table 3), step time was 1.0 seconds. The big models were trained for 300,000 steps\n(3.5 days).\n5.3\nOptimizer\nWe used the Adam optimizer [20] with β1 = 0.9, β2 = 0.98 and ϵ = 109. We varied the learning\nrate over the course of training, according to the formula:\nlrate = d0.5\nmodel · min(step_num0.5, step_num · warmup_steps1.5)\n(3)\nThis corresponds to increasing the learning rate linearly for the first warmup_steps training steps,\nand decreasing it thereafter proportionally to the inverse square root of the step number. We used\nwarmup_steps = 4000.\n5.4\nRegularization\nWe employ three types of regularization during training:\n7\n\n\n## PDF page 8\n\nTable 2: The Transformer achieves better BLEU scores than previous state-of-the-art models on the\nEnglish-to-German and English-to-French newstest2014 tests at a fraction of the training cost.\nModel\nBLEU\nTraining Cost (FLOPs)\nEN-DE\nEN-FR\nEN-DE\nEN-FR\nByteNet [18]\n23.75\nDeep-Att + PosUnk [39]\n39.2\n1.0 · 1020\nGNMT + RL [38]\n24.6\n39.92\n2.3 · 1019\n1.4 · 1020\nConvS2S [9]\n25.16\n40.46\n9.6 · 1018\n1.5 · 1020\nMoE [32]\n26.03\n40.56\n2.0 · 1019\n1.2 · 1020\nDeep-Att + PosUnk Ensemble [39]\n40.4\n8.0 · 1020\nGNMT + RL Ensemble [38]\n26.30\n41.16\n1.8 · 1020\n1.1 · 1021\nConvS2S Ensemble [9]\n26.36\n41.29\n7.7 · 1019\n1.2 · 1021\nTransformer (base model)\n27.3\n38.1\n3.3 · 1018\nTransformer (big)\n28.4\n41.8\n2.3 · 1019\nResidual Dropout\nWe apply dropout [33] to the output of each sub-layer, before it is added to the\nsub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the\npositional encodings in both the encoder and decoder stacks. For the base model, we use a rate of\nPdrop = 0.1.\nLabel Smoothing\nDuring training, we employed label smoothing of value ϵls = 0.1 [36]. This\nhurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.\n6\nResults\n6.1\nMachine Translation\nOn the WMT 2014 English-to-German translation task, the big transformer model (Transformer (big)\nin Table 2) outperforms the best previously reported models (including ensembles) by more than 2.0\nBLEU, establishing a new state-of-the-art BLEU score of 28.4. The configuration of this model is\nlisted in the bottom line of Table 3. Training took 3.5 days on 8 P100 GPUs. Even our base model\nsurpasses all previously published models and ensembles, at a fraction of the training cost of any of\nthe competitive models.\nOn the WMT 2014 English-to-French translation task, our big model achieves a BLEU score of 41.0,\noutperforming all of the previously published single models, at less than 1/4 the training cost of the\nprevious state-of-the-art model. The Transformer (big) model trained for English-to-French used\ndropout rate Pdrop = 0.1, instead of 0.3.\nFor the base models, we used a single model obtained by averaging the last 5 checkpoints, which\nwere written at 10-minute intervals. For the big models, we averaged the last 20 checkpoints. We\nused beam search with a beam size of 4 and length penalty α = 0.6 [38]. These hyperparameters\nwere chosen after experimentation on the development set. We set the maximum output length during\ninference to input length + 50, but terminate early when possible [38].\nTable 2 summarizes our results and compares our translation quality and training costs to other model\narchitectures from the literature. We estimate the number of floating point operations used to train a\nmodel by multiplying the training time, the number of GPUs used, and an estimate of the sustained\nsingle-precision floating-point capacity of each GPU 5.\n6.2\nModel Variations\nTo evaluate the importance of different components of the Transformer, we varied our base model\nin different ways, measuring the change in performance on English-to-German translation on the\n5We used values of 2.8, 3.7, 6.0 and 9.5 TFLOPS for K80, K40, M40 and P100, respectively.\n8\n\n\n## PDF page 9\n\nTable 3: Variations on the Transformer architecture. Unlisted values are identical to those of the base\nmodel. All metrics are on the English-to-German translation development set, newstest2013. Listed\nperplexities are per-wordpiece, according to our byte-pair encoding, and should not be compared to\nper-word perplexities.\nN\ndmodel\ndff\nh\ndk\ndv\nPdrop\nϵls\ntrain\nPPL\nBLEU\nparams\nsteps\n(dev)\n(dev)\n×106\nbase\n6\n512\n2048\n8\n64\n64\n0.1\n0.1\n100K\n4.92\n25.8\n65\n(A)\n1\n512\n512\n5.29\n24.9\n4\n128\n128\n5.00\n25.5\n16\n32\n32\n4.91\n25.8\n32\n16\n16\n5.01\n25.4\n(B)\n16\n5.16\n25.1\n58\n32\n5.01\n25.4\n60\n(C)\n2\n6.11\n23.7\n36\n4\n5.19\n25.3\n50\n8\n4.88\n25.5\n80\n256\n32\n32\n5.75\n24.5\n28\n1024\n128\n128\n4.66\n26.0\n168\n1024\n5.12\n25.4\n53\n4096\n4.75\n26.2\n90\n(D)\n0.0\n5.77\n24.6\n0.2\n4.95\n25.5\n0.0\n4.67\n25.3\n0.2\n5.47\n25.7\n(E)\npositional embedding instead of sinusoids\n4.92\n25.7\nbig\n6\n1024\n4096\n16\n0.3\n300K\n4.33\n26.4\n213\ndevelopment set, newstest2013. We used beam search as described in the previous section, but no\ncheckpoint averaging. We present these results in Table 3.\nIn Table 3 rows (A), we vary the number of attention heads and the attention key and value dimensions,\nkeeping the amount of computation constant, as described in Section 3.2.2. While single-head\nattention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.\nIn Table 3 rows (B), we observe that reducing the attention key size dk hurts model quality. This\nsuggests that determining compatibility is not easy and that a more sophisticated compatibility\nfunction than dot product may be beneficial. We further observe in rows (C) and (D) that, as expected,\nbigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our\nsinusoidal positional encoding with learned positional embeddings [9], and observe nearly identical\nresults to the base model.\n6.3\nEnglish Constituency Parsing\nTo evaluate if the Transformer can generalize to other tasks we performed experiments on English\nconstituency parsing. This task presents specific challenges: the output is subject to strong structural\nconstraints and is significantly longer than the input. Furthermore, RNN sequence-to-sequence\nmodels have not been able to attain state-of-the-art results in small-data regimes [37].\nWe trained a 4-layer transformer with dmodel = 1024 on the Wall Street Journal (WSJ) portion of the\nPenn Treebank [25], about 40K training sentences. We also trained it in a semi-supervised setting,\nusing the larger high-confidence and BerkleyParser corpora from with approximately 17M sentences\n[37]. We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens\nfor the semi-supervised setting.\nWe performed only a small number of experiments to select the dropout, both attention and residual\n(section 5.4), learning rates and beam size on the Section 22 development set, all other parameters\nremained unchanged from the English-to-German base translation model. During inference, we\n9\n\n\n## PDF page 10\n\nTable 4: The Transformer generalizes well to English constituency parsing (Results are on Section 23\nof WSJ)\nParser\nTraining\nWSJ 23 F1\nVinyals & Kaiser el al. (2014) [37]\nWSJ only, discriminative\n88.3\nPetrov et al. (2006) [29]\nWSJ only, discriminative\n90.4\nZhu et al. (2013) [40]\nWSJ only, discriminative\n90.4\nDyer et al. (2016) [8]\nWSJ only, discriminative\n91.7\nTransformer (4 layers)\nWSJ only, discriminative\n91.3\nZhu et al. (2013) [40]\nsemi-supervised\n91.3\nHuang & Harper (2009) [14]\nsemi-supervised\n91.3\nMcClosky et al. (2006) [26]\nsemi-supervised\n92.1\nVinyals & Kaiser el al. (2014) [37]\nsemi-supervised\n92.1\nTransformer (4 layers)\nsemi-supervised\n92.7\nLuong et al. (2015) [23]\nmulti-task\n93.0\nDyer et al. (2016) [8]\ngenerative\n93.3\nincreased the maximum output length to input length + 300. We used a beam size of 21 and α = 0.3\nfor both WSJ only and the semi-supervised setting.\nOur results in Table 4 show that despite the lack of task-specific tuning our model performs sur-\nprisingly well, yielding better results than all previously reported models with the exception of the\nRecurrent Neural Network Grammar [8].\nIn contrast to RNN sequence-to-sequence models [37], the Transformer outperforms the Berkeley-\nParser [29] even when training only on the WSJ training set of 40K sentences.\n7\nConclusion\nIn this work, we presented the Transformer, the first sequence transduction model based entirely on\nattention, replacing the recurrent layers most commonly used in encoder-decoder architectures with\nmulti-headed self-attention.\nFor translation tasks, the Transformer can be trained significantly faster than architectures based\non recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014\nEnglish-to-French translation tasks, we achieve a new state of the art. In the former task our best\nmodel outperforms even all previously reported ensembles.\nWe are excited about the future of attention-based models and plan to apply them to other tasks. We\nplan to extend the Transformer to problems involving input and output modalities other than text and\nto investigate local, restricted attention mechanisms to efficiently handle large inputs and outputs\nsuch as images, audio and video. Making generation less sequential is another research goals of ours.\nThe code we used to train and evaluate our models is available at https://github.com/\ntensorflow/tensor2tensor.\nAcknowledgements\nWe are grateful to Nal Kalchbrenner and Stephan Gouws for their fruitful\ncomments, corrections and inspiration.\nReferences\n[1] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint\narXiv:1607.06450, 2016.\n[2] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly\nlearning to align and translate. CoRR, abs/1409.0473, 2014.\n[3] Denny Britz, Anna Goldie, Minh-Thang Luong, and Quoc V. Le. Massive exploration of neural\nmachine translation architectures. CoRR, abs/1703.03906, 2017.\n[4] Jianpeng Cheng, Li Dong, and Mirella Lapata. Long short-term memory-networks for machine\nreading. arXiv preprint arXiv:1601.06733, 2016.\n10\n\n\n## PDF page 11\n\n[5] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk,\nand Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical\nmachine translation. CoRR, abs/1406.1078, 2014.\n[6] Francois Chollet. Xception: Deep learning with depthwise separable convolutions. arXiv\npreprint arXiv:1610.02357, 2016.\n[7] Junyoung Chung, Çaglar Gülçehre, Kyunghyun Cho, and Yoshua Bengio. Empirical evaluation\nof gated recurrent neural networks on sequence modeling. CoRR, abs/1412.3555, 2014.\n[8] Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, and Noah A. Smith. Recurrent neural\nnetwork grammars. In Proc. of NAACL, 2016.\n[9] Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. Convolu-\ntional sequence to sequence learning. arXiv preprint arXiv:1705.03122v2, 2017.\n[10] Alex Graves.\nGenerating sequences with recurrent neural networks.\narXiv preprint\narXiv:1308.0850, 2013.\n[11] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for im-\nage recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern\nRecognition, pages 770778, 2016.\n[12] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber. Gradient flow in\nrecurrent nets: the difficulty of learning long-term dependencies, 2001.\n[13] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation,\n9(8):17351780, 1997.\n[14] Zhongqiang Huang and Mary Harper. Self-training PCFG grammars with latent annotations\nacross languages. In Proceedings of the 2009 Conference on Empirical Methods in Natural\nLanguage Processing, pages 832841. ACL, August 2009.\n[15] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring\nthe limits of language modeling. arXiv preprint arXiv:1602.02410, 2016.\n[16] Łukasz Kaiser and Samy Bengio. Can active memory replace attention? In Advances in Neural\nInformation Processing Systems, (NIPS), 2016.\n[17] Łukasz Kaiser and Ilya Sutskever. Neural GPUs learn algorithms. In International Conference\non Learning Representations (ICLR), 2016.\n[18] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Ko-\nray Kavukcuoglu. Neural machine translation in linear time. arXiv preprint arXiv:1610.10099v2,\n2017.\n[19] Yoon Kim, Carl Denton, Luong Hoang, and Alexander M. Rush. Structured attention networks.\nIn International Conference on Learning Representations, 2017.\n[20] Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.\n[21] Oleksii Kuchaiev and Boris Ginsburg. Factorization tricks for LSTM networks. arXiv preprint\narXiv:1703.10722, 2017.\n[22] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen\nZhou, and Yoshua Bengio. A structured self-attentive sentence embedding. arXiv preprint\narXiv:1703.03130, 2017.\n[23] Minh-Thang Luong, Quoc V. Le, Ilya Sutskever, Oriol Vinyals, and Lukasz Kaiser. Multi-task\nsequence to sequence learning. arXiv preprint arXiv:1511.06114, 2015.\n[24] Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-\nbased neural machine translation. arXiv preprint arXiv:1508.04025, 2015.\n11\n\n\n## PDF page 12\n\n[25] Mitchell P Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. Building a large annotated\ncorpus of english: The penn treebank. Computational linguistics, 19(2):313330, 1993.\n[26] David McClosky, Eugene Charniak, and Mark Johnson. Effective self-training for parsing. In\nProceedings of the Human Language Technology Conference of the NAACL, Main Conference,\npages 152159. ACL, June 2006.\n[27] Ankur Parikh, Oscar Täckström, Dipanjan Das, and Jakob Uszkoreit. A decomposable attention\nmodel. In Empirical Methods in Natural Language Processing, 2016.\n[28] Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive\nsummarization. arXiv preprint arXiv:1705.04304, 2017.\n[29] Slav Petrov, Leon Barrett, Romain Thibaux, and Dan Klein. Learning accurate, compact,\nand interpretable tree annotation. In Proceedings of the 21st International Conference on\nComputational Linguistics and 44th Annual Meeting of the ACL, pages 433440. ACL, July\n2006.\n[30] Ofir Press and Lior Wolf. Using the output embedding to improve language models. arXiv\npreprint arXiv:1608.05859, 2016.\n[31] Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words\nwith subword units. arXiv preprint arXiv:1508.07909, 2015.\n[32] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton,\nand Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts\nlayer. arXiv preprint arXiv:1701.06538, 2017.\n[33] Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdi-\nnov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine\nLearning Research, 15(1):19291958, 2014.\n[34] Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory\nnetworks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors,\nAdvances in Neural Information Processing Systems 28, pages 24402448. Curran Associates,\nInc., 2015.\n[35] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. Sequence to sequence learning with neural\nnetworks. In Advances in Neural Information Processing Systems, pages 31043112, 2014.\n[36] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna.\nRethinking the inception architecture for computer vision. CoRR, abs/1512.00567, 2015.\n[37] Vinyals & Kaiser, Koo, Petrov, Sutskever, and Hinton. Grammar as a foreign language. In\nAdvances in Neural Information Processing Systems, 2015.\n[38] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang\nMacherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Googles neural machine\ntranslation system: Bridging the gap between human and machine translation. arXiv preprint\narXiv:1609.08144, 2016.\n[39] Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. Deep recurrent models with\nfast-forward connections for neural machine translation. CoRR, abs/1606.04199, 2016.\n[40] Muhua Zhu, Yue Zhang, Wenliang Chen, Min Zhang, and Jingbo Zhu. Fast and accurate\nshift-reduce constituent parsing. In Proceedings of the 51st Annual Meeting of the ACL (Volume\n1: Long Papers), pages 434443. ACL, August 2013.\n12\n\n\n## PDF page 13\n\nAttention Visualizations\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nIt\nis\nin\nthis\nspirit\nthat\na\nmajority\nof\nAmerican\ngovernments\nhave\npassed\nnew\nlaws\nsince\n2009\nmaking\nthe\nregistration\nor\nvoting\nprocess\nmore\ndifficult\n.\n<EOS>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\n<pad>\nFigure 3: An example of the attention mechanism following long-distance dependencies in the\nencoder self-attention in layer 5 of 6. Many of the attention heads attend to a distant dependency of\nthe verb making, completing the phrase making...more difficult. Attentions here shown only for\nthe word making. Different colors represent different heads. Best viewed in color.\n13\n\n\n## PDF page 14\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 4: Two attention heads, also in layer 5 of 6, apparently involved in anaphora resolution. Top:\nFull attentions for head 5. Bottom: Isolated attentions from just the word its for attention heads 5\nand 6. Note that the attentions are very sharp for this word.\n14\n\n\n## PDF page 15\n\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nThe\nLaw\nwill\nnever\nbe\nperfect\n,\nbut\nits\napplication\nshould\nbe\njust\n-\nthis\nis\nwhat\nwe\nare\nmissing\n,\nin\nmy\nopinion\n.\n<EOS>\n<pad>\nFigure 5: Many of the attention heads exhibit behaviour that seems related to the structure of the\nsentence. We give two such examples above, from two different heads from the encoder self-attention\nat layer 5 of 6. The heads clearly learned to perform different tasks.\n15\n\n\n可直接引用的图表文件:\n- paper_figure_1_transformer.pngFigure 1 from PDF page 3: The Transformer model architecture.\n- paper_figure_3_long_distance.pngFigure 3 from PDF page 13: Encoder self-attention following long-distance dependencies.\n- paper_figure_4_anaphora.pngFigure 4 from PDF page 14: Attention heads involved in anaphora resolution.\n\n请生成一版 10-20 页的完整初稿。内容必须忠于论文,至少引用上面列出的三张原论文图,并覆盖问题、Transformer 架构、注意力机制、训练、主要实验、局限和结论。不要复制长段原文;每页保持听众可读的信息密度。生成完整的 slides.md。"
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\n---\n\n# Attention Is All You Need\n## A Revolutionary Architecture for Sequence Transduction\n\nAshish Vaswani et al. \nNIPS 2017\n\n---\n\n## Problem Statement\n\n- Traditional sequence models rely on RNNs or CNNs\n- RNNs have inherent sequential computation (hard to parallelize)\n- CNNs require multiple layers to capture long-range dependencies\n- Both have increasing path lengths between distant positions\n\n**Key Insight**: Replace recurrence and convolution with attention mechanisms\n\n---\n\n## The Transformer: Model Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n- Encoder-decoder structure with stacked self-attention layers\n- No recurrence or convolution\n- Significantly more parallelizable\n\n---\n\n## Encoder Stack\n\n- 6 identical layers\n- Each layer has two sub-layers:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization around each sub-layer\n- Output dimension: d<sub>model</sub> = 512\n\n---\n\n## Decoder Stack\n\n- 6 identical layers\n- Three sub-layers per layer:\n 1. Masked multi-head self-attention\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Masking prevents attending to future positions\n\n---\n\n## Attention Mechanism\n\n### Scaled Dot-Product Attention\n\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- Queries (Q), Keys (K), Values (V) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradient vanishing\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-40 mx-auto\" />\n\n- Project Q, K, V h times with different linear projections\n- Perform attention in parallel on each projection\n- Concatenate results and project again\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**:\n - Queries from decoder, keys/values from encoder\n - Allows decoder to attend to all input positions\n\n2. **Encoder self-attention**:\n - All Q, K, V from previous encoder layer\n - Each position attends to all positions\n\n3. **Decoder self-attention**:\n - All Q, K, V from previous decoder layer\n - Masked to prevent attending to future positions\n\n---\n\n## Positional Encoding\n\nSince model has no recurrence/convolution, we add positional information:\n\n$$PE_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$PE_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Sinusoidal functions with varying frequencies\n- Allows model to learn relative position information\n- Performed as well as learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------|------------|----------------|-----------------|\n| Self-Attention | O(n²·d) | O(1) | O(1) |\n| Recurrent | O(n·d²) | O(n) | O(n) |\n| Convolutional | O(k·n·d²) | O(1) | O(logₖn) |\n\n- Better parallelization than RNNs\n- Shorter path lengths than CNNs/RNNs\n- More interpretable attention patterns\n\n---\n\n## Training Details\n\n- **Datasets**: WMT 2014 EN-DE (4.5M) and EN-FR (36M)\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Optimizer**: Adam (β₁=0.9, β₂=0.98, ϵ=10⁻⁹)\n- **Learning Rate**: $lrate = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step_num}^{-0.5}, \\text{step_num} \\cdot \\text{warmup_steps}^{-1.5})$\n- **Regularization**: Dropout (P=0.1), Label Smoothing (ϵ=0.1)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|------------------------|\n| GNMT + RL | 24.6 | 39.92 | 2.3·10¹⁹ |\n| ConvS2S | 25.16 | 40.46 | 9.6·10¹⁸ |\n| Transformer (base) | 27.3 | 38.1 | 3.3·10¹⁸ |\n| **Transformer (big)** | **28.4** | **41.8** | **2.3·10¹⁹** |\n\n- Transformer (big) outperforms all previous state-of-the-art\n- Achieves new SOTA with significantly less training cost\n\n---\n\n## Model Variations\n\n| Configuration | Dev PPL | Dev BLEU |\n|---------------|---------|----------|\n| Base | 4.92 | 25.8 |\n| 1 attention head | 5.29 | 24.9 |\n| 32 attention heads | 5.01 | 25.4 |\n| No dropout | 5.77 | 24.6 |\n| Learned positional embeddings | 4.92 | 25.7 |\n| Big model | 4.33 | 26.4 |\n\n- Multiple attention heads improve performance\n- Dropout is crucial for generalization\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Achieves competitive results with minimal task-specific modifications\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-70 mx-auto\" />\n\n- Attention heads follow distant dependencies\n- Example: Verb \"making\" attends to \"more difficult\"\n- Different colors represent different attention heads\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-70 mx-auto\" />\n\n- Some heads specialize in resolving pronouns\n- Example: \"its\" clearly attends to \"The Law\"\n- Sharp attention patterns for coreference resolution\n\n---\n\n## Limitations and Future Work\n\n### Limitations:\n- High memory consumption with long sequences (O(n²))\n- Still generates output sequentially\n\n### Future Work:\n- Local, restricted attention mechanisms for large inputs\n- Extend to other modalities (images, audio, video)\n- Make generation less sequential\n- Explore more efficient attention variants\n\n---\n\n## Conclusion\n\n- Transformer is the first transduction model based entirely on attention\n- Replaces RNNs/CNNs with multi-headed self-attention\n- Significantly faster training with better parallelization\n- Achieves new state-of-the-art in machine translation\n- Generalizes well to other sequence tasks like constituency parsing\n\n**Code**: https://github.com/tensorflow/tensor2tensor\n\n---\n\n## Thank You!\n```"
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "这是你上一版 slides.md 渲染出的 19 页截图。请自我审查(文字溢出/拥挤/图片尺寸/可读性/布局),然后输出修订后的完整 slides.md。修订后硬性保持 10–20 页,并保留三张原论文图。"
},
{
"type": "text",
"text": "第 1 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "43e962b781454c3d5eac7723de28844f9fe12cee5370e89387f0273d1c119d0a",
"characters": 89538,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 2 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "38663a48b255317d1b215719cae21f7aa164d6a06e18c33db0fbcb1521e07b08",
"characters": 127194,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 3 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "f2c32e54430c4248aef8efe88184b4ac4e651b33bb90a9363b232e9f6c31b849",
"characters": 163894,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 4 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a133c25660777e180a5ce25bbebc5ec3cf9b4ee399094503834f94b5a19249fb",
"characters": 100590,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 5 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9bbe983962c98389fd510d680ae999581f8df804965e242cb0c188667ffe180a",
"characters": 110394,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 6 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "446675777a3f374f452bfb70617bf46328990e9884d9997a1da802408c9d3d49",
"characters": 109418,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 7 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "d6add7843373ed4062f7f33e3cef9538da774244ac5ef15281a24d9c90b52cd4",
"characters": 125982,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 8 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "d126da4d299d6123fc4fcc5bef77fd481f57c5c379f6ac87c7995961c3d4dd32",
"characters": 145338,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 9 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "39a056fc9e4982e85821c808947c903f85a3cd3236c204fe22887f850db717b0",
"characters": 136346,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 10 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a89b46f3ef9f56d231e8c3c0a0e15d085a0cd45d75a11d7fcef2c3abfe20d33d",
"characters": 123138,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 11 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "1684df3822c5f232dfcc6f42539e91e5b2bb16e383fbbbb25fff3c4bc2d7ff8e",
"characters": 134618,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 12 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "65d72181f5930398c2e0ad9e29ddde08a324c168de9e183a3072a430e03dfcd1",
"characters": 137678,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 13 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "cfd076741770b767919a9b20b0589a6e2b9b48b189b5e2019396fd8ddd89e2a1",
"characters": 142406,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 14 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "8fa0de2217a29efdc146e957d16f97a02293a370513bc67d1dd9eae6870ae056",
"characters": 152318,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 15 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "0d2304a0c4ac2ea569ed1113df08ea926fb94d10a7cb174c8cc3221b1db97481",
"characters": 172402,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 16 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "859bd832f8a544f10d2f4f4d0539f969538126f038d394792e98caede1739d7d",
"characters": 175410,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 17 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "bd8b103b3619b1ff7c24f1846725a3d7dbe9e6788e9ed59145bd98a4a9d777d5",
"characters": 133230,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 18 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "0584853789dc51eb555b312710b70f51538d671471bc1f01af77052331ca4535",
"characters": 137474,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 19 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "e62c27dc16880a560b7826ed349aa24fbacea989919063c5539777d6accbb28e",
"characters": 14014,
"media_type": "image/png"
},
"detail": "high"
}
}
]
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\n---\n\n# Attention Is All You Need\n## A Revolutionary Architecture for Sequence Transduction\n\nAshish Vaswani et al. \nNIPS 2017\n\n---\n\n## Problem Statement\n\n- Traditional sequence models rely on RNNs or CNNs\n- RNNs have inherent sequential computation (hard to parallelize)\n- CNNs require multiple layers to capture long-range dependencies\n- Both have increasing path lengths between distant positions\n\n**Key Insight**: Replace recurrence and convolution with attention mechanisms\n\n---\n\n## The Transformer: Model Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-96 mx-auto\" />\n\n- Encoder-decoder structure with stacked self-attention layers\n- No recurrence or convolution\n- Significantly more parallelizable\n\n---\n\n## Encoder Stack\n\n- 6 identical layers with two sub-layers each:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Output dimension: d<sub>model</sub> = 512\n\n---\n\n## Decoder Stack\n\n- 6 identical layers with three sub-layers each:\n 1. Masked multi-head self-attention\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Masking prevents attending to future positions\n\n---\n\n## Scaled Dot-Product Attention\n\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- Queries (Q), Keys (K), Values (V) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradient vanishing\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-60 mx-auto\" />\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- Project Q, K, V h times with different linear projections\n- Perform attention in parallel on each projection\n- Concatenate results and project again\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**:\n - Queries from decoder, keys/values from encoder\n\n2. **Encoder self-attention**:\n - All Q, K, V from previous encoder layer\n - Each position attends to all positions\n\n3. **Decoder self-attention**:\n - All Q, K, V from previous decoder layer\n - Masked to prevent attending to future positions\n\n---\n\n## Positional Encoding\n\nSince model has no recurrence/convolution, we add positional information:\n\n$$PE_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$PE_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Sinusoidal functions with varying frequencies\n- Allows model to learn relative position information\n- Performed as well as learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------|------------|----------------|-----------------|\n| Self-Attention | O(n²·d) | O(1) | O(1) |\n| Recurrent | O(n·d²) | O(n) | O(n) |\n| Convolutional | O(k·n·d²) | O(1) | O(logₖn) |\n\n- Better parallelization than RNNs\n- Shorter path lengths than CNNs/RNNs\n- More interpretable attention patterns\n\n---\n\n## Training Details\n\n- **Datasets**: WMT 2014 EN-DE (4.5M) and EN-FR (36M)\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Optimizer**: Adam (β₁=0.9, β₂=0.98, ϵ=10⁻⁹)\n- **Learning Rate**: \n $$lrate = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step\\_num}^{-0.5}, \\text{step\\_num} \\cdot \\text{warmup\\_steps}^{-1.5})$$\n- **Regularization**: Dropout (P=0.1), Label Smoothing (ϵ=0.1)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|------------------------|\n| GNMT + RL | 24.6 | 39.92 | 2.3·10¹⁹ |\n| ConvS2S | 25.16 | 40.46 | 9.6·10¹⁸ |\n| Transformer (base) | 27.3 | 38.1 | 3.3·10¹⁸ |\n| **Transformer (big)** | **28.4** | **41.8** | **2.3·10¹⁹** |\n\n- Transformer (big) outperforms all previous state-of-the-art\n- Achieves new SOTA with significantly less training cost\n\n---\n\n## Model Variations\n\n| Configuration | Dev PPL | Dev BLEU |\n|---------------|---------|----------|\n| Base | 4.92 | 25.8 |\n| 1 attention head | 5.29 | 24.9 |\n| 32 attention heads | 5.01 | 25.4 |\n| No dropout | 5.77 | 24.6 |\n| Learned positional embeddings | 4.92 | 25.7 |\n| Big model | 4.33 | 26.4 |\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-80 mx-auto\" />\n\n- Attention heads follow distant dependencies\n- Example: Verb \"making\" attends to \"more difficult\"\n- Different colors represent different attention heads\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-80 mx-auto\" />\n\n- Some heads specialize in resolving pronouns\n- Example: \"its\" clearly attends to \"The Law\"\n- Sharp attention patterns for coreference resolution\n\n---\n\n## Limitations and Future Work\n\n### Limitations:\n- High memory consumption with long sequences (O(n²))\n- Still generates output sequentially\n\n### Future Work:\n- Local, restricted attention mechanisms for large inputs\n- Extend to other modalities (images, audio, video)\n- Make generation less sequential\n\n---\n\n## Conclusion\n\n- Transformer is the first transduction model based entirely on attention\n- Replaces RNNs/CNNs with multi-headed self-attention\n- Significantly faster training with better parallelization\n- Achieves new state-of-the-art in machine translation\n- Generalizes well to other sequence tasks like constituency parsing\n\n**Code**: https://github.com/tensorflow/tensor2tensor\n```"
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "这是你上一版 slides.md 渲染出的 18 页截图。请自我审查(文字溢出/拥挤/图片尺寸/可读性/布局),然后输出修订后的完整 slides.md。修订后硬性保持 10–20 页,并保留三张原论文图。"
},
{
"type": "text",
"text": "第 1 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "43e962b781454c3d5eac7723de28844f9fe12cee5370e89387f0273d1c119d0a",
"characters": 89538,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 2 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "38663a48b255317d1b215719cae21f7aa164d6a06e18c33db0fbcb1521e07b08",
"characters": 127194,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 3 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "77dfdf7da2c0b7cf2e2d4aa89b146a667500702bbd71ef2a4d2c6af66f0bad4d",
"characters": 189514,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 4 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "cd1b38eeafbf59ed2346609539f07c6c44d10c384be05f51a7f51492c131c0dc",
"characters": 90918,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 5 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "7dfdcbfbdcacc0070e72ced8abf51e2d71316c90c2946cf0e5abe98e4e36e7f2",
"characters": 109930,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 6 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "72fd664cb0eb9254ef2a1e781cd6f9542c221adbfe4a63f3e2d76a51bd6de371",
"characters": 100542,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 7 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "1da47031d1ca1dccf72460f3961eec5fba5633f2b407faaeebd7688d4b1cfa54",
"characters": 150498,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 8 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "2838056a82ff7c63766cbe6e3bba6611cd42162a354df629da52c40267540211",
"characters": 128842,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 9 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "39a056fc9e4982e85821c808947c903f85a3cd3236c204fe22887f850db717b0",
"characters": 136346,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 10 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a89b46f3ef9f56d231e8c3c0a0e15d085a0cd45d75a11d7fcef2c3abfe20d33d",
"characters": 123138,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 11 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9bb99e180f6c7b8384b0d30b31d729b8ceb13dd62eaa01caf91b00ef71b4fb9b",
"characters": 123246,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 12 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "65d72181f5930398c2e0ad9e29ddde08a324c168de9e183a3072a430e03dfcd1",
"characters": 137678,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 13 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "f472a496e8d188487b6ec46151eac0c60465ad412ad1d6e9592472b21af2b449",
"characters": 93350,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 14 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "e156855f85bd50f0feb74b8aa3d93b1a19ec6c5c96a60bd2f648e6220e8ee964",
"characters": 129414,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 15 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "6a406803a2572b7f3db4791dcf104562be21f59d7873ce0364c774e411533a5d",
"characters": 189734,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 16 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "670f9f30f8abf7c62d674ad098177449535487f19962dab65d4ab60154d22f52",
"characters": 194886,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 17 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "97d0320dcb23cb0a8f74db51cd40f029296fabd62303eac5488defbc2e2fcc00",
"characters": 118866,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 18 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "0584853789dc51eb555b312710b70f51538d671471bc1f01af77052331ca4535",
"characters": 137474,
"media_type": "image/png"
},
"detail": "high"
}
}
]
},
{
"role": "assistant",
"content": "```markdown\n---\ntheme: default\n---\n\n# Attention Is All You Need\n## A Revolutionary Architecture for Sequence Transduction\n\nAshish Vaswani et al. \nNIPS 2017\n\n---\n\n## Problem Statement\n\nTraditional sequence models rely on RNNs or CNNs with critical limitations:\n- **RNNs**: Inherently sequential computation (hard to parallelize)\n- **CNNs**: Require multiple layers to capture long-range dependencies\n- **Both**: Increasing path lengths between distant positions\n\n**Key Insight**: Replace recurrence and convolution with attention mechanisms\n\n---\n\n## The Transformer: Model Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-80 mx-auto\" />\n\n- Encoder-decoder structure with stacked self-attention layers\n- No recurrence or convolution\n- Significantly more parallelizable\n\n---\n\n## Encoder Stack\n\n- 6 identical layers with two sub-layers each:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Output dimension: d<sub>model</sub> = 512\n\n---\n\n## Decoder Stack\n\n- 6 identical layers with three sub-layers each:\n 1. Masked multi-head self-attention\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Masking prevents attending to future positions\n\n---\n\n## Scaled Dot-Product Attention\n\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- Queries (Q), Keys (K), Values (V) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradient vanishing\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- Project Q, K, V h times with different linear projections\n- Perform attention in parallel on each projection\n- Concatenate results and project again\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**:\n - Queries from decoder, keys/values from encoder\n\n2. **Encoder self-attention**:\n - All Q, K, V from previous encoder layer\n - Each position attends to all positions\n\n3. **Decoder self-attention**:\n - All Q, K, V from previous decoder layer\n - Masked to prevent attending to future positions\n\n---\n\n## Positional Encoding\n\nSince model has no recurrence/convolution, we add positional information:\n\n$$PE_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$PE_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Sinusoidal functions with varying frequencies\n- Allows model to learn relative position information\n- Performed as well as learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------|------------|----------------|-----------------|\n| Self-Attention | O(n²·d) | O(1) | O(1) |\n| Recurrent | O(n·d²) | O(n) | O(n) |\n| Convolutional | O(k·n·d²) | O(1) | O(logₖn) |\n\n- Better parallelization than RNNs\n- Shorter path lengths than CNNs/RNNs\n- More interpretable attention patterns\n\n---\n\n## Training Details\n\n- **Datasets**: WMT 2014 EN-DE (4.5M) and EN-FR (36M)\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Optimizer**: Adam (β₁=0.9, β₂=0.98, ϵ=10⁻⁹)\n- **Learning Rate**: \n $$lrate = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step\\_num}^{-0.5}, \\text{step\\_num} \\cdot \\text{warmup\\_steps}^{-1.5})$$\n- **Regularization**: Dropout (P=0.1), Label Smoothing (ϵ=0.1)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|------------------------|\n| GNMT + RL | 24.6 | 39.92 | 2.3·10¹⁹ |\n| ConvS2S | 25.16 | 40.46 | 9.6·10¹⁸ |\n| Transformer (base) | 27.3 | 38.1 | 3.3·10¹⁸ |\n| **Transformer (big)** | **28.4** | **41.8** | **2.3·10¹⁹** |\n\n- Transformer (big) outperforms all previous state-of-the-art\n- Achieves new SOTA with significantly less training cost\n\n---\n\n## Model Variations\n\n| Configuration | Dev PPL | Dev BLEU |\n|---------------|---------|----------|\n| Base | 4.92 | 25.8 |\n| 1 attention head | 5.29 | 24.9 |\n| 32 attention heads | 5.01 | 25.4 |\n| No dropout | 5.77 | 24.6 |\n| Learned positional embeddings | 4.92 | 25.7 |\n| Big model | 4.33 | 26.4 |\n\n**Key Findings**:\n- Multiple attention heads improve performance\n- Dropout is crucial for generalization\n- Sinusoidal and learned positional encodings perform similarly\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n- Achieves competitive results with minimal task-specific modifications\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-72 mx-auto\" />\n\n- Attention heads follow distant dependencies\n- Example: Verb \"making\" attends to \"more difficult\"\n- Different colors represent different attention heads\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-72 mx-auto\" />\n\n- Some heads specialize in resolving pronouns\n- Example: \"its\" clearly attends to \"The Law\"\n- Sharp attention patterns for coreference resolution\n\n---\n\n## Limitations and Future Work\n\n### Limitations:\n- High memory consumption with long sequences (O(n²))\n- Still generates output sequentially\n\n### Future Work:\n- Local, restricted attention mechanisms for large inputs\n- Extend to other modalities (images, audio, video)\n- Make generation less sequential\n\n---\n\n## Conclusion\n\n- Transformer is the first transduction model based entirely on attention\n- Replaces RNNs/CNNs with multi-headed self-attention\n- Significantly faster training with better parallelization\n- Achieves new state-of-the-art in machine translation\n- Generalizes well to other sequence tasks like constituency parsing\n```"
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "这是你上一版 slides.md 渲染出的 18 页截图。请自我审查(文字溢出/拥挤/图片尺寸/可读性/布局),然后输出修订后的完整 slides.md。修订后硬性保持 10–20 页,并保留三张原论文图。"
},
{
"type": "text",
"text": "第 1 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "43e962b781454c3d5eac7723de28844f9fe12cee5370e89387f0273d1c119d0a",
"characters": 89538,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 2 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "0d9ab9cf58ba005ffa39245d07e5824baf4e433f47bbc96c03e71eccdeb6aa13",
"characters": 134290,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 3 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "f2c32e54430c4248aef8efe88184b4ac4e651b33bb90a9363b232e9f6c31b849",
"characters": 163894,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 4 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "cd1b38eeafbf59ed2346609539f07c6c44d10c384be05f51a7f51492c131c0dc",
"characters": 90918,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 5 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "7dfdcbfbdcacc0070e72ced8abf51e2d71316c90c2946cf0e5abe98e4e36e7f2",
"characters": 109930,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 6 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "72fd664cb0eb9254ef2a1e781cd6f9542c221adbfe4a63f3e2d76a51bd6de371",
"characters": 100542,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 7 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "91b769562a6a49f496430fe602f46fe2d53755ea391a94018bf91870103119d8",
"characters": 94662,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 8 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "2838056a82ff7c63766cbe6e3bba6611cd42162a354df629da52c40267540211",
"characters": 128842,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 9 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "39a056fc9e4982e85821c808947c903f85a3cd3236c204fe22887f850db717b0",
"characters": 136346,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 10 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a89b46f3ef9f56d231e8c3c0a0e15d085a0cd45d75a11d7fcef2c3abfe20d33d",
"characters": 123138,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 11 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9bb99e180f6c7b8384b0d30b31d729b8ceb13dd62eaa01caf91b00ef71b4fb9b",
"characters": 123246,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 12 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "65d72181f5930398c2e0ad9e29ddde08a324c168de9e183a3072a430e03dfcd1",
"characters": 137678,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 13 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a970b52780b8142f4ea64abec5721956127f35761a72f2b464f0f6e2a2c21867",
"characters": 127530,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 14 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "8fa0de2217a29efdc146e957d16f97a02293a370513bc67d1dd9eae6870ae056",
"characters": 152318,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 15 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "e590cf281ef2b8fa748a2ad8d044f30af6b13e907866ee123b71fead930d3458",
"characters": 176554,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 16 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "da3cfe24e8bb30f591fa206d79a7a180b44820a663c7a8c05f19bb1ec95148ff",
"characters": 179618,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 17 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "97d0320dcb23cb0a8f74db51cd40f029296fabd62303eac5488defbc2e2fcc00",
"characters": 118866,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 18 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "83c53da42b5c7f740fb85ab2712fe99446ae3c2d036e43024752410c5f04f866",
"characters": 114506,
"media_type": "image/png"
},
"detail": "high"
}
}
]
}
],
"temperature": 0.3
},
"response": {
"id": "0217853856355023694b53d1b7644bc84f9058822e8eff2c1d67c",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "```markdown\n---\ntheme: default\n---\n\n# Attention Is All You Need\n## A Revolutionary Architecture for Sequence Transduction\n\nAshish Vaswani et al. \nNIPS 2017\n\n---\n\n## Problem Statement\n\nTraditional sequence models rely on RNNs or CNNs with critical limitations:\n- **RNNs**: Inherently sequential computation (hard to parallelize)\n- **CNNs**: Require multiple layers to capture long-range dependencies\n- **Both**: Increasing path lengths between distant positions\n\n**Key Insight**: Replace recurrence and convolution with attention mechanisms\n\n---\n\n## The Transformer: Model Architecture\n\n<img src=\"/paper_figure_1_transformer.png\" class=\"h-96 mx-auto\" />\n\n- Encoder-decoder structure with stacked self-attention layers\n- No recurrence or convolution\n- Significantly more parallelizable\n\n---\n\n## Encoder Stack\n\n- 6 identical layers with two sub-layers each:\n 1. Multi-head self-attention mechanism\n 2. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Output dimension: d<sub>model</sub> = 512\n\n---\n\n## Decoder Stack\n\n- 6 identical layers with three sub-layers each:\n 1. Masked multi-head self-attention\n 2. Multi-head attention over encoder output\n 3. Position-wise fully connected feed-forward network\n- Residual connections + layer normalization\n- Masking prevents attending to future positions\n\n---\n\n## Scaled Dot-Product Attention\n\n$$\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right)V$$\n\n- Queries (Q), Keys (K), Values (V) are matrices\n- Scaling by $\\sqrt{d_k}$ prevents gradient vanishing\n- More efficient than additive attention\n\n---\n\n## Multi-Head Attention\n\n$$\\text{MultiHead}(Q, K, V) = \\text{Concat}(\\text{head}_1, ..., \\text{head}_h)W^O$$\n\n- Project Q, K, V h times with different linear projections\n- Perform attention in parallel on each projection\n- Concatenate results and project again\n\n---\n\n## Applications of Attention\n\n1. **Encoder-decoder attention**:\n - Queries from decoder, keys/values from encoder\n\n2. **Encoder self-attention**:\n - All Q, K, V from previous encoder layer\n - Each position attends to all positions\n\n3. **Decoder self-attention**:\n - All Q, K, V from previous decoder layer\n - Masked to prevent attending to future positions\n\n---\n\n## Positional Encoding\n\nSince model has no recurrence/convolution, we add positional information:\n\n$$PE_{(pos, 2i)} = \\sin\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n$$PE_{(pos, 2i+1)} = \\cos\\left(pos / 10000^{2i/d_{\\text{model}}}\\right)$$\n\n- Sinusoidal functions with varying frequencies\n- Allows model to learn relative position information\n- Performed as well as learned positional embeddings\n\n---\n\n## Why Self-Attention?\n\n| Layer Type | Complexity | Sequential Ops | Max Path Length |\n|------------|------------|----------------|-----------------|\n| Self-Attention | O(n²·d) | O(1) | O(1) |\n| Recurrent | O(n·d²) | O(n) | O(n) |\n| Convolutional | O(k·n·d²) | O(1) | O(logₖn) |\n\n- Better parallelization than RNNs\n- Shorter path lengths than CNNs/RNNs\n- More interpretable attention patterns\n\n---\n\n## Training Details\n\n- **Datasets**: WMT 2014 EN-DE (4.5M) and EN-FR (36M)\n- **Hardware**: 8 NVIDIA P100 GPUs\n- **Optimizer**: Adam (β₁=0.9, β₂=0.98, ϵ=10⁻⁹)\n- **Learning Rate**: \n $lrate = d_{\\text{model}}^{-0.5} \\cdot \\min(\\text{step\\_num}^{-0.5}, \\text{step\\_num} \\cdot \\text{warmup\\_steps}^{-1.5})$\n- **Regularization**: Dropout (P=0.1), Label Smoothing (ϵ=0.1)\n\n---\n\n## Machine Translation Results\n\n| Model | EN-DE BLEU | EN-FR BLEU | Training Cost (FLOPs) |\n|-------|------------|------------|------------------------|\n| GNMT + RL | 24.6 | 39.92 | 2.3·10¹⁹ |\n| ConvS2S | 25.16 | 40.46 | 9.6·10¹⁸ |\n| Transformer (base) | 27.3 | 38.1 | 3.3·10¹⁸ |\n| **Transformer (big)** | **28.4** | **41.8** | **2.3·10¹⁹** |\n\n- Transformer (big) outperforms all previous state-of-the-art\n- Achieves new SOTA with significantly less training cost\n\n---\n\n## Model Variations\n\n| Configuration | Dev PPL | Dev BLEU |\n|---------------|---------|----------|\n| Base | 4.92 | 25.8 |\n| 1 attention head | 5.29 | 24.9 |\n| 32 attention heads | 5.01 | 25.4 |\n| No dropout | 5.77 | 24.6 |\n| Learned positional embeddings | 4.92 | 25.7 |\n| Big model | 4.33 | 26.4 |\n\n**Key Findings**:\n- Multiple attention heads improve performance\n- Dropout is crucial for generalization\n\n---\n\n## English Constituency Parsing\n\n| Parser | Training | WSJ 23 F1 |\n|--------|----------|-----------|\n| Petrov et al. (2006) | WSJ only | 90.4 |\n| Dyer et al. (2016) | WSJ only | 91.7 |\n| **Transformer (4 layers)** | **WSJ only** | **91.3** |\n| Vinyals & Kaiser et al. | Semi-supervised | 92.1 |\n| **Transformer (4 layers)** | **Semi-supervised** | **92.7** |\n\n- Transformer generalizes well to other sequence tasks\n\n---\n\n## Attention Visualization: Long-Distance Dependencies\n\n<img src=\"/paper_figure_3_long_distance.png\" class=\"h-80 mx-auto\" />\n\n- Attention heads follow distant dependencies\n- Example: Verb \"making\" attends to \"more difficult\"\n- Different colors represent different attention heads\n\n---\n\n## Attention Visualization: Anaphora Resolution\n\n<img src=\"/paper_figure_4_anaphora.png\" class=\"h-80 mx-auto\" />\n\n- Some heads specialize in resolving pronouns\n- Example: \"its\" clearly attends to \"The Law\"\n- Sharp attention patterns for coreference resolution\n\n---\n\n## Limitations and Future Work\n\n### Limitations:\n- High memory consumption with long sequences (O(n²))\n- Still generates output sequentially\n\n### Future Work:\n- Local, restricted attention mechanisms for large inputs\n- Extend to other modalities (images, audio, video)\n- Make generation less sequential\n\n---\n\n## Conclusion\n\n- Transformer is the first transduction model based entirely on attention\n- Replaces RNNs/CNNs with multi-headed self-attention\n- Significantly faster training with better parallelization\n- Achieves new state-of-the-art in machine translation\n- Generalizes well to other sequence tasks like constituency parsing\n```"
},
"usage": {
"prompt_tokens": 82577,
"completion_tokens": 2087,
"total_tokens": 84664,
"cached_prompt_tokens": 0
}
},
{
"meter": "独立评委(不计入两方案成本)",
"called_at_utc": "2026-07-30T04:29:11.892049+00:00",
"latency_s": 48.43,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名严格的演示文稿质量审核员(Reviewer)。你会看到一份由 Slidev 渲染出的 PPT,\n每张图对应一页幻灯片(按顺序编号,从第 1 页开始)。请逐页检查以下问题:\n\n- text_overflow(文字溢出/被裁切超出页面边界)\n- overcrowded(内容过多/过于拥挤/留白不足)\n- image_size(图片过大顶出布局,或过小看不清)\n- readability(字号过小、对比度差、代码块难读)\n- layout(对齐混乱、标题与正文比例失衡、空页)\n\n请以**目标用户是听众**的严格标准审查——一页幻灯片若要点超过约 5 条、或正文文字块偏长、\n或图片挤压了文字空间,都应视为 overcrowded/image_size 问题。报告真实存在的问题,\n但不要放过\"塞得太满\"。对每个问题给出:page(页码,整数)、\nissue_type(上面之一)、severityhigh/medium/low)、suggestion(具体、可执行的修改建议,中文)。\n\n同时给出:\n- overall_score0-100 的整体质量分(越高越好)\n- pass:布尔值,仅当整份 PPT **既无 high 也无 medium 级问题**、排版干净可读时才为 true\n\n严格输出如下 JSON(不要输出任何多余文字):\n{\n \"overall_score\": <int>,\n \"pass\": <bool>,\n \"issues\": [\n {\"page\": <int>, \"issue_type\": \"<type>\", \"severity\": \"<high|medium|low>\", \"suggestion\": \"<中文建议>\"}\n ]\n}"
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "这份 PPT 共 19 页,下面按页码顺序给出每一页的渲染截图。请审查。"
},
{
"type": "text",
"text": "第 1 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9d3c8d02979b8658be4dc98b1b914e4daf9ca6900e251a9c0d0c1225010ef208",
"characters": 61854,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 2 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "e3dd4226e5604f9b7d44c96e83d39d8cab36acfddd2ce044dd12ab4178ee6c03",
"characters": 99678,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 3 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "d54253c9d63ccd761cb68f2105dcbfc9546353ac173dc17e00a7aea2e54deb65",
"characters": 106506,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 4 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a36b9480cac068a4697457cf802e348a489af1e3cecd2a96cd6d375e9792effe",
"characters": 151218,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 5 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "7f0a9adb6003279433fbe0b678d32a00d1b18aa53a64ad7b410a82854daa1745",
"characters": 134138,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 6 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "f21c0de2d76609a1c98769e6b8466011a7157092b26879a647939982c93a0324",
"characters": 100734,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 7 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "929555f1f5c7a6c5d2e366eb2e496aa9ba70e2dbac7939382d744b9f9d50ad72",
"characters": 124658,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 8 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "4b02c8b2a4836e2e41aae9da9fa42e508036588f448c593b90866e5260bb8a01",
"characters": 153882,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 9 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "fbba53df383f6638fb8f09f85758530a9dd2ed69f707a424ad8acecacafe4b2e",
"characters": 187154,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 10 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "317afc56617303886072156d70c7f40b2c08f1a10b2545af504f8c656dcf3dfa",
"characters": 131406,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 11 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "4acf19a7ed443435686c95f30c4953a1f0428dd9270ad532c301d4caa0613242",
"characters": 110062,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 12 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "ced86f319797ec6fed137e4a9657b3c27843e16c597631553fc1552c1417f45e",
"characters": 97798,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 13 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "71e1693b042f6020b01b0523b775ba04782749444679354ec89a44c3bfd9ca92",
"characters": 92510,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 14 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "bd8143c387ff06c4782826a81b077a3c3cefb1aeb08816bca0160a527f8e7e68",
"characters": 105534,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 15 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "3ea3f5d33395f0e164166778184da3b27a9b4eae27c21615de85d0dd015b2e43",
"characters": 110602,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 16 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "3941596c28c3c3bf92d5edb9a455a8782241a1c436b97bfebbc197a862da68d0",
"characters": 272750,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 17 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "9d96bf60e05ef420ed392d9802c64327b22e7d6c55751fe224cbad1cd1e11fec",
"characters": 261346,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 18 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "2b06e06e39d8d79187144dd3480800259dba1dd1de79efdc40c43d68b19ad6e9",
"characters": 101706,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 19 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "00cb22fea345052aded272d9f8636e2fa27935367e3e1b5a701f96d2719fcdc5",
"characters": 95498,
"media_type": "image/png"
},
"detail": "high"
}
}
]
}
],
"temperature": 0.2
},
"response": {
"id": "0217853857037130a5720dfd57fd83aed3bdbca02adba84d68f1f",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "{\n \"overall_score\": 85,\n \"pass\": false,\n \"issues\": [\n {\"page\": 2, \"issue_type\": \"overcrowded\", \"severity\": \"medium\", \"suggestion\": \"当前页面有5个要点,略超过建议的5条上限。可将最后1点拆分到下一页,或精简部分要点的表述。\"},\n {\"page\": 16, \"issue_type\": \"image_size\", \"severity\": \"medium\", \"suggestion\": \"注意力可视化图细节较密集,建议放大图片尺寸或聚焦展示关键区域,确保观众能看清文字和连接线。\"},\n {\"page\": 16, \"issue_type\": \"readability\", \"severity\": \"medium\", \"suggestion\": \"图片中的文字偏小且线条密集,建议增大字号或使用更清晰的可视化方式,提高可读性。\"},\n {\"page\": 17, \"issue_type\": \"image_size\", \"severity\": \"medium\", \"suggestion\": \"指代消解注意力图细节模糊,建议放大图片或拆分展示,确保观众能分辨不同注意力头的连接关系。\"},\n {\"page\": 17, \"issue_type\": \"readability\", \"severity\": \"medium\", \"suggestion\": \"图片中文字过小且颜色对比度低,建议增大字号并优化配色方案,提高文字清晰度。\"}\n ]\n}"
},
"usage": {
"prompt_tokens": 22978,
"completion_tokens": 2124,
"total_tokens": 25102,
"cached_prompt_tokens": 0
}
},
{
"meter": "独立评委(不计入两方案成本)",
"called_at_utc": "2026-07-30T04:30:46.958839+00:00",
"latency_s": 92.88,
"request": {
"model": "doubao-seed-1-6-250615",
"messages": [
{
"role": "system",
"content": "你是一名严格的演示文稿质量审核员(Reviewer)。你会看到一份由 Slidev 渲染出的 PPT,\n每张图对应一页幻灯片(按顺序编号,从第 1 页开始)。请逐页检查以下问题:\n\n- text_overflow(文字溢出/被裁切超出页面边界)\n- overcrowded(内容过多/过于拥挤/留白不足)\n- image_size(图片过大顶出布局,或过小看不清)\n- readability(字号过小、对比度差、代码块难读)\n- layout(对齐混乱、标题与正文比例失衡、空页)\n\n请以**目标用户是听众**的严格标准审查——一页幻灯片若要点超过约 5 条、或正文文字块偏长、\n或图片挤压了文字空间,都应视为 overcrowded/image_size 问题。报告真实存在的问题,\n但不要放过\"塞得太满\"。对每个问题给出:page(页码,整数)、\nissue_type(上面之一)、severityhigh/medium/low)、suggestion(具体、可执行的修改建议,中文)。\n\n同时给出:\n- overall_score0-100 的整体质量分(越高越好)\n- pass:布尔值,仅当整份 PPT **既无 high 也无 medium 级问题**、排版干净可读时才为 true\n\n严格输出如下 JSON(不要输出任何多余文字):\n{\n \"overall_score\": <int>,\n \"pass\": <bool>,\n \"issues\": [\n {\"page\": <int>, \"issue_type\": \"<type>\", \"severity\": \"<high|medium|low>\", \"suggestion\": \"<中文建议>\"}\n ]\n}"
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "这份 PPT 共 18 页,下面按页码顺序给出每一页的渲染截图。请审查。"
},
{
"type": "text",
"text": "第 1 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "43e962b781454c3d5eac7723de28844f9fe12cee5370e89387f0273d1c119d0a",
"characters": 89538,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 2 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "0d9ab9cf58ba005ffa39245d07e5824baf4e433f47bbc96c03e71eccdeb6aa13",
"characters": 134290,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 3 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "77dfdf7da2c0b7cf2e2d4aa89b146a667500702bbd71ef2a4d2c6af66f0bad4d",
"characters": 189514,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 4 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "cd1b38eeafbf59ed2346609539f07c6c44d10c384be05f51a7f51492c131c0dc",
"characters": 90918,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 5 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "7dfdcbfbdcacc0070e72ced8abf51e2d71316c90c2946cf0e5abe98e4e36e7f2",
"characters": 109930,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 6 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "72fd664cb0eb9254ef2a1e781cd6f9542c221adbfe4a63f3e2d76a51bd6de371",
"characters": 100542,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 7 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "91b769562a6a49f496430fe602f46fe2d53755ea391a94018bf91870103119d8",
"characters": 94662,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 8 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "2838056a82ff7c63766cbe6e3bba6611cd42162a354df629da52c40267540211",
"characters": 128842,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 9 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "39a056fc9e4982e85821c808947c903f85a3cd3236c204fe22887f850db717b0",
"characters": 136346,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 10 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a89b46f3ef9f56d231e8c3c0a0e15d085a0cd45d75a11d7fcef2c3abfe20d33d",
"characters": 123138,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 11 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "0af076375623183b3a1d3872c1720ca4dfa24741a973dbd4c5b53eb8c407bd55",
"characters": 120246,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 12 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "65d72181f5930398c2e0ad9e29ddde08a324c168de9e183a3072a430e03dfcd1",
"characters": 137678,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 13 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "a970b52780b8142f4ea64abec5721956127f35761a72f2b464f0f6e2a2c21867",
"characters": 127530,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 14 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "e156855f85bd50f0feb74b8aa3d93b1a19ec6c5c96a60bd2f648e6220e8ee964",
"characters": 129414,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 15 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "6a406803a2572b7f3db4791dcf104562be21f59d7873ce0364c774e411533a5d",
"characters": 189734,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 16 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "670f9f30f8abf7c62d674ad098177449535487f19962dab65d4ab60154d22f52",
"characters": 194886,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 17 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "97d0320dcb23cb0a8f74db51cd40f029296fabd62303eac5488defbc2e2fcc00",
"characters": 118866,
"media_type": "image/png"
},
"detail": "high"
}
},
{
"type": "text",
"text": "第 18 页:"
},
{
"type": "image_url",
"image_url": {
"url": {
"data_url_sha256": "83c53da42b5c7f740fb85ab2712fe99446ae3c2d036e43024752410c5f04f866",
"characters": 114506,
"media_type": "image/png"
},
"detail": "high"
}
}
]
}
],
"temperature": 0.2
},
"response": {
"id": "021785385814997c85c17782ebc45169ced08d4429f63da3940c6",
"model": "doubao-seed-1-6-250615",
"finish_reason": "stop",
"content": "{\n \"overall_score\": 85,\n \"pass\": false,\n \"issues\": [\n {\"page\": 3, \"issue_type\": \"image_size\", \"severity\": \"high\", \"suggestion\": \"调整架构图大小,确保图片下方的文字说明完整显示,避免内容被截断\"},\n {\"page\": 3, \"issue_type\": \"overcrowded\", \"severity\": \"medium\", \"suggestion\": \"将图片下方的文字说明移至新页面,或精简文字内容,增加留白空间\"},\n {\"page\": 3, \"issue_type\": \"readability\", \"severity\": \"medium\", \"suggestion\": \"放大架构图中的文字,确保听众能清晰辨认图中的组件名称和结构关系\"},\n {\"page\": 15, \"issue_type\": \"image_size\", \"severity\": \"medium\", \"suggestion\": \"放大注意力可视化图,确保图中的文字和连接线清晰可见\"},\n {\"page\": 15, \"issue_type\": \"readability\", \"severity\": \"medium\", \"suggestion\": \"增加可视化图中文字的字号,或提供更清晰的图例说明不同颜色代表的含义\"},\n {\"page\": 16, \"issue_type\": \"image_size\", \"severity\": \"medium\", \"suggestion\": \"放大指代消解可视化图,确保图中的文字和注意力模式清晰可辨\"},\n {\"page\": 16, \"issue_type\": \"readability\", \"severity\": \"medium\", \"suggestion\": \"增加图中文字的字号,或在页面底部添加更详细的文字说明来解释可视化结果\"}\n ]\n}"
},
"usage": {
"prompt_tokens": 21794,
"completion_tokens": 1448,
"total_tokens": 23242,
"cached_prompt_tokens": 0
}
}
]