Transformer
Attention-only encoder-decoder for sequence transduction, in the original base size with 6 layers on each side.
Language · 649 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Task
- Language
- Parameters
- 63.1M
- Operations
- 649
- Framework
- PyTorch
- Recurrent
- No
- Published
- NeurIPS 2017
- Cited by
- 78,007 (as of 19 October 2026)
- Authors
- Ashish Vaswani, Noam Shazeer, Niki Parmar and others
- Source
- torch 2.6.0
- Name in source
- Transformer-original
- License
- Apache-2.0
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m3191
- Graph hash
- 512f5f8b31444b19ad0224a65275b333b8d78a386073e11a352b5a92d951d76c
- Skeleton hash
- efbf959bdc33588d92bac06808539df3321c7a8d1cae6254a016935ca0cd7061
- Architecture hash
- 1cd1992486735f55b0ff9ef1dc1029dbd05e203a307d910bba20f5de95ac4084
- Diagram SHA-256
- b7c8cd8345243ed288299285ca3b155e46e7aa90318d0039dc2ed7782a13a873
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
What it is
The Transformer is a sequence transduction architecture based solely on attention mechanisms, dispensing with recurrence and convolutions entirely. The paper's motivation is that recurrent computation is inherently sequential, which precludes parallelization within training examples.
The encoder is a stack of 6 identical layers, each with a multi-head self-attention sub-layer and a position-wise feed-forward network, wrapped in residual connections and layer normalization. The decoder also stacks 6 layers and adds a third sub-layer that attends over the encoder output, with masking so that each position depends only on known outputs at earlier positions. Attention is scaled dot-product attention run in 8 parallel heads, all sub-layers produce outputs of dimension 512, and the feed-forward inner layer has dimensionality 2048. Because the model has no recurrence or convolution, sinusoidal positional encodings are added to the input embeddings. The base model here uses a shared source-target byte-pair vocabulary of about 37000 tokens, as in the paper's English-German setup.
The paper reports 28.4 BLEU on the WMT 2014 English-to-German translation task and 41.8 BLEU on English-to-French after training for 3.5 days on eight GPUs. It also reports that the Transformer generalizes to English constituency parsing. The official code was released in the Tensor2Tensor library, which is now deprecated in favor of Trax.
Key idea. The Transformer replaces recurrence and convolution with multi-head self-attention, enabling more parallel training while improving translation quality in the paper's WMT 2014 results.
- transformer
- attention is all you need
- self-attention
- multi-head attention
- scaled dot-product attention
- encoder-decoder
- machine translation
- positional encoding
- tensor2tensor
- sequence transduction
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{vaswani2023attentionneed,
title={Attention Is All You Need},
author={Ashish Vaswani and Noam Shazeer and Niki Parmar and Jakob Uszkoreit and Llion Jones and Aidan N. Gomez and Lukasz Kaiser and Illia Polosukhin},
year={2023},
eprint={1706.03762},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/1706.03762},
}