# Attention Is All You Need

Author: Ishwar Jangid
Canonical URL: https://ishwarj.com/papers/transformer/
Updated: 2026-10-18
Source: https://github.com/ishwar6/ishwar-books/blob/main/content/papers/transformer/index.md


## Why this paper

Before 2017, the best translation systems read a sentence one word at a time. Each step waited for the step before it, so training could not use the full power of a GPU. This paper removed that loop. Its model, the **Transformer**, lets every word look at every other word in one step, through a mechanism called **attention**.

The Transformer translated better than the systems before it and trained in a fraction of the time. The same design now runs every large language model, many image models and speech models.

## How the seven parts are organised

**Before Part 1 (optional): [The Road to the Transformer](https://ishwarj.com/papers/transformer/background-the-road-to-the-transformer/).** Recurrent networks, encoder-decoder translation, and the first attention mechanism.

Each part follows the paper's own sections:

1. **[The Big Idea](https://ishwarj.com/papers/transformer/part-1-the-big-idea/)**: the title, the abstract, §1 and §2. What was wrong with recurrence, and the claim that attention alone is enough.
2. **[The Architecture](https://ishwarj.com/papers/transformer/part-2-the-architecture/)**: §3, Figure 1, §3.1, §3.3, §3.4 and §3.5. The encoder and decoder stacks, residual connections, layer normalisation, the feed-forward network, embeddings and position encodings.
3. **[Attention](https://ishwarj.com/papers/transformer/part-3-attention/)**: §3.2 and Figure 2. Scaled dot-product attention, multi-head attention, masking, and the three ways the model uses attention.
4. **[Why Self-Attention](https://ishwarj.com/papers/transformer/part-4-why-self-attention/)**: §4 and Table 1. Cost per layer, steps in sequence and path length, against recurrent and convolutional layers.
5. **[Training](https://ishwarj.com/papers/transformer/part-5-training/)**: §5. The data, batching, hardware, the learning-rate schedule, dropout and label smoothing.
6. **[Results, Variations and Impact](https://ishwarj.com/papers/transformer/part-6-results-and-impact/)**: §6, §7, Tables 2 to 4 and the attention pictures of the appendix. What the paper showed, and what came after.
7. **[Build It from Scratch](https://ishwarj.com/papers/transformer/part-7-build-it-from-scratch/)**: the whole Transformer in about 300 lines of PyTorch, one block at a time. We load the released model's weights into our own code, get the same translation, and train a small Transformer on your laptop.

## How to read the boxes

- A **teal "From the paper" box** shows the exact lines of the paper as a highlighted screenshot. Click the screenshot to see it at full size. Under it, **What it says** gives the main words of the paper. **What it means** then explains those lines, and what the authors mean but do not write. When the box shows a different paper, the box gives the name of that paper.
- A **yellow definition box** explains a technical word the first time it occurs. If you know the word, skip the box.
- The small **Paper §3** tag above a heading tells you which section of the paper you read.
- A **green "Key takeaways" box** ends each part with the facts to remember.

Code blocks show real code, and the output under a code block is what that code printed. The scripts are in [`code/papers/transformer`](https://github.com/ishwar6/ishwar-books/tree/main/code/papers/transformer).

## What you need to know first

You need to know what a vector and a matrix are, and how to multiply them. Every other term is explained when it first occurs. The [attention series](https://ishwarj.com/writings/attention-1-self-attention/) explains self-attention from zero, and is a good companion to Part 3.

