All models

Universal Transformer

Universal Transformer, an encoder-decoder that reapplies one self-attention block over recurrent steps.

Language · 742 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (168 KB)

Open in a new tab

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

Parameters
63M
Operations
742
Framework
PyTorch
Recurrent
Yes
Published
ICLR 2019
Cited by
440 (as of 27 October 2026)
Authors
Mostafa Dehghani, Stephan Gouws, Oriol Vinyals and others
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 diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m21218
Graph hash
051b38efd96d352b635a6ef56f618bb9274e307d7d938a8958ff4933dd6e5493
Skeleton hash
d5597a2a32f2cb103ecd2dabbabe5ee44e9ae32fad1451931abbb9d8a6b29929
Architecture hash
03a9233c66c4ceddb3ace984a0204ffd7364864e556407746bd66f23bd32eb44
Diagram SHA-256
1476a15979eb11aa36f4e7ff0d32638e44df5f4ade5f6a477fc1cdd36587845c
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 Universal Transformer (UT) is a sequence model that recurs over depth: rather than stepping through positions, it repeatedly revises the vector representation of every position. The paper proposes it as a generalization of the Transformer that keeps its parallelism and global receptive field while adding the recurrent inductive bias of RNNs. The motivation is that the Transformer fails to generalize on simple tasks that recurrent models handle, such as copying strings longer than those seen in training.

In each recurrent step, every position is first updated with self-attention across the whole sequence and then passed through a transition function shared across positions and time steps. Both the encoder and the decoder work this way, and the decoder also attends to the final encoder representation. Fixed two-dimensional (position, time) coordinate embeddings tell the model both where a symbol sits and which step it is on. A dynamic per-position halting mechanism can let the model choose the number of refinement steps for each symbol.

On WMT14 En-De machine translation, the paper reports a 0.9 BLEU improvement over Transformers. It also notes that dynamic halting improved accuracy on several smaller algorithmic and linguistic inference tasks but marginally degraded results on machine translation.

Key idea. The Universal Transformer refines every position in parallel with self-attention followed by a transformation shared across all positions and time-steps, applied recurrently.

  • universal transformer
  • universal transformers
  • ut
  • adaptive universal transformer
  • recurrent self-attention
  • dynamic halting
  • adaptive computation time
  • machine translation
  • sequence-to-sequence
  • tensor2tensor

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{dehghani2019universaltransformers,
      title={Universal Transformers}, 
      author={Mostafa Dehghani and Stephan Gouws and Oriol Vinyals and Jakob Uszkoreit and Łukasz Kaiser},
      year={2019},
      eprint={1807.03819},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/1807.03819}, 
}