<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Transformers on Sanketh's Blog</title><link>https://sankethbk.github.io/blog/tags/transformers/</link><description>Recent content in Transformers on Sanketh's Blog</description><generator>Hugo -- 0.166.0</generator><language>en-us</language><lastBuildDate>Sun, 20 Sep 2026 00:00:00 +0530</lastBuildDate><atom:link href="https://sankethbk.github.io/blog/tags/transformers/index.xml" rel="self" type="application/rss+xml"/><item><title>Attention: Turning Token Vectors into Context Vectors</title><link>https://sankethbk.github.io/blog/posts/ml/2026-09-20-1-attention-turning-token-vectors-into-context/</link><pubDate>Sun, 20 Sep 2026 00:00:00 +0530</pubDate><guid>https://sankethbk.github.io/blog/posts/ml/2026-09-20-1-attention-turning-token-vectors-into-context/</guid><description>&lt;h1 id="attention-turning-token-vectors-into-context-vectors"&gt;Attention: Turning Token Vectors into Context Vectors&lt;/h1&gt;
&lt;p&gt;The &lt;a href="https://sankethbk.github.io/blog/posts/ml/2026-09-14-4-embeddings-from-one-hot-to-learned-representations"&gt;embeddings note&lt;/a&gt; ended with an honest limitation: a token&amp;rsquo;s embedding is one fixed row of a learned matrix. The word &amp;ldquo;bank&amp;rdquo; gets the same vector in &amp;ldquo;river bank&amp;rdquo; and &amp;ldquo;investment bank&amp;rdquo;. Everything the model can possibly know about &amp;ldquo;bank itself&amp;rdquo; is frozen into that row at training time.&lt;/p&gt;
&lt;p&gt;But meaning is contextual. When a model processes a sentence, what it needs at the position of &amp;ldquo;bank&amp;rdquo; is not &amp;ldquo;the generic bank vector&amp;rdquo; but &amp;ldquo;the vector of bank &lt;em&gt;as it appears in this sentence&lt;/em&gt;&amp;rdquo;. Attention is the mechanism that builds that second thing from the first.&lt;/p&gt;</description></item><item><title>The Transformer Block: Multi-Head Attention, Residuals, Norms, and Position</title><link>https://sankethbk.github.io/blog/posts/ml/2026-09-20-2-the-transformer-block/</link><pubDate>Sun, 20 Sep 2026 00:00:00 +0530</pubDate><guid>https://sankethbk.github.io/blog/posts/ml/2026-09-20-2-the-transformer-block/</guid><description>&lt;h1 id="the-transformer-block-multi-head-attention-residuals-norms-and-position"&gt;The Transformer Block: Multi-Head Attention, Residuals, Norms, and Position&lt;/h1&gt;
&lt;p&gt;The &lt;a href="https://sankethbk.github.io/blog/posts/ml/2026-09-20-1-attention-turning-token-vectors-into-context"&gt;attention note&lt;/a&gt; derived the single mechanism — softmax over query-key scores, times values — and ended with its two obvious weaknesses: one head can track only &lt;em&gt;one&lt;/em&gt; relevance pattern at a time, and the whole operation is blind to token order.&lt;/p&gt;
&lt;p&gt;This note turns attention into the actual Transformer block. The block is attention plus four supporting acts — multi-head projection, a residual connection, layer normalization, and a small feedforward network — and then positional encoding bolted onto the input. None of them are exotic. Each one exists to patch a specific failure of the bare mechanism, and by the end you should be able to name the patch for each failure.&lt;/p&gt;</description></item><item><title>Training a Language Model End to End: From Text to Loss to Generation</title><link>https://sankethbk.github.io/blog/posts/ml/2026-09-20-3-training-a-language-model-end-to-end/</link><pubDate>Sun, 20 Sep 2026 00:00:00 +0530</pubDate><guid>https://sankethbk.github.io/blog/posts/ml/2026-09-20-3-training-a-language-model-end-to-end/</guid><description>&lt;h1 id="training-a-language-model-end-to-end-from-text-to-loss-to-generation"&gt;Training a Language Model End to End: From Text to Loss to Generation&lt;/h1&gt;
&lt;p&gt;We now have every moving part: token → embedding (the lookup note), tokens mix via masked multi-head attention (previous two notes), blocks stack, and the whole thing is just a computation graph built from matrix multiplies and softmax — the exact family the general
$L$
-layer loop handles.&lt;/p&gt;
&lt;p&gt;What remains is boring-sounding but is actually the point of the whole series: &lt;strong&gt;how does a stack of transformer blocks become a language model that predicts text?&lt;/strong&gt; The answer has four pieces: a final linear layer to vocabulary-sized logits, cross-entropy per position against the next token, teacher forcing during training, and autoregressive sampling at inference. The pieces are individually simple; seeing them end-to-end is what makes &amp;ldquo;GPT&amp;rdquo; stop being magical.&lt;/p&gt;</description></item></channel></rss>