<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Large Language Models on Bitsy Services Wiki</title>
    <link>https://wiki.bitsy.services/wiki/ai/llm/</link>
    <description>Recent content in Large Language Models on Bitsy Services Wiki</description>
    <generator>Hugo</generator>
    <language>en</language>
    <atom:link href="https://wiki.bitsy.services/wiki/ai/llm/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Conventions</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/conventions/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/conventions/</guid>
      <description>&lt;p&gt;Every diagram and sentence here uses one layout, declared once so no page has to re-orient you.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Depth runs left to right.&lt;/strong&gt; Embedding at the left edge, block 0 next, block 11 further right, unembedding at the right edge. A vector that has been through more blocks is &lt;em&gt;further right&lt;/em&gt;. Never &amp;ldquo;deeper,&amp;rdquo; never &amp;ldquo;up the stack.&amp;rdquo;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Sequence runs top to bottom.&lt;/strong&gt; One token position is one row: first token on top, the token you&amp;rsquo;re predicting from at the bottom.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;The feature axis is row width.&lt;/strong&gt; A row is &lt;code&gt;d_model&lt;/code&gt; numbers wide, and the only thing that changes that is the MLP bulge — which changes it straight back.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;div style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&#xA;&lt;table style=&#34;border-spacing:0;padding:0;margin:0;border:0;&#34;&gt;&lt;tr&gt;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;1&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;2&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;3&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;4&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;5&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;6&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;7&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;8&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;;width:100%&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                        depth  →&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  pos 0  &amp;#34;The&amp;#34;   [···········]──[···········]──▶ logits&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  pos 1  &amp;#34; cat&amp;#34;  [···········]──[···········]──▶ logits&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  pos 2  &amp;#34; sat&amp;#34;  [···········]──[···········]──▶ logits&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    │&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ▼             embed          block 0 … 11&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; sequence        └── d_model ──┘&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;h2 id=&#34;what-the-layout-buys-you&#34;&gt;What the layout buys you&lt;a class=&#34;anchor&#34; href=&#34;#what-the-layout-buys-you&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/attention&#34;&gt;Attention&lt;/a&gt; moves information &lt;em&gt;between rows&lt;/em&gt; — a row reads the rows above it. The MLP moves it &lt;em&gt;within a row&lt;/em&gt;, never looking at another. Here that&amp;rsquo;s literally vertical versus horizontal: the cleanest one-sentence account of a block you&amp;rsquo;ll get.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Glossary</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/glossary/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/glossary/</guid>
      <description>&lt;p&gt;The words this subsection uses — and it uses only these. Third column: what the same thing is called elsewhere, so you can translate when you leave.&lt;/p&gt;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;th&gt;Term&lt;/th&gt;&#xA;          &lt;th&gt;Means&lt;/th&gt;&#xA;          &lt;th&gt;Elsewhere called&lt;/th&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;row&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;one token position&amp;rsquo;s vector at some depth — &lt;code&gt;d_model&lt;/code&gt; numbers wide&lt;/td&gt;&#xA;          &lt;td&gt;activation, hidden state, token representation&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;&lt;code&gt;d_model&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;the row width. 768 in &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/gpt-2&#34;&gt;GPT-2 small&lt;/a&gt;, and fixed from embedding to unembedding&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;n_embd&lt;/code&gt;, hidden size, model dimension&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;residual stream&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;the row seen as a bus running rightward through every block: blocks add into it and never overwrite it&lt;/td&gt;&#xA;          &lt;td&gt;hidden state, skip path&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;block&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;one attention plus one MLP, each wrapped in a norm and a skip connection. GPT-2 small has 12&lt;/td&gt;&#xA;          &lt;td&gt;layer, transformer layer, decoder layer&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;MLP bulge&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;the MLP widening a row to 4×&lt;code&gt;d_model&lt;/code&gt; (3072) and back down. The only place a row isn&amp;rsquo;t &lt;code&gt;d_model&lt;/code&gt; wide&lt;/td&gt;&#xA;          &lt;td&gt;feed-forward, FFN, hidden dim&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;head&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;one attention channel: its own Q/K/V projections into a 64-wide subspace. 12 per block in GPT-2 small&lt;/td&gt;&#xA;          &lt;td&gt;attention head&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;attention pattern&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;one row&amp;rsquo;s post-softmax weights over the rows it can see. Sums to 1&lt;/td&gt;&#xA;          &lt;td&gt;attention weights, attention map&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;KV cache&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;keys and values already computed for earlier rows, kept so the next token doesn&amp;rsquo;t recompute them&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;past_key_values&lt;/code&gt;, decoder cache&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;logits&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;the raw scores at the right edge — one per vocabulary entry (50,257), before softmax&lt;/td&gt;&#xA;          &lt;td&gt;scores, unnormalized log-probs&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;unembedding&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;the matrix that turns the final row into logits. Tied to the embedding in GPT-2&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;lm_head&lt;/code&gt;, output head, &lt;code&gt;W_U&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;perplexity&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;exp(loss)&lt;/code&gt; — roughly, how many tokens the model is choosing between&lt;/td&gt;&#xA;          &lt;td&gt;PPL&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;feature&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;a direction in the stream that means something&lt;/td&gt;&#xA;          &lt;td&gt;concept, latent&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;h2 id=&#34;words-this-subsection-avoids&#34;&gt;Words this subsection avoids&lt;a class=&#34;anchor&#34; href=&#34;#words-this-subsection-avoids&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;&amp;ldquo;Layer&amp;rdquo;&lt;/strong&gt; — ambiguous between a block and a sublayer inside it. Say &lt;em&gt;block&lt;/em&gt;, &lt;em&gt;attention&lt;/em&gt;, or &lt;em&gt;MLP&lt;/em&gt;. (LayerNorm keeps its name; it&amp;rsquo;s a proper noun.)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&amp;ldquo;Deeper,&amp;rdquo; &amp;ldquo;up the stack&amp;rdquo;&lt;/strong&gt; — spatially wrong here; depth runs rightward. See &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/conventions&#34;&gt;conventions&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&amp;ldquo;Column&amp;rdquo;&lt;/strong&gt; — a row is never one, whatever shape the tensor is in memory.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;depends-on--leads-to&#34;&gt;Depends on / leads to&lt;a class=&#34;anchor&#34; href=&#34;#depends-on--leads-to&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Depends on &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/conventions&#34;&gt;conventions&lt;/a&gt;. Leads to every other page in the subsection.&lt;/p&gt;</description>
    </item>
    <item>
      <title>GPT-2</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/gpt-2/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/gpt-2/</guid>
      <description>&lt;p&gt;GPT-2 is the language model this section takes apart. OpenAI built it to test one idea — that a program trained only to guess the next piece of text, given enough ordinary writing to practise on, would pick up skills nobody set out to teach it — and it worked well enough to point the whole field in the direction it has been going ever since. It is also, by current standards, small and completely open: the weights are published, it runs on a laptop, and it is built the same way as the models people pay for today. Pivotal and openable at once is a rare combination, and it is why every page here uses GPT-2 as its worked example.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Tokenization</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/tokenization/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/tokenization/</guid>
      <description>&lt;p&gt;A model never sees text. It sees a list of integers, and the tokenizer is the only component that ever touched a character. &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/gpt-2&#34;&gt;GPT-2&lt;/a&gt;&amp;rsquo;s is byte-pair encoding: start from raw bytes, repeatedly merge the most frequent adjacent pair, keep the merge table. Encoding replays those merges in the order they were learned — not longest-match, which is the usual misreading. The vocabulary is what they produced: 50,000 merges plus the 256 raw bytes and an end-of-text marker, so 50,257 entries.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Embeddings</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/embeddings/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/embeddings/</guid>
      <description>&lt;p&gt;An embedding is where a token stops being an arbitrary label and becomes a position in a space the model has opinions about. Every entry in the vocabulary owns its own list of numbers, learned during training, and embedding a token means fetching its list — pulling one row out of a table. Nothing is calculated. This is the model&amp;rsquo;s first move, and it is the least clever thing it does all day.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The Residual Stream</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/residual-stream/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/residual-stream/</guid>
      <description>&lt;p&gt;Nothing in a transformer ever replaces a token&amp;rsquo;s vector. Each part of the model reads it, works something out, and adds the result on top of what&amp;rsquo;s already there. What comes out the far end is the starting vector plus every contribution made along the way — a running total. That total is the residual stream, and it is the only thing travelling through the model at all.&lt;/p&gt;&#xA;&lt;h2 id=&#34;why-a-sum-and-not-a-pipeline&#34;&gt;Why a sum, and not a pipeline&lt;a class=&#34;anchor&#34; href=&#34;#why-a-sum-and-not-a-pipeline&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Picture the obvious design first, because almost everyone does. Each stage takes the previous stage&amp;rsquo;s output, transforms it, and hands on a replacement — a relay race, one baton, passed along. That&amp;rsquo;s how a plain deep network works.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Attention</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/attention/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/attention/</guid>
      <description>&lt;p&gt;Attention is the part of a model that lets one word take account of another. Everything else in a transformer handles each position on its own: a word is processed without reference to its neighbours, as though it arrived alone. Attention is the exception, and it is the &lt;em&gt;only&lt;/em&gt; exception — the sole mechanism by which information moves between positions. Remove it and what&amp;rsquo;s left is a machine that reads every word in isolation and can never relate any of them.&lt;/p&gt;</description>
    </item>
    <item>
      <title>One Attention Head</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/one-attention-head/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/one-attention-head/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/attention&#34;&gt;Attention&lt;/a&gt; as an idea is a row asking the rows above it a question and blending the answers. This page is that idea as arithmetic. One &lt;strong&gt;head&lt;/strong&gt; is a single complete instance of the machinery — a block runs &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/multi-head-attention&#34;&gt;twelve of them side by side&lt;/a&gt;, but one shows the entire operation.&lt;/p&gt;&#xA;&lt;p&gt;Here it is, from a single row&amp;rsquo;s point of view. The row emits a &lt;strong&gt;query&lt;/strong&gt;: what am I looking for? Every row at or above it exposes a &lt;strong&gt;key&lt;/strong&gt;: what I&amp;rsquo;ve got. Dot the query against each key and you get a score per row — how much this row wants that one. Softmax those scores into an &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/glossary&#34;&gt;attention pattern&lt;/a&gt;: weights that sum to 1 across the rows it&amp;rsquo;s allowed to see. Then take those rows&amp;rsquo; &lt;strong&gt;value&lt;/strong&gt; vectors, weight them by the pattern, sum, and map the result back to &lt;code&gt;d_model&lt;/code&gt;. That&amp;rsquo;s what the head adds to the row&amp;rsquo;s &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/residual-stream&#34;&gt;residual stream&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Q/K/V as Three Projections</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/qkv-projections/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/qkv-projections/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/attention&#34;&gt;Attention&lt;/a&gt; talks about a row&amp;rsquo;s query, its key, and its value as though the row were carrying three things around with it. It isn&amp;rsquo;t. There is only the row. Query, key, and value are three different ways of &lt;em&gt;reading&lt;/em&gt; it — three learned lenses, each trained to pull a different aspect out of the same numbers. Nothing is stored. All three are worked out from the row on the spot, every time attention runs.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The Causal Mask</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/causal-mask/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/causal-mask/</guid>
      <description>&lt;p&gt;A row may not read the rows below it. Before the softmax, every score pointing at a row further down the sequence is set to −∞, so its weight comes out exactly 0. That&amp;rsquo;s the mechanism: a triangle of −∞ added to the score matrix.&lt;/p&gt;&#xA;&lt;p&gt;The reason is training. One forward pass over a 1024-token sequence makes a prediction at every row — 1023 of which have a next token to score against. If row 5 could see row 6, the answer to &amp;ldquo;what follows row 5?&amp;rdquo; would be sitting in the input, the loss would go to zero, and the model would learn nothing. The mask is what makes training on every position at once honest.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Multi-Head Attention</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/multi-head-attention/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/multi-head-attention/</guid>
      <description>&lt;p&gt;One head is a narrow channel: a 64-wide query chasing one kind of relationship. &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/gpt-2&#34;&gt;GPT-2 small&lt;/a&gt; runs &lt;strong&gt;12 of them per block, in parallel, over the same row&lt;/strong&gt;, and they never talk to each other.&lt;/p&gt;&#xA;&lt;p&gt;The row doesn&amp;rsquo;t get wider. &lt;code&gt;d_model&lt;/code&gt; is split, not multiplied: 12 heads × 64 = 768. Each head reads the full row through its own &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/qkv-projections&#34;&gt;Q/K/V projections&lt;/a&gt;, produces its own 64-wide result, and the twelve results are concatenated back to 768, passed through one output matrix, and added to the stream as a single write. Twelve independent reads, one write.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The MLP</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/the-mlp/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/the-mlp/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/attention&#34;&gt;Attention&lt;/a&gt; moves information between rows. The MLP is what the block does &lt;em&gt;to&lt;/em&gt; a row once it has what it needs — and it never looks at another row.&lt;/p&gt;&#xA;&lt;p&gt;Mechanically it&amp;rsquo;s two matrices with a nonlinearity between them: 768 → 3072, &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/activations&#34;&gt;GELU&lt;/a&gt;, 3072 → 768. That widening is the &lt;strong&gt;MLP bulge&lt;/strong&gt;, the only place in the model where a row isn&amp;rsquo;t &lt;code&gt;d_model&lt;/code&gt; wide. Nothing mixes across rows on the way through; each row goes in and comes back alone.&lt;/p&gt;</description>
    </item>
    <item>
      <title>GELU and SwiGLU</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/activations/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/activations/</guid>
      <description>&lt;p&gt;Almost everything a transformer does to a row is, arithmetically, a straight line: multiply by a matrix, add a vector, multiply by another matrix. Straight lines have an inconvenient property — chain as many as you like and the result is just another straight line. A model built only from them would be no more capable with a hundred blocks than with one, however many parameters you poured in. The activation function is the small bend in the middle of the MLP that breaks the straightness, and it is the reason depth buys anything at all. GPT-2 bends with GELU; nearly everything since bends with SwiGLU.&lt;/p&gt;</description>
    </item>
    <item>
      <title>LayerNorm and RMSNorm</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/normalization/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/normalization/</guid>
      <description>&lt;p&gt;Before &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/attention&#34;&gt;attention&lt;/a&gt; or the MLP reads the row, the row is normalized: subtract the mean of its 768 numbers, divide by their standard deviation, then scale and shift by learned per-feature parameters. That&amp;rsquo;s LayerNorm. It works &lt;em&gt;within a row&lt;/em&gt;, along the feature axis — never across rows, so it can&amp;rsquo;t leak anything between token positions. (The name is historical; it normalizes a row, not a &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/glossary&#34;&gt;block&lt;/a&gt;.)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/gpt-2&#34;&gt;GPT-2&lt;/a&gt; is &lt;strong&gt;pre-norm&lt;/strong&gt;: &lt;code&gt;row = row + attention(norm(row))&lt;/code&gt;. Read that placement carefully. The norm applies to the copy attention reads. It does not apply to the stream. The &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/residual-stream&#34;&gt;residual stream&lt;/a&gt; is never normalized in place — it keeps whatever magnitude it has accumulated, and it grows rightward, hard. In GPT-2 small the last row&amp;rsquo;s norm runs from about 5 at the embedding to about 400 leaving block 11: a factor of a hundred. Exactly once, at the right edge, a final norm rescales it before the unembedding reads it.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Skip Connections</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/skip-connections/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/skip-connections/</guid>
      <description>&lt;p&gt;The &lt;code&gt;+&lt;/code&gt; in &lt;code&gt;row = row + attention(norm(row))&lt;/code&gt; is the skip connection, and it&amp;rsquo;s the reason the &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/residual-stream&#34;&gt;residual stream&lt;/a&gt; exists. The stream &lt;em&gt;is&lt;/em&gt; the accumulated skip path.&lt;/p&gt;&#xA;&lt;p&gt;It does two jobs.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;It makes &amp;ldquo;do nothing&amp;rdquo; the default.&lt;/strong&gt; A block whose attention and MLP output zeros is the identity, so a new block starts out harmless and learns a correction instead of having to earn back what its predecessors built. That is the argument for the &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/residual-stream&#34;&gt;residual stream&lt;/a&gt; and it&amp;rsquo;s made there; the &lt;code&gt;+&lt;/code&gt; is simply the thing that does it.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The Unembedding and Logits</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/unembedding-and-logits/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/unembedding-and-logits/</guid>
      <description>&lt;p&gt;The final row is 768 numbers. The vocabulary has 50,257 entries. The unembedding closes that gap with a single matrix multiply and nothing else.&lt;/p&gt;&#xA;&lt;p&gt;After the final norm, the row is dotted against one vector per vocabulary entry. The score for token &lt;em&gt;t&lt;/em&gt; is &lt;code&gt;dot(row, W_U[t])&lt;/code&gt; — literally: how much does this row point in token &lt;em&gt;t&lt;/em&gt;&amp;rsquo;s direction? Those 50,257 scores are the &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/glossary&#34;&gt;logits&lt;/a&gt;. No search, no nonlinearity, no table of stored continuations. The model&amp;rsquo;s answer is one vector, and the vocabulary is a set of directions to compare it against — direction picks the winner, magnitude decides how confident the logits look.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Softmax and Temperature</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/softmax-and-temperature/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/softmax-and-temperature/</guid>
      <description>&lt;p&gt;Logits are scores: unbounded, signed, meaningless alone. Softmax turns them into probabilities — exponentiate, normalize — with a temperature knob in the middle:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;div style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&#xA;&lt;table style=&#34;border-spacing:0;padding:0;margin:0;border:0;&#34;&gt;&lt;tr&gt;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;1&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;;width:100%&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;p_i = exp(z_i / T) / Σ_j exp(z_j / T)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;p&gt;Two properties are worth knowing cold.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Only differences matter.&lt;/strong&gt; Add a constant to every logit and nothing changes; the constant cancels top and bottom. A logit&amp;rsquo;s absolute value tells you nothing. The &lt;em&gt;gap&lt;/em&gt; to the next logit tells you everything.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Sampling Strategies</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/sampling-strategies/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/sampling-strategies/</guid>
      <description>&lt;p&gt;Softmax hands you a distribution over 50,257 tokens. Sampling turns it into one token — the only real choice you get at inference, and the one most likely to be blamed on the model.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Greedy&lt;/strong&gt; takes the argmax. Deterministic, and it degenerates: fluent text that falls into loops, because the most likely continuation of a phrase you&amp;rsquo;ve just said is often to say it again.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Pure sampling&lt;/strong&gt; draws from the whole distribution. It never loops, and it wanders, because the tail is enormous. After &amp;ldquo;the cat sat on the,&amp;rdquo; the ~49,500 tokens below p = 0.0001 carry more probability between them (0.10) than the single best token does (0.08). Sample long enough and you &lt;em&gt;will&lt;/em&gt; pick from the garbage.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The Loss Function</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/the-loss-function/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/the-loss-function/</guid>
      <description>&lt;p&gt;One number trains the entire model: the negative log-probability the model assigned to the token that actually came next, averaged over every row.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;div style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&#xA;&lt;table style=&#34;border-spacing:0;padding:0;margin:0;border:0;&#34;&gt;&lt;tr&gt;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;1&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;;width:100%&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;loss = −(1/n) Σ log p(actual next token | rows above)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;p&gt;That&amp;rsquo;s cross-entropy, and it&amp;rsquo;s the &lt;em&gt;only&lt;/em&gt; signal. Nobody tells the model what a verb is, that Paris is in France, or which of two continuations reads better. It&amp;rsquo;s told, at each of a trillion positions, how much probability it put on the token that turned up.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Perplexity</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/perplexity/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/perplexity/</guid>
      <description>&lt;p&gt;Perplexity is the standard single number for how good a language model is at its one core job: predicting the next token. It restates the model&amp;rsquo;s average surprise as an effective number of choices — how many equally-likely options the model is, in effect, deciding between at each step. Fewer is better; a model that always knew exactly what came next would have nothing left to choose between. It&amp;rsquo;s the figure papers quote to claim one model fits a body of text better than another, though the same model scores differently depending only on how that text was cut into tokens — a caveat that turns out to be most of the story of reading the number honestly.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Backprop Through One Weight</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/backprop-one-weight/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/backprop-one-weight/</guid>
      <description>&lt;p&gt;Pick one number out of &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/gpt-2&#34;&gt;GPT-2 small&lt;/a&gt;&amp;rsquo;s 124 million — a single entry &lt;code&gt;w&lt;/code&gt; in block 6&amp;rsquo;s MLP input matrix. Backprop answers exactly one question about it: &lt;em&gt;if I nudge &lt;code&gt;w&lt;/code&gt; up a hair, does the loss go up or down, and how fast?&lt;/em&gt; That&amp;rsquo;s &lt;code&gt;∂L/∂w&lt;/code&gt;. Training is that answer, applied to every weight, a few hundred thousand times.&lt;/p&gt;&#xA;&lt;p&gt;The chain rule gets it there in one sweep. The &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/the-loss-function&#34;&gt;loss&lt;/a&gt; is computed at the right edge; its gradient flows right to left, and at each operation the gradient arriving from the right is multiplied by that operation&amp;rsquo;s local derivative. By the time it reaches &lt;code&gt;w&lt;/code&gt;, the number is a &lt;strong&gt;sum over every path&lt;/strong&gt; from &lt;code&gt;w&lt;/code&gt; to the loss — through the &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/skip-connections&#34;&gt;skip connections&lt;/a&gt;, through every block to its right — each path a product of local derivatives. It&amp;rsquo;s a sum, not a product. Think &amp;ldquo;product&amp;rdquo; and you&amp;rsquo;ve reinvented the vanishing gradient that skips exist to prevent.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Weight Sharing Across Positions</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/weight-sharing/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/weight-sharing/</guid>
      <description>&lt;p&gt;There is no &amp;ldquo;block 6 for position 300.&amp;rdquo; Every row runs through the &lt;em&gt;same&lt;/em&gt; weights: one set of Q/K/V matrices, one MLP, per block, applied identically at position 1 and position 900.&lt;/p&gt;&#xA;&lt;p&gt;This isn&amp;rsquo;t a memory optimization. It&amp;rsquo;s what makes the thing a language model instead of a lookup table indexed by position. Whatever &amp;ldquo;attend to the subject of this clause&amp;rdquo; costs to learn, it&amp;rsquo;s learned once and works everywhere — and gradients from every position in every sequence pile into the same matrices, which is why &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/backprop-one-weight&#34;&gt;one sequence teaches a weight a thousand times over&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The KV Cache</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/kv-cache/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/kv-cache/</guid>
      <description>&lt;p&gt;Generating token 500 means running a forward pass over 499 rows to produce one new row. Do that naively for every token and you rebuild the entire prefix each time — the same keys and values, from the same unchanged rows, again and again.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/causal-mask&#34;&gt;The causal mask&lt;/a&gt; says you don&amp;rsquo;t have to. A row can only depend on itself and the rows above it, so once a row is computed it&amp;rsquo;s final: nothing you append below can change it, and its key and value are constants. Keep them.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Grouped-Query Attention</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/grouped-query-attention/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/grouped-query-attention/</guid>
      <description>&lt;p&gt;When a model is served to real users, the thing that fills the graphics card is not always the model. It&amp;rsquo;s the pile of remembered arithmetic kept for every token of every conversation in flight — and &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/multi-head-attention&#34;&gt;multi-head attention&lt;/a&gt; makes that pile as large as it can possibly be, by giving every head its own private copy. Grouped-query attention is the observation that they don&amp;rsquo;t all need one. Put the heads in groups, let a group share, and most of the memory goes away while the model carries on asking just as many questions as before. It costs a little quality, and it is why essentially every model served at scale today is built this way.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Positional Encoding</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/positional-encoding/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/positional-encoding/</guid>
      <description>&lt;p&gt;A query dotted with a key doesn&amp;rsquo;t know where either row sits. &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/attention&#34;&gt;Attention&lt;/a&gt;, by itself, is a bag of rows. Position has to be injected on purpose.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/gpt-2&#34;&gt;GPT-2&lt;/a&gt; injects it once, at the left edge. It learns a vector per position — &lt;code&gt;wpe&lt;/code&gt;, one row per slot — and &lt;em&gt;adds&lt;/em&gt; it to the &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/embeddings&#34;&gt;embedding&lt;/a&gt; before block 0 sees anything. Same width, added rather than concatenated, so position costs the row no capacity; it just perturbs it. Every block and every head downstream reads position out of a signal mixed into the row&amp;rsquo;s content at the start.&lt;/p&gt;</description>
    </item>
    <item>
      <title>RoPE</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/rope/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/rope/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/one-attention-head&#34;&gt;Attention scores a query against a key&lt;/a&gt; with a dot product, and a dot product has no idea where either token sits in the sequence. Order has to be put in on purpose. Rotary position embedding (RoPE) puts it in as &lt;em&gt;rotation&lt;/em&gt; — and does it so that the score between two tokens depends only on the distance between them.&lt;/p&gt;&#xA;&lt;h2 id=&#34;position-is-invisible-to-a-dot-product&#34;&gt;Position is invisible to a dot product&lt;a class=&#34;anchor&#34; href=&#34;#position-is-invisible-to-a-dot-product&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Attention works by dotting a query row against a key row: a large dot product means &amp;ldquo;this token is relevant to that one.&amp;rdquo; But the dot product looks only at the &lt;em&gt;contents&lt;/em&gt; of the two vectors. It cannot tell whether the key is the token right before the query or five hundred tokens back. Swap two rows of the sequence and every attention score comes out identical. Order isn&amp;rsquo;t in the arithmetic, so it has to be injected — which is the job of &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/positional-encoding&#34;&gt;positional encoding&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Training vs Inference Parallelism</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/training-vs-inference-parallelism/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/training-vs-inference-parallelism/</guid>
      <description>&lt;p&gt;The same weights, run two completely different ways.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Training does every row at once.&lt;/strong&gt; One forward pass over 1024 tokens computes all 1024 rows in parallel and scores 1023 next-token predictions — &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/causal-mask&#34;&gt;the causal mask&lt;/a&gt; is what makes that legal. The GPU is doing enormous matmuls, it&amp;rsquo;s compute-bound, and that&amp;rsquo;s why training is a throughput problem you solve with more FLOPs.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Inference can&amp;rsquo;t.&lt;/strong&gt; Token 501 depends on token 500, which you have to sample first. Generation is strictly serial: one row, one forward pass, repeat. And with a &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/kv-cache&#34;&gt;KV cache&lt;/a&gt; the arithmetic per row is trivial — you push a single 768-wide row through 124M weights and get about one multiply out of each. Every weight is read; none is &lt;em&gt;reused&lt;/em&gt;. The parallel pass reads exactly the same weights and reuses each one a thousand times over. That difference — arithmetic intensity, not FLOPs — is what makes decode memory-bandwidth-bound.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Context Length and the O(n²) Cost</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/context-length/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/context-length/</guid>
      <description>&lt;p&gt;Every row scores every row it can see: an n × n matrix of scores, per head, per block — the only thing in a transformer that grows quadratically with the sequence.&lt;/p&gt;&#xA;&lt;p&gt;Everything else is linear: projections, MLP, and norms chew one row at a time, so doubling the context doubles their work. &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/attention&#34;&gt;Attention&lt;/a&gt;&amp;rsquo;s score matrix and its weighted sum &lt;em&gt;quadruple&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So the famous O(n²) is a &lt;strong&gt;crossover&lt;/strong&gt;, not a flat tax. Per block the quadratic part costs about &lt;code&gt;4n²·d_model&lt;/code&gt; (the full n × n; a good kernel skips the masked half and pays half that), the linear part — projections plus MLP — about &lt;code&gt;24n·d_model²&lt;/code&gt;. Equal at &lt;code&gt;n ≈ 6·d_model&lt;/code&gt;: ~4,600 tokens for &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/gpt-2&#34;&gt;GPT-2 small&lt;/a&gt;, ~9,200 causal-only. Below that the MLP dominates; above it, attention &lt;em&gt;is&lt;/em&gt; the bill. Nobody worried about this in 2019 with a 1024-token window; everybody does now.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Mixture of Experts</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/mixture-of-experts/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/mixture-of-experts/</guid>
      <description>&lt;p&gt;Replace the single MLP in a block with N of them — &amp;ldquo;experts&amp;rdquo; — plus a small router. The router scores the row, picks the top one or two, and only those run. Attention is untouched; MoE is a story about &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/the-mlp&#34;&gt;the MLP&lt;/a&gt; and nothing else.&lt;/p&gt;&#xA;&lt;p&gt;The trade is parameters for FLOPs, and it&amp;rsquo;s a good one. Eight experts give a block eight times the MLP weights, but each row still runs through only one or two of them, so compute per token barely moves. Mixtral: 46.7B parameters total, 12.9B active per token — a &lt;em&gt;top-2&lt;/em&gt; number. Route to one expert and only ~7B would be active, at half the MLP FLOPs. You&amp;rsquo;re buying capacity — more places to put what the model knows — without buying much latency.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Superposition</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/superposition/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/superposition/</guid>
      <description>&lt;p&gt;A model keeps track of far more things than it has room for. Superposition is how it gets away with it: rather than giving every concept its own private slot, it overlaps them, cramming many more into the space than the space can strictly hold and accepting a little interference as the price. It works because on any given word almost none of those concepts are actually in play, so the collisions mostly don&amp;rsquo;t happen at the same time.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Fine-Tuning</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/fine-tuning/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/fine-tuning/</guid>
      <description>&lt;p&gt;Same architecture, same weights, more training — on your data, at a small learning rate. Nothing structural changes. Every virtue and every failure of fine-tuning follows from that.&lt;/p&gt;&#xA;&lt;p&gt;What it&amp;rsquo;s good at is &lt;strong&gt;behaviour&lt;/strong&gt;: format, tone, refusal style, the input-output shape of a task. Those are cheap to move, because the model already has the &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/superposition&#34;&gt;features&lt;/a&gt; and you&amp;rsquo;re only adjusting how it uses them.&lt;/p&gt;&#xA;&lt;p&gt;What it&amp;rsquo;s bad at is &lt;strong&gt;facts&lt;/strong&gt;. Teaching the model something it doesn&amp;rsquo;t know means shifting weights far enough to store new information, and the same gradient steps quietly degrade everything else — catastrophic forgetting. The rule of thumb that follows: if you want the model to &lt;em&gt;know&lt;/em&gt; your documents, put them in the context; if you want it to &lt;em&gt;behave&lt;/em&gt; a certain way, fine-tune.&lt;/p&gt;</description>
    </item>
    <item>
      <title>RLHF</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/rlhf/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/rlhf/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/the-loss-function&#34;&gt;Cross-entropy&lt;/a&gt; trains a model to predict what a human &lt;em&gt;would&lt;/em&gt; write. It has no way to say that one plausible continuation is better than another. RLHF is the machinery for training on that preference instead.&lt;/p&gt;&#xA;&lt;p&gt;Three steps, classically. Supervised fine-tune on demonstrations. Then collect &lt;strong&gt;comparisons&lt;/strong&gt; — a human sees two completions and picks one — and train a &lt;strong&gt;reward model&lt;/strong&gt;: a copy of the language model with the unembedding swapped for a scalar head, trained so preferred completions score higher. Then optimize the policy against that reward with PPO, plus a &lt;strong&gt;KL penalty&lt;/strong&gt; pinning it to the model it started from.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Speculative Decoding</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/speculative-decoding/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/speculative-decoding/</guid>
      <description>&lt;p&gt;Decoding is serial: each token depends on the last. &lt;em&gt;Verifying&lt;/em&gt; isn&amp;rsquo;t. That asymmetry is the whole trick.&lt;/p&gt;&#xA;&lt;p&gt;A small &lt;strong&gt;draft&lt;/strong&gt; model generates k tokens (four, say) one at a time — but it&amp;rsquo;s small, so slow is cheap. The big &lt;strong&gt;target&lt;/strong&gt; model then scores all k in a &lt;em&gt;single&lt;/em&gt; forward pass, which it can do because &lt;a href=&#34;https://wiki.bitsy.services/wiki/ai/llm/training-vs-inference-parallelism&#34;&gt;that&amp;rsquo;s how training already works&lt;/a&gt;: one pass over a sequence yields a next-token distribution at every row at once. Compare the target&amp;rsquo;s distribution at each row against the draft&amp;rsquo;s, accept the longest prefix that survives a rejection-sampling test, resample the first rejected token from a corrected distribution, discard the rest.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Why Scale Worked</title>
      <link>https://wiki.bitsy.services/wiki/ai/llm/why-scale-worked/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/ai/llm/why-scale-worked/</guid>
      <description>&lt;p&gt;Modern language models are not good because someone discovered a smarter way to read a sentence. They are good because someone discovered a way to train on far more writing than anyone had trained on before — and it turned out that more writing was what the problem had been short of all along. The insight everyone quotes is attention. The insight that did the work is duller: this design can turn a bigger budget into more text read, and the design it replaced could not. This page argues the second one is load-bearing and the first is mostly a means to it.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
