Length Generalization for Transformers via Compression
Abstract
Recent advancements in transformer length generalization theory enable us to reliably predict when a transformer can learn to solve a task. In particular, the C-RASP hypothesis (a formalized version of the so-called RASP-l conjecture) posits that transformers length-generalize on a task if and only if a solution is expressible in the C-RASP language. While this hypothesis has strong empirical validation, it faces a theoretical problem in the fact that C-RASP admits no computable bound on length complexity (that is, the length of strings required to learn a language perfectly), and an empirical problem in the form of experimental results that seem to contradict it. To address these problems, we refine the C-RASP hypothesis using the fragments C-RASP+ and C-RASP1. Recent work has shown that these fragments have length-complexity bounds that are computable, but in the worst case exponential. In this paper, we study the problem of sample enumeration: computing the training data that are required for length generalization. That is, given a bound on the permitted C-RASP+ or C-RASP1 program size (not a particular program), to compute a complete sample for learning. Previous results implied a double exponential time upper bound for the complexity of sample enumeration. In this paper, we show a tight polynomial space and exponential time upper bound. Our algorithm is in fact a simple enumeration of short (polynomially sized) compressed strings, in terms of power words. As an application, we show how this yields a fine-grained analysis of the C-RASP conjecture that provides a possible explanation for the apparent contradiction with experimental evidence.