{"id":3479,"date":"2026-08-08T15:00:00","date_gmt":"2026-08-08T15:00:00","guid":{"rendered":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/"},"modified":"2026-08-08T22:59:10","modified_gmt":"2026-08-08T22:59:10","slug":"before-q-k-and-v-reconstructing-the-transformer","status":"publish","type":"post","link":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/","title":{"rendered":"Earlier than Q, Okay, and V: Reconstructing the Transformer"},"content":{"rendered":"<p><br \/>\n<\/p>\n<div>\n<p class=\"wp-block-paragraph\"> keys, queries, values, and dot product consideration?<\/p>\n<p class=\"wp-block-paragraph\">\u201cYou want keys and queries for tokens to speak to one another,\u201d says the favored Web analogy. However why? There\u2019s a variety of nice analogies for the way they work, however loads much less materials about why we actually want them. Are there any options or are these summary ideas inevitable?<\/p>\n<p class=\"wp-block-paragraph\">This may seem to be a foolish query given the utter success of the Transformer structure in 2026. But when historical past is any indication, Transformers will finally get replaced by one thing higher. The extra we perceive why they work, the sooner we are able to transfer past them.<\/p>\n<p class=\"wp-block-paragraph\">Extremely, we are able to present that the overall form of the Transformer is tough to keep away from! Begin with a couple of key design pressures, and the alphabet soup of matrices begins to look a lot much less arbitrary. With out counting on any \u201ctoken asks a query\u201d analogies, we\u2019ll see that queries come up from a symmetry drawback, whereas values and a spotlight heads seem once we exchange an unwieldy dynamic weight matrix with a small set of reusable transformations.<\/p>\n<p class=\"wp-block-paragraph\">And as we reconcile our toy mannequin with the unique (autoregressive) Transformer, we\u2019ll finish with one final fascinating connection: the MLP\u2014the often-overlooked feedforward block\u2014may be considered as a key-value retailer of its personal.<\/p>\n<p class=\"wp-block-paragraph\">Able to invent the Transformer for ourselves? First, we have to journey again to 2014 and ask why recurrent neural networks aren\u2019t sufficient.<\/p>\n<h2 class=\"wp-block-heading\">Why Mounted Reminiscence Fails<\/h2>\n<p class=\"wp-block-paragraph\">There are numerous points with commonplace recurrent neural networks (RNNs.) Some points, just like the \u201cgradient vanishing\u201d subject, had been solved by the extraordinarily fashionable LSTM (Lengthy Quick-Time period Reminiscence community) by Hochreiter and Schmidhuber [1] which is a extra superior taste of RNN. However one core subject stays for all flavors: RNNs \u201csquish\u201d previous inputs collectively into mounted reminiscence.<\/p>\n<p class=\"wp-block-paragraph\">To see why, recall that an RNN has a reminiscence state that&#8217;s \u201cwritten to\u201d by the present enter and the earlier state. This connection between states in time is the place the \u201crecurrence\u201d comes from. Take into account the next two layer RNN unrolled in time:<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/rnn_unrolled_in_time_v2.png\" alt=\"\" class=\"wp-image-677323\"\/><figcaption class=\"wp-element-caption\">Fig. 1: RNN unrolled in time. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Right here the inputs are inexperienced, the outputs are blue, and the 2 intermediate layers of the community that compute commonplace neural community activations are grey. All the elements are vectors, and the directed arrows are matrix weights that multiply their inputs. To see the community at one time limit, merely take a look at a single vertical slice of the diagram; in that slice, there are two mounted grey models that collectively signify the \u201creminiscence\u201d of the community at that time limit.<\/p>\n<p class=\"wp-block-paragraph\">Let\u2019s use a crude analogy to point out why this \u201cmounted reminiscence\u201d is a matter. Say you encode the sentence \u201cI&#8217;ve 5 {dollars}\u201d into the RNN\u2019s reminiscence, which we\u2019ll signify with the gray rectangle beneath:<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/box_text_no_overlap.png\" alt=\"\" class=\"wp-image-677317\"\/><figcaption class=\"wp-element-caption\">Fig. 2: Reminiscence analogy. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Now let\u2019s lengthen that sentence to \u201cI&#8217;ve 5 {dollars} and forty cents in my pocket\u201d:<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/box_text_overlap.png\" alt=\"\" class=\"wp-image-677319\"\/><figcaption class=\"wp-element-caption\">Fig. 3: Compressed reminiscence analogy. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Yikes. After including extra info into finite reminiscence, there&#8217;s better \u201ccompetitors\u201d for actual property and a few reminiscence is overwritten. That is disastrous when you have to recall particular details or comply with very particular directions.<\/p>\n<p class=\"wp-block-paragraph\">You could be pondering, \u201cWhy not use dynamic reminiscence that grows with the enter sequence?\u201d<\/p>\n<p class=\"wp-block-paragraph\">Nice instinct! That is precisely what Bahdanau et al. [2] tried in 2014 after they popularized the thought of \u201cconsideration\u201d inside the RNN (sure, RNNs used consideration earlier than Transformers did!)<\/p>\n<p class=\"wp-block-paragraph\">The concept, at a excessive degree, is to maintain the complete earlier historical past of the RNN states as our \u201cincreasing reminiscence\u201d, which naturally has the property of rising with the enter sequence. Take into account the next up to date diagram (this isn&#8217;t the precise structure within the Bahdanau paper, however an analogy):<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/rnn_with_attention_v2.png\" alt=\"\" class=\"wp-image-677324\"\/><figcaption class=\"wp-element-caption\">Fig. 4: RNN with consideration. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Be aware the brand new connections in purple; these join the grey states within the RNN layers to each earlier enter in time. Earlier than including these connections, every state was pressured to compress all the historic info and move it alongside within the left-to-right \u201crecurrent\u201d connections. However this compression is now not wanted since each state now has direct entry to the complete historical past of inputs, aka our rising reminiscence!<\/p>\n<p class=\"wp-block-paragraph\">There&#8217;s one large problem that is still: coaching pace. At coaching time, we&#8217;ve every enter sequence accessible up entrance. However producing the ultimate Nth output requires N sequential steps in time given the recurrent dependencies; with lengthy enter sequences, we&#8217;ve lengthy sequential computations that can&#8217;t be parallelized by GPUs.<\/p>\n<p class=\"wp-block-paragraph\">The concept within the landmark paper by Vaswani et al. [3] is that this: What if we are able to take away these recurrent left-to-right connections? What if the purple connections are all you want? See the next diagram that represents this concept at a excessive degree:<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/nonrecurrent_rnn_attention_v2.png\" alt=\"\" class=\"wp-image-677326\"\/><figcaption class=\"wp-element-caption\">Fig. 5: Consideration with no recurrence. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Let\u2019s stack the recurrent and non-recurrent architectures facet by facet, and evaluate their whole variety of compute steps by placing ordered labels for every step:<\/p>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/rnn_attention_recurrence_vs_no_recurrence_v2.png\" alt=\"\" class=\"wp-image-677328\"\/><figcaption class=\"wp-element-caption\">Fig. 6: Time steps \u2013 recurrence vs. no recurrence. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Be aware how the non-recurrent mannequin wanted solely 2 compute steps, since it might probably compute every layer fully in parallel as soon as the earlier layer is computed. However, the recurrent mannequin wanted 5 compute steps as a result of recurrent dependencies inside every layer. Because the sequence will get longer, the non-recurrent mannequin would keep at 2 steps whereas the recurrent mannequin\u2019s steps would develop ceaselessly with the sequence. It\u2019s not wanting good for recurrence!<\/p>\n<p class=\"wp-block-paragraph\">Let\u2019s pivot to the non-recurrent mannequin on the suitable. Now, we run into our subsequent problem: How on Earth ought to we choose the weights for these purple connections?<\/p>\n<h2 class=\"wp-block-heading\">Transformers and Dynamic Weights<\/h2>\n<p class=\"wp-block-paragraph\">When you take a look at the diagram of our non-recurrent community, it seems to be identical to an strange neural community with two layers and 4 models per layer. With such a community, we&#8217;d ask: Why not be taught mounted weights like we do with every other community?<\/p>\n<p class=\"wp-block-paragraph\">However not like this mounted diagram, sequences are usually not mounted throughout coaching or prediction. The community might encounter an enter sequence of dimension 2 or it might encounter an enter sequence of dimension 2000, and our diagram might develop indefinitely to the suitable with ever extra models and weights. So how can we set these incoming new weights?<\/p>\n<p class=\"wp-block-paragraph\">What we&#8217;d like is a perform to generate new weights on the fly, with parameters that we are able to set throughout coaching. We&#8217;d like dynamic weights!<\/p>\n<p class=\"wp-block-paragraph\">To determine a great perform, let\u2019s zoom into one explicit unit with a size 3 sequence:<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/single_unit_transformer_v2.png\" alt=\"\" class=\"wp-image-677330\"\/><figcaption class=\"wp-element-caption\">Fig. 7: Zoomed neural unit. Picture by writer.<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">First, an essential notice on a brand new diagram addition: To make the diagram full, we would have liked so as to add skip connections. By these, the inputs x1, x2, and x3 are added again to the outputs of O1, O2, and O3 respectively (and this course of repeats once more on the subsequent layer when O1, O2, and O3 develop into inputs themselves.) These \u201cskips\u201d free intermediate transformations from having to protect the inputs and allow them to concentrate on the a lot simpler job of additively adjusting these inputs. Skip connections are a crucial efficiency optimization that had been pioneered within the well-known ResNet structure by He et al. [4].<\/p>\n<p class=\"wp-block-paragraph\">Now again to our perform to generate weights dynamically. First, we have to resolve what the weights ought to be a perform of.<\/p>\n<p class=\"wp-block-paragraph\">We might begin by defining a given weight as a perform of the output of the burden\u2019s supply unit in addition to the place of that supply unit within the left-right sequence. To make issues easy, I\u2019ll mix \u201center\u201d and \u201cplace\u201d collectively and simply say \u201center\u201d going ahead (this merging may be carried out by encoding place into the enter instantly; to see how this could be carried out, examine sinusoidal encodings within the authentic Transformer structure.) Then, our diagram seems to be one thing like this:<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/single_unit_weight_f_of_input_v2.png\" alt=\"\" class=\"wp-image-677334\"\/><figcaption class=\"wp-element-caption\">Fig. 8: Naive dynamic weights. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">There\u2019s one apparent draw back right here: If x1 must be \u201cessential\u201d to O3 through a \u201cmassive\u201d weight, then it&#8217;s pressured to even be essential to O2 and O1 since all of them share the identical worth for his or her x1 weights. Which means that close by blue models inside a layer will compute very comparable issues, defeating the pliability of this structure to mannequin distinctive ideas. To repair this, we have to break the \u201csymmetry\u201d and make every of the weights of O1, O2, and O3 distinctive from each other.<\/p>\n<p class=\"wp-block-paragraph\">We might break the symmetry by making a given weight a perform of each the supply unit\u2019s output and the tip unit\u2019s output; nonetheless, utilizing the tip unit\u2019s output instantly is round since we first want the burden to compute the tip output.<\/p>\n<p class=\"wp-block-paragraph\">To get round this circularity, notice that every unit\u2019s distinctive objective is to change its enter stream; for instance, O3 is uniquely chargeable for modifying x3 through the skip connection. Since x3 and O3 are uniquely intertwined, x3 is a pure candidate for the second, symmetry-breaking argument to generate O3\u2019s weights!<\/p>\n<p class=\"wp-block-paragraph\">Once we replace the diagram it&#8217;s clear that every one weights at the moment are distinctive:<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/single_unit_weights_f_of_input_output_v2-1.png\" alt=\"\" class=\"wp-image-677335\"\/><figcaption class=\"wp-element-caption\">Fig. 9: Symmetry-broken dynamic weights. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">You probably have a great eye, you may begin to spot the \u201ckey\u201d and \u201cquestion\u201d of the Transformer structure already! But when not, no worries; we\u2019ll construct as much as that extra formally.<\/p>\n<p class=\"wp-block-paragraph\">One final name out: We might additionally break symmetry by making the weights zero for each enter besides the one {that a} unit modifies, however then you definitely get the next diagram that reveals that is successfully a state-less community:<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/single_unit_transformer_stateless_v2.png\" alt=\"\" class=\"wp-image-677336\"\/><figcaption class=\"wp-element-caption\">Fig. 10: Naive symmetry breaking. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">In different phrases, symmetry breaking is a needed however not enough situation. We additionally want some non-zero interactivity between models and different models from totally different time steps.<\/p>\n<h2 class=\"wp-block-heading\">Keys, Queries, and Values Emerge Naturally<\/h2>\n<p class=\"wp-block-paragraph\">Now that we\u2019ve determined to generate every weight through a perform of two arguments, we have to resolve what this perform really seems to be like.<\/p>\n<p class=\"wp-block-paragraph\">Keep in mind that every weight is a matrix that multiplies enter vectors into output vectors, so our perform really must be matrix-valued. However that introduces a brand new drawback: How can we make these matrices dynamic with out blowing up the variety of parameters in our mannequin?<\/p>\n<p class=\"wp-block-paragraph\">To see why parameter explosion is actual, let\u2019s write our perform in matrix kind, utilizing the burden between x1 and O3 for example:<\/p>\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_001-1-1024x318.png\" alt=\"\" class=\"wp-image-677337\" style=\"width:580px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">Right here, every place (i, j) of the (d x d) matrix has its personal perform. If we parametrize every perform individually, that\u2019s d-squared separate units of parameters that should be match. When the dimension d is within the vary of a whole bunch, that\u2019s &gt;100K units of parameters that need to be realized. Laborious move!<\/p>\n<p class=\"wp-block-paragraph\">We might vastly cut back that quantity by solely becoming a diagonal matrix:<\/p>\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_002-1-1024x319.png\" alt=\"\" class=\"wp-image-677341\" style=\"width:579px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">Nevertheless, that is nonetheless a whole bunch of units of perform parameters to suit, and we haven\u2019t even gotten into the scale of these units. Additionally, notice that diagonal matrices carry out element-wise multiplication on their inputs; if components of the ultimate vector should be zero for causes like sparsity, then features in these diagonal parts should be very near zero or zero precisely\u2014which places a variety of burden on the features themselves.<\/p>\n<p class=\"wp-block-paragraph\">To see another, let\u2019s rewrite that diagonal matrix as a linear mixture of one-hot matrices:<\/p>\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_003-1-895x1024.png\" alt=\"\" class=\"wp-image-677342\" style=\"width:443px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">What if as a substitute of utilizing these one-hot matrices within the sum, we use any matrices we wished? We might make every matrix a parameter to be realized, after which choose the ultimate variety of learnable matrices in order that the overall nested parameter depend is cheap. Then we might rewrite our weight between x1 and O3 as a brand new matrix sum:<\/p>\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_004-1-1024x440.png\" alt=\"\" class=\"wp-image-677348\" style=\"width:299px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">Superior; we simply changed a painful dynamic matrix with a small variety of static matrices and dynamic coefficients! Right here, the V\u2019s are the static matrices that we be taught as free parameters and the features within the sum are our dynamic scalar-valued coefficients. Preserve the V\u2019s in thoughts; they\u2019ll present up within the consideration \u201cworth\u201d calculations later.<\/p>\n<p class=\"wp-block-paragraph\">Lastly, we have to outline the scalar-valued features inside that sum above. To try this, let\u2019s additively decompose one of many features into two single argument \u201cnon-interaction\u201d features sandwiching a pure interplay perform:<\/p>\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_005-1024x198.png\" alt=\"\" class=\"wp-image-677350\" style=\"width:424px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">The draw back to having non-interaction features is identical draw back we encountered with weight symmetries from the final part: If the left time period is massive, then it\u2019ll be massive for all models linked to x1 since x1 is the one dependency within the time period. We need to break this symmetry so let\u2019s preserve solely the center interplay perform v, which I\u2019ll name the \u201cconsideration\u201d perform to any extent further.<\/p>\n<p class=\"wp-block-paragraph\">One candidate for the eye perform was launched in Bahdanau et al. [2]:<\/p>\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_006-1024x205.png\" alt=\"\" class=\"wp-image-677351\" style=\"width:410px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">Chances are you&#8217;ll acknowledge this as a easy one layer neural community with hyperbolic tangent activation, the place the ultimate result&#8217;s decreased to a scalar worth through a dot product.<\/p>\n<p class=\"wp-block-paragraph\">There&#8217;s one draw back to utilizing the tanh perform right here: It is just weakly interacting by its non-linearity. The perform\u2019s contours get squashed non-linearly, however their fundamental construction nonetheless seems to be like a linear sum. To see this visually, evaluate the similarity in contour plots for tanh of x1 plus x3 vs. the straight sum of x1 and x3 (the place we\u2019ll make x1 and x3 1D inputs for ease of visualization):<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/contour_plot_tanh_vs_linear.png\" alt=\"\" class=\"wp-image-677353\"\/><figcaption class=\"wp-element-caption\">Fig. 11: Contour plots, tanh of sum vs. straight sum. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Let\u2019s actually spotlight the problem with an instance: Suppose all of the models in our community use one of many features above, and one unit has inputs x1 and x3.<\/p>\n<p class=\"wp-block-paragraph\">If this unit must output a big constructive worth, then there\u2019s just one area that satisfies this on both plot: the highest proper half. But when one other unit shares the identical x1 enter and requires x1 to be on the left facet (i.e. unfavourable) to attain its aim, then you definitely\u2019re caught on the primary unit\u2019s requirement until x3 is a large constructive quantity to compensate. Each models\u2019 necessities are, to a level, incompatible. This community is much less versatile in what its totally different models can mannequin after they share some inputs.<\/p>\n<p class=\"wp-block-paragraph\">However, take a look at the contour plot of the product perform beneath:<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/contour_plot_product.png\" alt=\"\" class=\"wp-image-677356\"\/><figcaption class=\"wp-element-caption\">Fig. 12: Contour plot for product perform. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Now, there are two distinct areas the place the ultimate output is massive, not only one! If one other unit shares the identical x1 enter and desires x1 to be unfavourable, not an issue; the primary unit can nonetheless output a big constructive worth if x3 is unfavourable. Each models\u2019 necessities are now not as incompatible as earlier than. It is a refined mathematical argument for the way \u201cinteractivity\u201d (for instance, through a product) issues in permitting models to mannequin distinctive issues regardless of having overlap of their inputs.<\/p>\n<p class=\"wp-block-paragraph\">You may ask, \u201cWhy not use a deeper neural community to mannequin a extra interactive consideration perform?\u201d That is fairly pricey in apply as a result of the variety of consideration calculations scales quadratically with sequence size. And contemplate that we don\u2019t make every layer of a conventional neural community sophisticated both; usually we use easy non-linear features like ReLU (rectified linear models) and let extra layers iteratively construct up complexity.<\/p>\n<p class=\"wp-block-paragraph\">May we do one thing comparable right here, i.e. go along with a easy but interactive consideration perform and construct up complexity over layers? In that case, the product perform is a superb candidate\u2014and GPUs like it too!<\/p>\n<p class=\"wp-block-paragraph\">There&#8217;s one tweak we have to make since our consideration inputs are multi-dimensional vectors, not 1D inputs. As a substitute of a scalar product, we&#8217;d like a dot product. Extra typically, you may need to compute the dot product in a specific sub-space, which leads to a bilinear kind that appears like this:<\/p>\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_007-1.png\" alt=\"\" class=\"wp-image-677357\" style=\"width:96px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">Be aware that this reduces to a plain dot product when A is the identification matrix, so this way is extra normal.<\/p>\n<p class=\"wp-block-paragraph\">There&#8217;s one other consideration that we have to begin discussing right here: the computation \u201ccache\u201d (what you might have heard because the \u201ckey-value cache\u201d in fashionable architectures.) We will keep away from a big variety of consideration computations by caching matrix multiplications (e.g. A instances x1 above) for previous inputs, since we reuse these previous calculations for each new time step at each layer.<\/p>\n<p class=\"wp-block-paragraph\">Nevertheless, the scale of this cache turns into a fairly large ache level. Instance: If we&#8217;ve a sequence size of 5,000 (fairly a bit smaller than many commonplace LLM conversations), 50 layers, 20 totally different V matrices \u2013&gt; 20 totally different dot product features (see our matrix sum definition earlier), cached matrix-vector merchandise of dimension 1000, and a couple of bytes per floating level quantity, then the ultimate dimension of our cache is: 5000 x 50 x 20 x 1000 x 2 = 10 GB. Ouch.<\/p>\n<p class=\"wp-block-paragraph\">Bigger caches imply extra GPU value and reminiscence overhead. One optimization is to easily cut back the dimension of the cached merchandise from 1000 to a decrease dimension r, so long as it doesn\u2019t considerably affect mannequin accuracy. However this requires the ultimate dot product to now be in an r-dimensional house reasonably than a 1000-dimensional one.<\/p>\n<p class=\"wp-block-paragraph\">We will decrease that dot product dimension by factorizing the matrix A into two matrices that \u201cundertaking\u201d the vectors x3 and x1 into the r-dimensional house:<\/p>\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_008-1024x166.png\" alt=\"\" class=\"wp-image-677359\" style=\"width:522px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">Right here, Wq and Wk are (r x 1000) matrices, and the right-most expression is the specified dot product between two r-dimensional vectors. If r is simply 200, then the ultimate cache dimension goes from 10 GB to 2 GB\u2014a 5x discount!<\/p>\n<p class=\"wp-block-paragraph\">Now for the grand reveal: The left and proper phrases within the new dot product are nothing however the \u201cquestion\u201d and \u201ckey\u201d within the Transformer structure, and the projection matrices are the identical learnable matrices within the authentic paper! (One caveat is that the Transformer structure provides scaling for computational stability, therefore the time period \u201cscaled dot product consideration\u201d. However for the remainder of this text, I\u2019ll concentrate on the form of the structure reasonably than on coaching optimizations like scaling.)<\/p>\n<p class=\"wp-block-paragraph\">We will now substitute this consideration perform into the coefficients of our earlier matrix sum, with totally different parameters for every j:<\/p>\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_009-1024x508.png\" alt=\"\" class=\"wp-image-677360\" style=\"width:425px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">Fast abstract of the place we&#8217;re: The perform \u201cf\u201d on the left spits out the burden matrix between enter x1 and unit O3; this matrix is the same as a sum involving H scalar consideration features as coefficients, and based mostly on our dialogue, we\u2019ve chosen to make use of dot product consideration for every perform. Then we are able to signify the sum whole of all weighted inputs into O3 with a brand new sum s3:<\/p>\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_010-1024x470.png\" alt=\"\" class=\"wp-image-677361\" style=\"width:451px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">The time period WQ * x3 is the question for x3, the time period WK * xi is the important thing for xi, and the time period V * xi is the worth for xi. The subscript j on the matrices denotes a specific consideration \u201chead\u201d among the many H heads; every head has a novel learnable question, key, and worth projection matrix. That is beginning to look identical to a Transformer!<\/p>\n<h2 class=\"wp-block-heading\">From Our Consideration to Transformer Consideration<\/h2>\n<p class=\"wp-block-paragraph\">In our earlier instance, the outer sum is over a paltry sequence of dimension 3. However this sum blows up in dimension when the sequence will get actually lengthy.<\/p>\n<p class=\"wp-block-paragraph\">One solution to handle this can be a commonplace machine studying trick known as normalization: Take the prevailing coefficients within the weighted sum and rework them in order that the reworked coefficients sum to 1 whatever the earlier quantity and dimension of coefficients.<\/p>\n<p class=\"wp-block-paragraph\">We&#8217;d additionally need sparsity within the reworked coefficients; within the area of language, there are a whole bunch of irrelevant phrases that may add up weight rapidly, so we need to aggressively squash the whole lot however a couple of coefficients.<\/p>\n<p class=\"wp-block-paragraph\">To see how we must always add normalization to our system, notice that we have to do that normalization within the sum over the sequence size, not within the sum over the heads. In that case, we have to flip the order of the sums as follows:<\/p>\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_011-1024x475.png\" alt=\"\" class=\"wp-image-677362\" style=\"width:455px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">Now, the time period contained in the outer parentheses seems to be like a sum over the sequence size L with coefficient weights (key-query dot merchandise) on the ultimate worth vectors\u2014simply as we wished. We then apply a normalization transformation to these dot product coefficients. The pure alternative of transformation for attaining delicate sparsity is the softmax transformation, which exponentiates every coefficient and divides that outcome by the sum of all exponentiated coefficients:<\/p>\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_012-1024x433.png\" alt=\"\" class=\"wp-image-677363\" style=\"width:467px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">That is known as the \u201csoftmax\u201d as a result of it aggressively pushes the most important (max) coefficient to 1 and squashes all different coefficients in direction of 0. The tau parameter within the exponent controls how aggressive this transformation is.<\/p>\n<p class=\"wp-block-paragraph\">Okay, all of that is nice\u2014however the place are the matrices Q, Okay, and V that the article title promised us?<\/p>\n<p class=\"wp-block-paragraph\">To match our expression with the long-lasting Transformer equation, let\u2019s quickly ignore the outer sum over heads by choosing a specific head j and rewrite the normalized sum at place L for that head:<\/p>\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_013-1024x302.png\" alt=\"\" class=\"wp-image-677364\" style=\"width:368px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">Right here, q is the question vector for the Lth unit, and the rows of matrices Okay and V are the important thing and worth vectors respectively. The subscript 1:L signifies that we solely use the keys and values for positions 1 by L, which displays the truth that the Lth unit is simply linked to earlier models in time. The product between q and Okay^T creates a vector containing each dot product between q and a key in Okay, and the softmax on prime normalizes the ultimate dot product scores. Afterwards, we do a weighted sum of worth vectors in V utilizing the ensuing softmax scores.<\/p>\n<p class=\"wp-block-paragraph\">We will lengthen this right into a single consolidated matrix expression for the sum at each place, not simply place L:<\/p>\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_014-1024x261.png\" alt=\"\" class=\"wp-image-677365\" style=\"width:426px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">That is precisely the long-lasting Transformer equation (minus dimensional scaling) however for an autoregressive Transformer! Right here, every row of S is the ultimate sum at that place, and every row of Q, Okay, and V are the respective question, key, and worth vectors at that place. Since we&#8217;re utilizing the total matrices Q, Okay, and V, we&#8217;d like a masking matrix M to zero out invalid dot merchandise (such because the dot product between a question at place p and a key at a later place) by including in unfavourable infinity to these entries; the softmax then squashes these outcomes to zero.<\/p>\n<p class=\"wp-block-paragraph\">Why write this with matrices as a substitute of our authentic sum if the 2 expressions are equivalent? The reply is straightforward: GPUs love matrix multiplication. It&#8217;s usually extra environment friendly to rewrite a computation as a matrix multiplication, even when which means performing some pointless work like computing dot merchandise which shall be masked out anyway. That being stated, I discover the sum notation simpler to make use of for explanations, so I\u2019ll keep it up for the remainder of the article.<\/p>\n<p class=\"wp-block-paragraph\">Let\u2019s shut out the part by returning to the sum over consideration heads. You&#8217;ll have seen that whereas we sum over the H consideration heads, Vaswani et al. [3] and implementations like PyTorch\u2019s \u201cMultiheadAttention\u201d concatenate the outputs throughout every head as a substitute\u2014and multiply the concatenation by a \u201cmixing matrix\u201d Wo that collapses the concatenation again to the earlier mannequin dimension.<\/p>\n<p class=\"wp-block-paragraph\">This may appear like a beauty distinction; why concatenate if you&#8217;re simply going to break down again down?<\/p>\n<p class=\"wp-block-paragraph\">The trick is caching, however now with a concentrate on worth vectors: We&#8217;d like the blending matrix to permit us to compress these worth vectors (V * x\u2019s) so our cache doesn\u2019t explode. Let\u2019s see what occurs to our double sum expression if we concatenate the output of every head j right into a block vector as a substitute of summing over the heads:<\/p>\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_015.png\" alt=\"\" class=\"wp-image-677366\" style=\"width:298px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">For the sake of readability, I\u2019ve substituted in alphas for the earlier normalized coefficients so there aren\u2019t a bunch of exponentials all over the place.<\/p>\n<p class=\"wp-block-paragraph\">Now let\u2019s left-multiply this lengthy block vector by the blending matrix Wo. Let\u2019s first re-write Wo into an identical block matrix kind after which carry out the multiplication:<\/p>\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_016-1024x635.png\" alt=\"\" class=\"wp-image-677369\" style=\"width:433px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">Be aware how comparable the ultimate result&#8217;s to our authentic double sum! The one distinction is the block matrix left multiplying V; when every block matrix is the identification matrix, the brand new expression is completely equivalent to our authentic expression.<\/p>\n<p class=\"wp-block-paragraph\">Chances are you&#8217;ll ask, \u201cWhy not simply soak up the Wo block matrices into the V matrices?\u201d At first look, the 2 matrices appear redundant if you happen to can collapse them right into a single one. However the cause we\u2019d need to preserve them separate is identical cause we didn\u2019t use a single matrix A for our consideration dot product: reducing our cache dimension.<\/p>\n<p class=\"wp-block-paragraph\">Let\u2019s say we did soak up the whole lot right into a single matrix V. If our mannequin dimension is 1000 and we use the identical circumstances from our key-based cache instance earlier, then the cumulative cache dimension for our price vectors is an unwieldy 10 GB. But when V has the form (r x 1000) the place r &lt; 1000, then the ultimate dimension of our price vectors shall be r &lt; 1000 and our cache dimension may be significantly smaller. <\/p>\n<p class=\"wp-block-paragraph\">Herein lies the necessity for the Wo matrices; after we\u2019re carried out having our enjoyable in decrease dimensions, we have to multiply the ultimate values by a matrix of form (1000 x r) to \u201cup undertaking\u201d again to the bigger mannequin dimension of 1000.<\/p>\n<h2 class=\"wp-block-heading\">The Transformer MLP: The Different Key-Worth Retailer<\/h2>\n<p class=\"wp-block-paragraph\">Every part we did earlier was to outline the weights in our community. If we isolate one enter xi within the sum of weighted inputs from our final expression, then its weight into unit L is the same as:<\/p>\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/eq_017.png\" alt=\"\" class=\"wp-image-677371\" style=\"width:267px\"\/><\/figure>\n<p class=\"wp-block-paragraph\">Right here, every alpha coefficient is unit L\u2019s softmax normalized scalar for enter i and a given head j.<\/p>\n<p class=\"wp-block-paragraph\">Upon getting all of the weights, all you have to do is to sum up the weighted inputs into every unit, compute the position-wise non-linearity, and add again to the residual stream through the skip connection to replace the positional illustration. Voila, there\u2019s your neural community!<\/p>\n<p class=\"wp-block-paragraph\">These steps may be visually represented by the next recap diagram, utilizing the identical size 3 sequence for simplicity:<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/single_unit_attention_as_blocks.png\" alt=\"\" class=\"wp-image-677372\"\/><figcaption class=\"wp-element-caption\">Fig. 13: Community recap. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">You&#8217;ll have seen that Vaswani et al. [3] introduce two new weight matrices (W1 and W2) that sandwich the non-linearity within the blue models. At first look, these additions really feel like arbitrary add-ons. If we\u2019ve already carried out all this work to outline dynamic weights through consideration, then do we actually want two new matrices across the non-linearity?<\/p>\n<p class=\"wp-block-paragraph\">It seems that W2 isn\u2019t there only for the sake of it. Geva et al. [5] give us essential perspective for understanding why: The Transformer MLP (feed-forward block) acts like a key-value retailer in its personal proper.<\/p>\n<p class=\"wp-block-paragraph\">To see this, let\u2019s really present the place the \u201ckeys\u201d and \u201cvalues\u201d would reside in an instance MLP community:<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/mlp_key_value_store_v2.png\" alt=\"\" class=\"wp-image-677374\"\/><figcaption class=\"wp-element-caption\">Fig. 14: MLP as a key-value retailer. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">On this community, the center layer has purple, inexperienced, and blue models that every mannequin totally different patterns. The incoming (first layer) weights of the identical coloration signify the \u201ckey\u201d vectors for every sample, and the outgoing (final layer) weights of the identical coloration signify the \u201cworth\u201d vectors for every sample. Geva et al. [5] reveal what a few of these \u201cpatterns\u201d might appear like; for the mannequin they educated, one instance of a realized sample was every time the enter sentence ended within the phrase \u201csubstitutes\u201d, and one other was every time the enter sentence contained a \u201ca part of\u201d relation.<\/p>\n<p class=\"wp-block-paragraph\">Now let\u2019s stroll by what the \u201ckeys\u201d and \u201cvalues\u201d really do right here. When the enter aligns intently with the important thing vector (incoming weights) for a given sample, the dot product between the important thing and enter is excessive, and the unit related to that sample outputs a big quantity. That quantity then multiplies the worth vector (outgoing weights) for the sample and this weighted worth vector is lastly added to the output layer.<\/p>\n<p class=\"wp-block-paragraph\">So again to our additional parameters: What does this inform us about why we&#8217;d like W2?<\/p>\n<p class=\"wp-block-paragraph\">Recall that W2 is simply the matrix multiplied to the output of the non-linearity within the authentic Transformer. In our MLP instance, W2 is precisely equal to the matrix of weights within the last layer, i.e. a matrix the place every column is one worth vector.<\/p>\n<p class=\"wp-block-paragraph\">If we do away with W2, our diagram would as a substitute look one thing like this:<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/mlp_key_value_no_w2_v2.png\" alt=\"\" class=\"wp-image-677375\"\/><figcaption class=\"wp-element-caption\">Fig. 15: MLP with no W2 matrix. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Every unit on this community is writing to a single coordinate of the residual stream (since we add the output layer instantly again to the residual stream.) However there are two the reason why that is unhealthy:<\/p>\n<p>If we would like our models to be taught arbitrary patterns, then every of these arbitrary patterns won&#8217;t map cleanly to single coordinates of the \u201csemantic house\u201d at that layer. In that case, it&#8217;s way more expressive to permit every unit to jot down arbitrary vectors (values) into the residual stream reasonably than coupling them to particular person output coordinates.<\/p>\n<p>We wish our MLPs to mannequin as many patterns as potential, which pushes us to have extra models within the MLP community relative to the mannequin dimension within the residual stream (the place the latter is saved smaller to keep away from gnarly consideration computations that don\u2019t profit as a lot from excessive dimensions.) In that case, a 1:1 correspondence of coordinates isn\u2019t even potential; we&#8217;d like a matrix to \u201cdown undertaking\u201d again to the smaller mannequin dimension in any case.<\/p>\n<p class=\"wp-block-paragraph\">We\u2019ve spent all this time discussing W2; what about W1, the additional matrix multiplying contained in the non-linearity?<\/p>\n<p class=\"wp-block-paragraph\">This may increasingly really be the extra arbitrary matrix. In our setup, W1 might certainly be absorbed into our dynamic weight matrices (particularly, Wo from the earlier part) and dropped as an additional parameter. However there&#8217;s a cause this may\u2019t be carried out within the authentic Transformer: In that setup, there are two intermediate steps between the eye output and the non-linearity that stop consolidation of matrices.<\/p>\n<p class=\"wp-block-paragraph\">First, the Transformer splits our single large skip connection right into a skip connection between the enter and the sum output in addition to a second skip between the sum output and the non-linearity output. See the modified diagram with the break up skip connection:<\/p>\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2026\/07\/single_unit_attention_as_blocks_double_skip.png\" alt=\"\" class=\"wp-image-677377\"\/><figcaption class=\"wp-element-caption\">Fig. 16: The Transformer block\u2019s twin skip connections. Picture by writer<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Upon getting this extra skip connection, you want a separate weight matrix utilized on the sums of the output from the eye (capital sigma) blocks and the residuals from the primary skips. The burden matrix utilized to that sum of outputs can now not be cleanly absorbed, so that you want a separate parameter.<\/p>\n<p class=\"wp-block-paragraph\">Secondly, there&#8217;s an extra scaling transformation between the sum of consideration outputs and the non-linearity that stops absorption. Whereas these scaling transformations are essential, they&#8217;re coaching optimizations, and so I\u2019ve omitted them to focus purely on architectural form right here.<\/p>\n<h2 class=\"wp-block-heading\">Recapping the Logic<\/h2>\n<p class=\"wp-block-paragraph\">Pat your self on the again; you simply invented the Transformer! Right here\u2019s a recap of the steps we took to get right here:<\/p>\n<p>We wanted to entry each previous state of the sequence with out compression loss. This required direct connections to previous states, aka \u201cconsideration\u201d.<\/p>\n<p>We wanted parallelism for quick GPU coaching. This required dropping recurrence.<\/p>\n<p>We wanted a solution to set new weights for future inputs with out introducing weight symmetries throughout the community. This required making the weights a perform of the supply unit and the tip unit (each distinctive per weight), the place we used the residual stream\u2019s worth as a stand-in for the \u201cfinish unit\u201d. These two perform arguments are the \u201ckey\u201d and \u201cquestion\u201d previous to projection.<\/p>\n<p>We wanted to make the weight-generating perform keep away from symmetries by encoding pure interactions between the arguments. A GPU-efficient alternative for this interplay perform was the dot product between the important thing and question arguments.<\/p>\n<p>We wanted to scale back our cache dimension for the reusable matrix-vector multiplies within the dot product, which required computing the dot product in decrease dimensions. This required projection matrices Wk and Wq to undertaking the important thing and question into that decrease dimensional house.<\/p>\n<p>We wanted to scale back our search over the complete d^2 house of linear operations (matrices) right into a search over a smaller quantity H of potential operations that we are able to choose from through our dot product weights. That is represented by H totally different worth projections V representing our H consideration heads.<\/p>\n<p>We wanted to make the ultimate weights on the worth projections sparse so noise doesn\u2019t blow up over bigger sequences. This required softmax normalization of the dot product coefficients over sequence size, per head.<\/p>\n<p>We wanted to scale back our cache dimension for the reusable matrix-vector multiplies between the worth projections V and the inputs. This required the Vs to \u201cdown undertaking\u201d the ultimate worth vectors right into a decrease dimensional house, and a separate mixing matrix Wo to \u201cup undertaking\u201d again into the mannequin dimension.<\/p>\n<p>We wanted a bigger \u201ccharacteristic house\u201d for our non-linearities to be taught a number of patterns, whereas permitting these options to jot down arbitrary vectors to the decrease dimensional residual stream. This required a brand new matrix W2 that multiplies the output of the non-linearity.<\/p>\n<h2 class=\"wp-block-heading\">Why Transformers Aren\u2019t Inevitable<\/h2>\n<p class=\"wp-block-paragraph\">The one factor inevitable in AI\/ML is one structure changing one other, and Transformers are not any exception to the rule.<\/p>\n<p class=\"wp-block-paragraph\">However why will Transformers get replaced in the event that they work so nicely right now?<\/p>\n<p class=\"wp-block-paragraph\">For starters, Transformers have one large draw back: Computations scale quadratically with sequence size. You would implement sliding window consideration to attempt to get round this, however then you definitely lose the flexibility to recall pin-point details or directions hidden inside longer context.<\/p>\n<p class=\"wp-block-paragraph\">Chances are you&#8217;ll be questioning, \u201cHowever many of the consideration scores are principally zero as a result of softmax normalization. Do we have to calculate all n^2 scores?\u201d<\/p>\n<p class=\"wp-block-paragraph\">That\u2019s a fantastic perception, and makes an attempt at sparse consideration mechanisms have certainly been made. Nevertheless, regardless of the main discount in calculations, these mechanisms counterintuitively run slower than full quadratic consideration resulting from GPU reminiscence bottlenecks changing into the larger ache level, as mentioned by Dao et al. [6].<\/p>\n<p class=\"wp-block-paragraph\">This brings us to a different level: Transformers are benefitting enormously from being tailored for GPUs. A lot of their design selections revolve across the quirky reminiscence and compute patterns of GPUs, and something that might dethrone Transformers has to finally move the \u201cGPU odor take a look at\u201d. In different phrases, we&#8217;re trapped in a {hardware} native minima and are lacking out on significantly better algorithms due to it. Human intelligence doesn\u2019t run on GPUs, so why ought to we accept Transformers?<\/p>\n<h2 class=\"wp-block-heading\">References<\/h2>\n<p class=\"wp-block-paragraph\">[1] S. Hochreiter and J. Schmidhuber, \u201cLengthy Quick-Time period Reminiscence,\u201d Neural Computation, vol. 9, no. 8, pp. 1735-1780, 1997.<\/p>\n<p class=\"wp-block-paragraph\">[2] D. Bahdanau, Okay. Cho, and Y. Bengio, \u201cNeural Machine Translation by Collectively Studying to Align and Translate,\u201d Worldwide Convention on Studying Representations (ICLR), 2015.<\/p>\n<p class=\"wp-block-paragraph\">[3] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, \u0141. Kaiser, and I. Polosukhin, \u201cConsideration Is All You Want,\u201d Advances in Neural Info Processing Techniques 30 (NIPS), pp. 5998-6008, 2017.<\/p>\n<p class=\"wp-block-paragraph\">[4] Okay. He, X. Zhang, S. Ren, and J. Solar, \u201cDeep Residual Studying for Picture Recognition,\u201d IEEE Convention on Laptop Imaginative and prescient and Sample Recognition (CVPR), pp. 770-778, 2016.<\/p>\n<p class=\"wp-block-paragraph\">[5] M. Geva, R. Schuster, J. Berant, and O. Levy, \u201cTransformer Feed-Ahead Layers Are Key-Worth Reminiscences,\u201d Convention on Empirical Strategies in Pure Language Processing (EMNLP), pp. 5484-5495, 2021.<\/p>\n<p class=\"wp-block-paragraph\">[6] T. Dao, D. Y. Fu, S. Ermon, A. Rudra, and C. R\u00e9, \u201cFlashAttention: Quick and Reminiscence-Environment friendly Precise Consideration with IO-Consciousness,\u201d Advances in Neural Info Processing Techniques 35 (NeurIPS), pp. 16344-16359, 2022.<\/p>\n<\/div>\n<p><br \/>\n<br \/><a href=\"https:\/\/towardsdatascience.com\/before-q-k-and-v-reconstructing-the-transformer\/\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>keys, queries, values, and dot product consideration? \u201cYou want keys and queries for tokens to speak to one another,\u201d says the favored Web analogy. However why? There\u2019s a variety of nice analogies for the way they work, however loads much less materials about why we actually want them. Are there any options or are these [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3481,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2026\/08\/antonio-janeski-ANP0t4EGMBE-unsplash-scaled-1.jpg","fifu_image_alt":"","jnews-multi-image_gallery":[],"jnews_single_post":[],"jnews_primary_category":[],"jnews_override_bookmark_settings":[],"jnews_social_meta":[],"jnews_override_counter":[],"footnotes":""},"categories":[7],"tags":[3856,3700],"class_list":["post-3479","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-science-mlops","tag-reconstructing","tag-transformer"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Earlier than Q, Okay, and V: Reconstructing the Transformer - Future News 24<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Earlier than Q, Okay, and V: Reconstructing the Transformer - Future News 24\" \/>\n<meta property=\"og:description\" content=\"keys, queries, values, and dot product consideration? \u201cYou want keys and queries for tokens to speak to one another,\u201d says the favored Web analogy. However why? There\u2019s a variety of nice analogies for the way they work, however loads much less materials about why we actually want them. Are there any options or are these [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/\" \/>\n<meta property=\"og:site_name\" content=\"Future News 24\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-08T15:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-08-08T22:59:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2026\/08\/antonio-janeski-ANP0t4EGMBE-unsplash-scaled-1.jpg\" \/>\n<meta name=\"author\" content=\"Future News 24\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2026\/08\/antonio-janeski-ANP0t4EGMBE-unsplash-scaled-1.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Future News 24\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"30 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/futurenews24.com\\\/index.php\\\/2026\\\/08\\\/08\\\/before-q-k-and-v-reconstructing-the-transformer\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/futurenews24.com\\\/index.php\\\/2026\\\/08\\\/08\\\/before-q-k-and-v-reconstructing-the-transformer\\\/\"},\"author\":{\"name\":\"Future News 24\",\"@id\":\"https:\\\/\\\/futurenews24.com\\\/#\\\/schema\\\/person\\\/cecad1bde21cfc357cf70128144d6c83\"},\"headline\":\"Earlier than Q, Okay, and V: Reconstructing the Transformer\",\"datePublished\":\"2026-08-08T15:00:00+00:00\",\"dateModified\":\"2026-08-08T22:59:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/futurenews24.com\\\/index.php\\\/2026\\\/08\\\/08\\\/before-q-k-and-v-reconstructing-the-transformer\\\/\"},\"wordCount\":6136,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/futurenews24.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/futurenews24.com\\\/index.php\\\/2026\\\/08\\\/08\\\/before-q-k-and-v-reconstructing-the-transformer\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/towardsdatascience.com\\\/wp-content\\\/uploads\\\/2026\\\/08\\\/antonio-janeski-ANP0t4EGMBE-unsplash-scaled-1.jpg\",\"keywords\":[\"Reconstructing\",\"Transformer\"],\"articleSection\":[\"Data Science &amp; MLOps\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/futurenews24.com\\\/index.php\\\/2026\\\/08\\\/08\\\/before-q-k-and-v-reconstructing-the-transformer\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/futurenews24.com\\\/index.php\\\/2026\\\/08\\\/08\\\/before-q-k-and-v-reconstructing-the-transformer\\\/\",\"url\":\"https:\\\/\\\/futurenews24.com\\\/index.php\\\/2026\\\/08\\\/08\\\/before-q-k-and-v-reconstructing-the-transformer\\\/\",\"name\":\"Earlier than Q, Okay, and V: Reconstructing the Transformer - Future News 24\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/futurenews24.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/futurenews24.com\\\/index.php\\\/2026\\\/08\\\/08\\\/before-q-k-and-v-reconstructing-the-transformer\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/futurenews24.com\\\/index.php\\\/2026\\\/08\\\/08\\\/before-q-k-and-v-reconstructing-the-transformer\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/towardsdatascience.com\\\/wp-content\\\/uploads\\\/2026\\\/08\\\/antonio-janeski-ANP0t4EGMBE-unsplash-scaled-1.jpg\",\"datePublished\":\"2026-08-08T15:00:00+00:00\",\"dateModified\":\"2026-08-08T22:59:10+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/futurenews24.com\\\/index.php\\\/2026\\\/08\\\/08\\\/before-q-k-and-v-reconstructing-the-transformer\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/futurenews24.com\\\/index.php\\\/2026\\\/08\\\/08\\\/before-q-k-and-v-reconstructing-the-transformer\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/futurenews24.com\\\/index.php\\\/2026\\\/08\\\/08\\\/before-q-k-and-v-reconstructing-the-transformer\\\/#primaryimage\",\"url\":\"https:\\\/\\\/towardsdatascience.com\\\/wp-content\\\/uploads\\\/2026\\\/08\\\/antonio-janeski-ANP0t4EGMBE-unsplash-scaled-1.jpg\",\"contentUrl\":\"https:\\\/\\\/towardsdatascience.com\\\/wp-content\\\/uploads\\\/2026\\\/08\\\/antonio-janeski-ANP0t4EGMBE-unsplash-scaled-1.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/futurenews24.com\\\/index.php\\\/2026\\\/08\\\/08\\\/before-q-k-and-v-reconstructing-the-transformer\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/futurenews24.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Earlier than Q, Okay, and V: Reconstructing the Transformer\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/futurenews24.com\\\/#website\",\"url\":\"https:\\\/\\\/futurenews24.com\\\/\",\"name\":\"Future News 24\",\"description\":\"The Smart Hub for AI and Next-Gen Innovation\",\"publisher\":{\"@id\":\"https:\\\/\\\/futurenews24.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/futurenews24.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/futurenews24.com\\\/#organization\",\"name\":\"Future News 24\",\"url\":\"https:\\\/\\\/futurenews24.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/futurenews24.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/futurenews24.com\\\/wp-content\\\/uploads\\\/2026\\\/06\\\/fn24-favicon.png\",\"contentUrl\":\"https:\\\/\\\/futurenews24.com\\\/wp-content\\\/uploads\\\/2026\\\/06\\\/fn24-favicon.png\",\"width\":250,\"height\":250,\"caption\":\"Future News 24\"},\"image\":{\"@id\":\"https:\\\/\\\/futurenews24.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/futurenews24.com\\\/#\\\/schema\\\/person\\\/cecad1bde21cfc357cf70128144d6c83\",\"name\":\"Future News 24\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d57f07142d73cb5503ab2446ea7bc9ef3d0a5ba378d64a6157692311e42bf097?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d57f07142d73cb5503ab2446ea7bc9ef3d0a5ba378d64a6157692311e42bf097?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d57f07142d73cb5503ab2446ea7bc9ef3d0a5ba378d64a6157692311e42bf097?s=96&d=mm&r=g\",\"caption\":\"Future News 24\"},\"sameAs\":[\"https:\\\/\\\/futurenews24.com\"],\"url\":\"https:\\\/\\\/futurenews24.com\\\/index.php\\\/author\\\/mridulpahuja20\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Earlier than Q, Okay, and V: Reconstructing the Transformer - Future News 24","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/","og_locale":"en_US","og_type":"article","og_title":"Earlier than Q, Okay, and V: Reconstructing the Transformer - Future News 24","og_description":"keys, queries, values, and dot product consideration? \u201cYou want keys and queries for tokens to speak to one another,\u201d says the favored Web analogy. However why? There\u2019s a variety of nice analogies for the way they work, however loads much less materials about why we actually want them. Are there any options or are these [&hellip;]","og_url":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/","og_site_name":"Future News 24","article_published_time":"2026-08-08T15:00:00+00:00","article_modified_time":"2026-08-08T22:59:10+00:00","og_image":[{"url":"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2026\/08\/antonio-janeski-ANP0t4EGMBE-unsplash-scaled-1.jpg","type":"","width":"","height":""}],"author":"Future News 24","twitter_card":"summary_large_image","twitter_image":"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2026\/08\/antonio-janeski-ANP0t4EGMBE-unsplash-scaled-1.jpg","twitter_misc":{"Written by":"Future News 24","Est. reading time":"30 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/#article","isPartOf":{"@id":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/"},"author":{"name":"Future News 24","@id":"https:\/\/futurenews24.com\/#\/schema\/person\/cecad1bde21cfc357cf70128144d6c83"},"headline":"Earlier than Q, Okay, and V: Reconstructing the Transformer","datePublished":"2026-08-08T15:00:00+00:00","dateModified":"2026-08-08T22:59:10+00:00","mainEntityOfPage":{"@id":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/"},"wordCount":6136,"commentCount":0,"publisher":{"@id":"https:\/\/futurenews24.com\/#organization"},"image":{"@id":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/#primaryimage"},"thumbnailUrl":"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2026\/08\/antonio-janeski-ANP0t4EGMBE-unsplash-scaled-1.jpg","keywords":["Reconstructing","Transformer"],"articleSection":["Data Science &amp; MLOps"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/","url":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/","name":"Earlier than Q, Okay, and V: Reconstructing the Transformer - Future News 24","isPartOf":{"@id":"https:\/\/futurenews24.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/#primaryimage"},"image":{"@id":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/#primaryimage"},"thumbnailUrl":"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2026\/08\/antonio-janeski-ANP0t4EGMBE-unsplash-scaled-1.jpg","datePublished":"2026-08-08T15:00:00+00:00","dateModified":"2026-08-08T22:59:10+00:00","breadcrumb":{"@id":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/#primaryimage","url":"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2026\/08\/antonio-janeski-ANP0t4EGMBE-unsplash-scaled-1.jpg","contentUrl":"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2026\/08\/antonio-janeski-ANP0t4EGMBE-unsplash-scaled-1.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/futurenews24.com\/index.php\/2026\/08\/08\/before-q-k-and-v-reconstructing-the-transformer\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/futurenews24.com\/"},{"@type":"ListItem","position":2,"name":"Earlier than Q, Okay, and V: Reconstructing the Transformer"}]},{"@type":"WebSite","@id":"https:\/\/futurenews24.com\/#website","url":"https:\/\/futurenews24.com\/","name":"Future News 24","description":"The Smart Hub for AI and Next-Gen Innovation","publisher":{"@id":"https:\/\/futurenews24.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/futurenews24.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/futurenews24.com\/#organization","name":"Future News 24","url":"https:\/\/futurenews24.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/futurenews24.com\/#\/schema\/logo\/image\/","url":"https:\/\/futurenews24.com\/wp-content\/uploads\/2026\/06\/fn24-favicon.png","contentUrl":"https:\/\/futurenews24.com\/wp-content\/uploads\/2026\/06\/fn24-favicon.png","width":250,"height":250,"caption":"Future News 24"},"image":{"@id":"https:\/\/futurenews24.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/futurenews24.com\/#\/schema\/person\/cecad1bde21cfc357cf70128144d6c83","name":"Future News 24","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d57f07142d73cb5503ab2446ea7bc9ef3d0a5ba378d64a6157692311e42bf097?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d57f07142d73cb5503ab2446ea7bc9ef3d0a5ba378d64a6157692311e42bf097?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d57f07142d73cb5503ab2446ea7bc9ef3d0a5ba378d64a6157692311e42bf097?s=96&d=mm&r=g","caption":"Future News 24"},"sameAs":["https:\/\/futurenews24.com"],"url":"https:\/\/futurenews24.com\/index.php\/author\/mridulpahuja20\/"}]}},"_links":{"self":[{"href":"https:\/\/futurenews24.com\/index.php\/wp-json\/wp\/v2\/posts\/3479","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/futurenews24.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/futurenews24.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/futurenews24.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/futurenews24.com\/index.php\/wp-json\/wp\/v2\/comments?post=3479"}],"version-history":[{"count":1,"href":"https:\/\/futurenews24.com\/index.php\/wp-json\/wp\/v2\/posts\/3479\/revisions"}],"predecessor-version":[{"id":3480,"href":"https:\/\/futurenews24.com\/index.php\/wp-json\/wp\/v2\/posts\/3479\/revisions\/3480"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/futurenews24.com\/index.php\/wp-json\/wp\/v2\/media\/3481"}],"wp:attachment":[{"href":"https:\/\/futurenews24.com\/index.php\/wp-json\/wp\/v2\/media?parent=3479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/futurenews24.com\/index.php\/wp-json\/wp\/v2\/categories?post=3479"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/futurenews24.com\/index.php\/wp-json\/wp\/v2\/tags?post=3479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}