<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Transformers on Programmer.ie: Modern AI programming</title>
    <link>http://programmer.ie/tags/transformers/</link>
    <description>Recent content in Transformers on Programmer.ie: Modern AI programming</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 08 Aug 2026 14:03:00 +0100</lastBuildDate>
    <atom:link href="http://programmer.ie/tags/transformers/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>PyTorch Zero to Hero 10: Build a Small GPT-Style Language Model From Scratch</title>
      <link>http://programmer.ie/post/pytorch-zero-to-hero-10/</link>
      <pubDate>Sat, 08 Aug 2026 14:03:00 +0100</pubDate>
      <guid>http://programmer.ie/post/pytorch-zero-to-hero-10/</guid>
      <description>&lt;h1 id=&#34;build-a-small-gpt-style-language-model-from-scratch-in-pytorch&#34;&gt;Build a Small GPT-Style Language Model From Scratch in PyTorch&lt;/h1&gt;&#xA;&lt;p&gt;This is the final post in the &lt;strong&gt;PyTorch: Zero to Hero&lt;/strong&gt; series.&lt;/p&gt;&#xA;&lt;p&gt;We have spent the previous posts learning the machinery underneath PyTorch:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;tensors and shapes;&lt;/li&gt;&#xA;&lt;li&gt;autograd;&lt;/li&gt;&#xA;&lt;li&gt;manual neural networks;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nn.Module&lt;/code&gt; and parameter registration;&lt;/li&gt;&#xA;&lt;li&gt;DataLoader performance;&lt;/li&gt;&#xA;&lt;li&gt;convolutional networks;&lt;/li&gt;&#xA;&lt;li&gt;attention and masks;&lt;/li&gt;&#xA;&lt;li&gt;training failures;&lt;/li&gt;&#xA;&lt;li&gt;CUDA performance and &lt;code&gt;torch.compile&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now we put it together.&lt;/p&gt;&#xA;&lt;p&gt;The goal is not to download a pretrained model.&lt;/p&gt;</description>
    </item>
    <item>
      <title>PyTorch Attention Shapes: Q, K, V, Multi-Head Attention Masks and Transformer Dimension Errors</title>
      <link>http://programmer.ie/post/pytorch-zero-to-hero-07/</link>
      <pubDate>Sat, 08 Aug 2026 13:30:00 +0100</pubDate>
      <guid>http://programmer.ie/post/pytorch-zero-to-hero-07/</guid>
      <description>&lt;h2 id=&#34;pytorch-zero-to-hero--step-07&#34;&gt;PyTorch: Zero to Hero — Step 07&lt;/h2&gt;&#xA;&lt;p&gt;Attention code is where tensor-shape mistakes stop being annoying and start becoming architectural.&lt;/p&gt;&#xA;&lt;p&gt;A CNN usually makes its dimensional assumptions fairly obvious. Attention does not.&lt;/p&gt;&#xA;&lt;p&gt;A tensor that starts as:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&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;(batch, sequence, embedding)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;is projected into Q, K and V, split into heads, transposed, multiplied, masked, normalized, multiplied again, transposed again, concatenated and projected back to the embedding dimension.&lt;/p&gt;&#xA;&lt;p&gt;A single bad &lt;code&gt;view&lt;/code&gt;, &lt;code&gt;transpose&lt;/code&gt;, mask shape or head calculation can produce anything from an immediate runtime error to a model that trains while attending to the wrong tokens.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
