Wink Pings

GPT and BERT share one set of building blocks; the difference is who attention can see

One diagram compresses Transformer, GPT, and BERT into the same attention formula. Broken down, the encoder, decoder, causal mask, and cross-attention are clearer than memorizing architecture diagrams.

Transformer, GPT, and BERT are often listed side by side, as if they were three different architectures. X user @mathemetica posted a short video that, once the structures are broken down, leaves the same set of attention building blocks.

The original Transformer had an encoder and a decoder. The encoder uses self-attention to read the input; the decoder writes the output one token at a time, using masked self-attention internally and cross-attention over the encoder. This design originally served sequence-to-sequence tasks, with machine translation as the most typical case.

GPT keeps the decoder and removes cross-attention. A causal mask lets each token see only the tokens before it, so the training objective naturally becomes predicting the next word. BERT keeps the encoder. Each token sees both left and right at the same time, and the pretraining task becomes fill-in-the-blank: restoring the masked words.

All three ultimately reduce to the same formula: softmax(QKᵀ/√dₖ)V. There are many lines in architecture diagrams, but one key variable that truly changes model behavior is the visibility range of attention. Tighten the range, and the model can only look forward; open it up, and it can read both sides of the context.

Video:

The original post's compression is very shareable, and it also makes it easy to remember an oversimplified conclusion. In the replies, someone directly asked @Grok whether BERT only keeps the encoder, has each token look at both sides, and then fills in hidden words. This way of asking shows that the explanation works, and also that people will use a one-sentence summary to verify it. Another user, Orion Shi, mentioned in a reply that from one perspective, these large models are related to Bayes' formula and the law of total probability. This perspective is worth discussing, but it cannot replace architectural differences. Training objectives, data, scale, positional encoding, number of layers, and more all change model capabilities.

Treating GPT and BERT as two completely different buildings makes it easy to get more confused the more you look. Treat them as different rooms in the same building: first look at who attention can see, then look at what the model is asked to do during training, and the architecture diagram becomes much clearer. As for which is stronger, that depends on the task and the training recipe, not on the names.

发布时间: 2026-12-01 11:34