Unique Hard Attention: A Tale of Two Sides

Selim Jerad, Anej Svete, Jiaoda Li, Ryan Cotterell
3/18/2025
cs.LGcs.CCcs.CL

No confident code implementation found for this paper.

Abstract

Understanding the expressive power of transformers has recently attracted attention, as it offers insights into their abilities and limitations. Many studies analyze unique hard attention transformers, where attention selects a single position that maximizes the attention scores. When multiple positions achieve the maximum score, either the rightmost or the leftmost of those is chosen. In this paper, we highlight the importance of this seeming triviality. Recently, finite-precision transformers with both leftmost- and rightmost-hard attention were shown to be equivalent to Linear Temporal Logic (LTL). We show that this no longer holds with only leftmost-hard attention -- in that case, they correspond to a \emph{strictly weaker} fragment of LTL. Furthermore, we show that models with leftmost-hard attention are equivalent to \emph{soft} attention, suggesting they may better approximate real-world transformers than right-attention models. These findings refine the landscape of transformer expressivity and underscore the role of attention directionality.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{jerad2025unique,
  title  = {Unique Hard Attention: A Tale of Two Sides},
  author = {Selim Jerad and Anej Svete and Jiaoda Li and Ryan Cotterell},
  year   = {2025},
  eprint = {2503.14615},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2503.14615v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2503.14615.svg)](https://codeofpaper.com/paper/2503.14615)

Discussion