Looped Transformers as Programmable Computers

By Angeliki Giannou, Shashank Rajput, Jy-yong Sohn, Kangwook Lee, Jason D. Lee, Dimitris Papailiopoulos. 2023

222 citations recorded by the source corpus.

We present a framework for using transformer networks as universal computers by programming them with specific weights and placing them in a loop. Our input sequence acts as a punchcard, consisting of instructions and memory for data read/writes. We demonstrate that a constant number of encoder layers can emulate basic computing blocks, including embedding edit operations, non-linear functions, function calls, program counters, and conditional branches. Using these building blocks, we emulate a small instruction-set computer. This allows us to map iterative algorithms to programs that can be executed by a looped, 13-layer transformer. We show how this transformer, instructed by its input, can emulate a basic calculator, a basic linear algebra library, and in-context learning algorithms that employ backpropagation. Our work highlights the versatility of the attention mechanism, and demonstrates that even shallow transformers can execute full-fledged, general-purpose programs.

Subfields: Artificial Intelligence, Electrical and Electronic Engineering, Hardware and Architecture, Model Architectures

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Artificial Intelligence

  1. Tengyu Ma
  2. Zhiyuan Li
  3. Di He
  4. Suvrit Sra
  5. Denny Zhou
  6. Liwei Wang
  7. Hadi Daneshmand
  8. Liang Sun

In Electrical and Electronic Engineering

  1. Tengyu Ma
  2. Liang Sun
  3. Xue Wang
  4. Rong Jin
  5. Suvrit Sra
  6. Tian Zhou
  7. Denny Zhou

In Hardware and Architecture

  1. Tengyu Ma
  2. Liwei Wang

In Model Architectures

  1. Di He
  2. Hadi Daneshmand
  3. Tengyu Ma
  4. Liang Sun
  5. Xue Wang
  6. Hong Liu
  7. Rong Jin
  8. Liwei Wang

Citations in the corpus