Understanding Transformer Core by Hand
ProfTomYeh · x · 2026-07-17
What this is about
The author breaks down a Transformer block using a "hand-calculated" approach, aiming to let readers walk through the forward pass themselves to understand its internal structure.
Core Conclusions
- Attention weighting is responsible for mixing information across different positions, allowing a token to "see" the features of neighboring positions.
- FFN (Feed-Forward Network) is responsible for mixing feature dimensions within the same position.
- Together, these two parts constitute a complete Transformer block. The author emphasizes that other components (like positional encoding, multi-head, layer norm, skip connections, etc.) primarily enhance stability and scale, rather than being these two core computations themselves.
Demonstration Steps in the Article
- Provide input features for 5 positions.
- Generate the attention matrix via query-key.
- Apply attention weights to the input to get a representation mixed across positions.
- Feed it into the first layer of the FFN to expand the feature dimensions.
- Pass through ReLU to zero out negative values.
- Pass through the second layer to compress the dimensions back, and the output moves to the next layer.
Author's Takeaway
- Attention mixes information horizontally.
- FFN processes features vertically.
- The expressive power of the Transformer comes from the repeated stacking of these two mechanisms.
More from coding & agent
- An MCP server signs every AI agent tool call into a verifiable Merkle chain — Funky_Chicken_22 · 2026-07-22
- Claude Code skill uses 10 Markdown rules to make outputs ADHD-friendly — alex_verem · 2026-07-22
- A Firecracker-based platform says it can host 6,000 AI agents on one 256 GB server — maritime_sh · 2026-07-22
- A better path to agent autonomy is running waves, finding friction, and iterating — JnBrymn · 2026-07-22
- AI agent designers map the visual and tonal cues behind companionship products — Unlikely-Platform-47 · 2026-07-22
- Coding agents are heading toward an AI-writes, AI-reviews, human-approves workflow — aftahi_ai · 2026-07-22