about
What Algorithms Can Transformers Learn? A Study in Length Generalization (arxiv.org)
2 points by sebg on Feb 9, 2024 | hide | past | pdf | 1 comment on HN

In plain words: They predict a transformer will handle longer inputs than it trained on whenever the task fits a short program in a tiny language that mirrors how transformers compute. The rule matched most known cases and sharply improved accuracy on tasks like parity and addition.

Abstract · What Algorithms can Transformers Learn? A Study in Length Generalization

Large language models exhibit surprising emergent generalization properties, yet also struggle on many simple reasoning tasks such as arithmetic and parity. This raises the question of if and when Transformer models can learn the true algorithm for solving a task. We study the scope of Transformers' abilities in the specific setting of length generalization on algorithmic tasks. Here, we propose a unifying framework to understand when and how Transformers can exhibit strong length generalization on a given task. Specifically, we leverage RASP (Weiss et al., 2021) -- a programming language designed for the computational model of a Transformer -- and introduce the RASP-Generalization Conjecture: Transformers tend to length generalize on a task if the task can be solved by a short RASP program which works for all input lengths. This simple conjecture remarkably captures most known instances of length generalization on algorithmic tasks. Moreover, we leverage our insights to drastically improve generalization performance on traditionally hard tasks (such as parity and addition). On the theoretical side, we give a simple example where the "min-degree-interpolator" model of learning from Abbe et al. (2023) does not correctly predict Transformers' out-of-distribution behavior, but our conjecture does. Overall, our work provides a novel perspective on the mechanisms of compositional generalization and the algorithmic capabilities of Transformers.

Hattie Zhou, Arwen Bradley, Etai Littwin, Noam Razin, Omid Saremi, Josh Susskind, Samy Bengio, Preetum Nakkiran
arXiv:2310.16028 · cs.LG, cs.AI, cs.CL, stat.ML · submitted Oct 24, 2023
abstract · pdf · html · Preprint

add comment on HN

Doesn't this also generalize to LLMs (which are mostly all doing just one-next-word prediction):

https://news.ycombinator.com/item?id=38830186 :

>>> Making the prefix shorter tends to produce less coherent prose; making it longer tends to reproduce the input text verbatim. For English text, using two words to select a third is a good compromise; it seems to recreate the flavor of the input while adding its own whimsical touch.

But could classical LLMs approximate quantum relations?

https://news.ycombinator.com/item?id=39255848 :

> If there is some sort of e.g. geometric correspondence, it could be possible for a Church-Turing classical computer to compute quantum functions (that return wave functions) that a Church-Turing-Deutsch quantum computer can compute; but otherwise Lean [and all non-quantum LLMs] can't compute most quantum circuits either.