Skip to main content
QUICK REVIEW

[Paper Review] Transformers Learn Shortcuts to Automata

Bingbin Liu, Jordan T. Ash|arXiv (Cornell University)|Oct 19, 2022
Machine Learning and AlgorithmsComputer Science11 citations
TL;DR

This paper demonstrates that Transformers learn 'shortcut' solutions to simulate finite-state automata using hierarchical reparameterization, enabling exact emulation of sequential computations in O(log T) or even O(1) depth—far shallower than the sequence length T. Theoretical and empirical results show that these shortcuts are common, efficient, and learned via standard training, though they exhibit brittleness in out-of-distribution generalization.

ABSTRACT

Algorithmic reasoning requires capabilities which are most naturally understood through recurrent models of computation, like the Turing machine. However, Transformer models, while lacking recurrence, are able to perform such reasoning using far fewer layers than the number of reasoning steps. This raises the question: what solutions are learned by these shallow and non-recurrent models? We find that a low-depth Transformer can represent the computations of any finite-state automaton (thus, any bounded-memory algorithm), by hierarchically reparameterizing its recurrent dynamics. Our theoretical results characterize shortcut solutions, whereby a Transformer with $o(T)$ layers can exactly replicate the computation of an automaton on an input sequence of length $T$. We find that polynomial-sized $O(\log T)$-depth solutions always exist; furthermore, $O(1)$-depth simulators are surprisingly common, and can be understood using tools from Krohn-Rhodes theory and circuit complexity. Empirically, we perform synthetic experiments by training Transformers to simulate a wide variety of automata, and show that shortcut solutions can be learned via standard training. We further investigate the brittleness of these solutions and propose potential mitigations.

Motivation & Objective

  • To understand how non-recurrent, shallow Transformers perform algorithmic reasoning tasks typically requiring sequential computation.
  • To investigate whether Transformers can exactly simulate finite-state automata using depth sublinear in sequence length.
  • To characterize the structural and computational conditions under which such shortcut solutions exist.
  • To evaluate the robustness and generalization properties of learned shortcut solutions in practice.
  • To propose training strategies that guide Transformers toward more robust, RNN-like iterative reasoning.

Proposed method

  • Theoretical analysis uses Krohn-Rhodes decomposition and circuit complexity to characterize when constant-depth Transformers can simulate semiautomata.
  • Constructs explicit depth-O(log T) and O(1)-depth Transformer architectures that exactly simulate any finite-state automaton via hierarchical reparameterization of transition dynamics.
  • Empirically trains standard, non-autoregressive Transformers on various semiautomaton tasks to observe shortcut learning under standard optimization.
  • Introduces recency-biased scratchpad training to guide autoregressive Transformers toward learning iterative, chain-of-thought-style reasoning.
  • Uses periodic activations (e.g., sin/cos) and max-pooling to reduce width and depth requirements in feedforward networks.
  • Applies reductions from circuit complexity (e.g., NC¹-completeness) to prove lower bounds on depth requirements for non-solvable semiautomata.

Experimental results

Research questions

  • RQ1Can a shallow, non-recurrent Transformer exactly simulate the computation of a finite-state automaton with depth sublinear in sequence length?
  • RQ2Under what conditions do constant-depth shortcut solutions exist for semiautomata, and how are they related to algebraic structure?
  • RQ3Do standard training procedures cause Transformers to naturally learn these shortcut solutions?
  • RQ4How robust are the learned shortcut solutions to distributional shift, particularly in sequence length?
  • RQ5Can we guide Transformers to learn iterative, RNN-like reasoning instead of shortcuts?

Key findings

  • A depth-O(log T) Transformer can exactly simulate any finite-state automaton, regardless of sequence length T.
  • Constant-depth (O(1)) shortcuts exist for solvable semiautomata, as guaranteed by the Krohn-Rhodes theorem.
  • For non-solvable semiautomata, constant-depth simulation is impossible unless TC⁰ = NC¹, establishing a theoretical lower bound.
  • Empirical training shows that standard Transformers converge to shortcut solutions across diverse automaton types, despite non-convex optimization.
  • Learned shortcuts exhibit poor out-of-distribution generalization, especially to unseen sequence lengths, and underperform RNNs under limited supervision.
  • Recency-biased scratchpad training successfully guides autoregressive Transformers to learn iterative, chain-of-thought reasoning, mitigating shortcut brittleness.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.