Skip to content
AI & Machine Learning Rich #transformer#block#mlp

Transformer Block

Attention, residual, norm, MLP, residual, norm. The unit that stacks 100+ deep.

A free, animated transformer block you can read here or embed on any website, from Scrollchart.

Transformer Block

Transformer Block (Pre-Norm)

A pre-norm transformer block: input -> LN -> multi-head attention -> + residual -> LN -> MLP (up-proj, GELU/SiLU, down-proj) -> + residual -> output. Pre-norm vs post-norm variants compared on training stability. Shapes annotated at every edge for d_model=4096, n_heads=32.

Good for

  • Architecture explainers
  • GPT/Llama internals
  • Course material on transformers

Source & accuracy

This transformer block is an editorial illustration built to represent the concept accurately. Where it shows figures, they are typical or representative values chosen to make the relationship clear, not a single underlying dataset. The diagram and its explainer are reviewed and maintained centrally, and updated over time as understanding improves.

The repeating unit of deep transformers

A transformer block (or transformer layer) is a reusable module that stacks multi-head attention, normalization, and a feedforward network (MLP). The block receives token embeddings, applies attention to mix information across all tokens, applies residual connections to preserve identity, normalizes, passes through a two-layer MLP with an activation function, and outputs refined embeddings. This same block repeats dozens or hundreds of times, creating the depth that gives transformers their power.

Residual connections and normalization enable deep stacking

Modern transformer blocks use residual connections (skip connections) after both the attention and MLP sublayers, allowing gradients to flow directly through layers during backpropagation. Layer normalization before each sublayer (or after, in some architectures) stabilizes training and prevents activation distributions from drifting. These two techniques work together to make it feasible to train models 50+ layers deep without gradient vanishing or exploding, which would be impossible without them.

The MLP component typically expands the hidden dimension by a factor of 4 during the first sublayer, then projects back down. This expansion-projection pattern increases model capacity within each block while maintaining manageable overall complexity.

Embed this diagram

Add this animated transformer block to your own site. Copy one line of HTML, or use the embed builder for theme and sizing options.

Reference

What this is
A free, embeddable, animated transformer block for any website.
Who uses it
AI/ML blogs, CS educators.
How to embed
Copy one line of HTML. No signup. No watermark. Works in WordPress, Webflow, Ghost, Substack, plain HTML.
File size
iframe embed, ~80 KB gzipped (loads on demand, does not block your page paint).
License
Free forever. Editorial explainer text included; updated centrally over time.

Embed format options

Copy the universal HTML snippet, the WordPress shortcode, or an iframe fallback - see the WordPress plugin page for details. Any format keeps the same Core Web Vitals profile and the same explainer text.

Embed snippet
<div data-scrollchart="transformer-block" data-scrollchart-v="1"></div>
<script src="https://scrollchart.com/embed.js" async></script>

Frequently asked questions

Where can I get a free animated "Transformer Block" for my website?
Scrollchart provides "Transformer Block" as a free, embeddable animated diagram you can add to any website with one line of HTML. No signup is required and there is no watermark. The diagram and its explainer text are served from scrollchart.com, so the embed stays current without any maintenance on your end.
How do I embed a transformer block in a developer or tech blog?
Copy the one-line snippet from the Scrollchart diagram page and paste it into your post HTML. It works in any static site generator, CMS, or hand-coded HTML page. The embed is a thin loader, not an iframe, so the content is fully in your DOM.