Simulating Hard Attention Using Soft Attention

Andy Yang, Lena Strobl, David Chiang, Dana Angluin
12/13/2024
cs.LGcs.CLcs.FL

No confident code implementation found for this paper.

Abstract

We study conditions under which transformers using soft attention can simulate hard attention, that is, effectively focus all attention on a subset of positions. First, we examine several subclasses of languages recognized by hard-attention transformers, which can be defined in variants of linear temporal logic. We demonstrate how soft-attention transformers can compute formulas of these logics using unbounded positional embeddings or temperature scaling. Second, we demonstrate how temperature scaling allows softmax transformers to simulate general hard-attention transformers, using a temperature that depends on the minimum gap between the maximum attention scores and other attention scores.

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{yang2024simulating,
  title  = {Simulating Hard Attention Using Soft Attention},
  author = {Andy Yang and Lena Strobl and David Chiang and Dana Angluin},
  year   = {2024},
  eprint = {2412.09925},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2412.09925v2}
}

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/2412.09925.svg)](https://codeofpaper.com/paper/2412.09925)

Discussion