Transformers as Transducers

Lena Strobl, Dana Angluin, David Chiang, Jonathan Rawski, Ashish Sabharwal
4/2/2024
cs.FLcs.LG

No confident code implementation found for this paper. 1 possible match can be shown below.

Abstract

We study the sequence-to-sequence mapping capacity of transformers by relating them to finite transducers, and find that they can express surprisingly large classes of transductions. We do so using variants of RASP, a programming language designed to help people "think like transformers," as an intermediate representation. We extend the existing Boolean variant B-RASP to sequence-to-sequence functions and show that it computes exactly the first-order rational functions (such as string rotation). Then, we introduce two new extensions. B-RASP[pos] enables calculations on positions (such as copying the first half of a string) and contains all first-order regular functions. S-RASP adds prefix sum, which enables additional arithmetic operations (such as squaring a string) and contains all first-order polyregular functions. Finally, we show that masked average-hard attention transformers can simulate S-RASP.

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. 1 weaker match is hidden by default — 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{strobl2024transformers,
  title  = {Transformers as Transducers},
  author = {Lena Strobl and Dana Angluin and David Chiang and Jonathan Rawski and Ashish Sabharwal},
  year   = {2024},
  eprint = {2404.02040},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2404.02040v3}
}

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

Discussion