Table of Contents
Fetching ...

Transformers as Transducers

Lena Strobl, Dana Angluin, David Chiang, Jonathan Rawski, Ashish Sabharwal

TL;DR

This work extends the existing Boolean variant B-RASP to sequence-to-sequence transductions and shows that it computes exactly the first-order rational transductions (such as string rotation).

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.

Transformers as Transducers

TL;DR

This work extends the existing Boolean variant B-RASP to sequence-to-sequence transductions and shows that it computes exactly the first-order rational transductions (such as string rotation).

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.
Paper Structure (34 sections, 21 theorems, 44 equations, 1 figure, 8 tables)

This paper contains 34 sections, 21 theorems, 44 equations, 1 figure, 8 tables.

Key Result

Theorem 3.4

Any $\text{B-RASP}$ program with packed outputs defines an aperiodic rational transduction.

Figures (1)

  • Figure 1: Overview of results of this paper. Arrows denote inclusion; dashed arrows denote inclusions that are known from previous work. Slashed arrows denote non-inclusions. The columns, from left to right, are: (1) the hierarchy of aperiodic transductions; (2) RASP variants; (3) variants of transformer encoders.

Theorems & Definitions (60)

  • Definition 2.1: string homomorphism
  • Definition 2.2: deterministic finite transducer
  • Example 2.3
  • Example 2.4
  • Definition 2.5: aperiodicity
  • Example 2.6
  • Definition 2.7
  • Example 3.1
  • Example 3.2
  • Example 3.3
  • ...and 50 more