Hard Monotonic Attention (Online NMT)
Sequence-to-sequence LSTM whose attention moves only left to right, so it can decode online in linear time.
Audio and speech · 685 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
- Audio and speech
- Parameters
- 6.4M
- Operations
- 685
- Framework
- PyTorch
- Recurrent
- Yes
- Published
- ICML 2017
- Cited by
- 215 (as of 30 October 2026)
- Authors
- Colin Raffel, Minh-Thang Luong, Peter J. Liu and others
- Source
- GitHub: craffel/mad
- 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
- m17308
- Graph hash
- 11e59bf7b8849979c155c6a6a3cdac5ecd82cf485f99c4c6203a46098e1180ba
- Skeleton hash
- 47d39422cb98e82f2d8575c5fcb510dd2c5b9b3c653095705f0f6ea4dcc0222c
- Architecture hash
- 6d85b3bcb03b515f22b2c0de3c9f5e3952c7df73e9cb47410653af90c65f8298
- Diagram SHA-256
- 79bb9f68f9da52fb37d1ec921b5c590255fec61e9a18b5fcf53e9835ea7ae9ec
- 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
Hard monotonic attention is an attention mechanism for recurrent sequence-to-sequence models that scans the input once, from left to right. Ordinary soft attention makes a pass over the entire input for each output element, which rules out online use and gives quadratic time complexity. The paper builds on the observation that in many problems, such as transcribing speech, the alignment between input and output is roughly monotonic.
At each output step the decoder inspects memory entries from left to right, starting from where it left off at the previous step, and chooses a single one. That choice is nondifferentiable, so the paper derives an algorithm for its expected output: the model trains with standard backpropagation and switches to the online, linear-time process at test time. During training, zero-mean, unit-variance Gaussian noise is added before the sigmoid so that the selection probabilities end up close to 0 or 1.
For online speech recognition on TIMIT, the paper's encoder is three unidirectional LSTM layers. Time reduction layers after the first and second LSTM layer skip every other sequence element. The decoder is a single unidirectional LSTM with a 62-dimensional output softmax, covering the 60 TIMIT phonemes plus start-of-sequence and end-of-sequence tokens. The paper notes that on TIMIT, CTC still outperforms all sequence-to-sequence models.
Key idea. The paper proposes an end-to-end differentiable method for learning monotonic alignments that lets attention be computed online and in linear time at test time.
- monotonic attention
- hard monotonic attention
- online and linear-time attention
- monotonic alignment
- online attention
- online speech recognition
- sequence-to-sequence
- attention mechanism
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{raffel2017onlinelineartimeattentionenforcing,
title={Online and Linear-Time Attention by Enforcing Monotonic Alignments},
author={Colin Raffel and Minh-Thang Luong and Peter J. Liu and Ron J. Weiss and Douglas Eck},
year={2017},
eprint={1704.00784},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/1704.00784},
}