Universal In-Context Approximation By Prompting Fully Recurrent Models

Zero-shot and in-context learning enable solving tasks without model fine-tuning, making them essential for developing generative model solutions. Therefore, it is crucial to understand whether a pretrained model can be prompted to approximate any function, i.e., whether it is a universal in-context approximator. While it was recently shown that transformer models do possess this property, these results rely on their attention mechanism. Hence, these findings do not apply to fully recurrent architectures like RNNs, LSTMs, and the increasingly popular SSMs. We demonstrate that RNNs, LSTMs, GRUs, Linear RNNs, and linear gated architectures such as Mamba and Hawk/Griffin can also serve as universal in-context approximators. To streamline our argument, we introduce a programming language called LSRL that compiles to these fully recurrent architectures. LSRL may be of independent interest for further studies of fully recurrent models, such as constructing interpretability benchmarks. We also study the role of multiplicative gating and observe that architectures incorporating such gating (e.g., LSTMs, GRUs, Hawk/Griffin) can implement certain operations more stably, making them more viable candidates for practical in-context universal approximation.

Paper

Similar papers

Peer review

Reviewer qz767/10 · confidence 4/52024-07-03

Summary

In-context learning has emerged as one of the puzzling properties of language models at scale. While a lot of work has been done to understand the mechanics supporting this behavior in attention-based models, much less has been done on recurrent models. Given the renewed interest in these architectures (e.g. Mamba or Griffin), a better understanding of in-context learning in these models is needed. The paper proposes to study these abilities through the notion of in-context approximation, that is whether a model can produce a certain function if it's given the right prompt. The authors show two universality results by introducing a low-level programming language that implements the canonical proof ideas for this kind of result within the neural dynamics.

Strengths

- The paper studies in-context learning from an interesting perspective: in-context approximation theory. - Abstracting neural dynamics in a programming language is an elegant way to prove the approximation results of the paper. - The paper is overall very well written and easy to follow.

Weaknesses

- The review of the different recurrent architectures is inaccurate. For example, Mamba and Hawk do not have an A matrix that is constant: it is x-dependent. On top of that, this matrix is diagonal with real values, which makes the implementation of the rotation algorithm presented in 4.2 impossible. More clarity on these questions, starting in Section 2 is necessary. - Some synthetic numerical experiments involving the training networks to solve the task, e.g. comparing the solution found by gradient descent to the one of the construction or confirming the importance of gating to get more compact solutions, would be an interesting add-on. I am aware that it is a theoretical paper and I am not expecting such experiments to recommend acceptance. Yet, it would still nicely complement the paper. - Section 6 does not bring much to the story.

Questions

- Can the authors position their work compared to: - [Zucchet et al. 2023](https://arxiv.org/abs/2309.01775): they study the link between gated RNNs (very similar to the one you consider) and attention, therefore connecting to the literature on how attention solves in-context learning. Additionally, they also highlight the importance of gating in practice. - [Orvieto et al. 2023](https://arxiv.org/abs/2307.11888) and the references mentioned there on the universal approximation capabilities of linear RNNs. It would be valuable to compare with those results in more detail, c.f. next question. - I am wondering about how fundamentally different is in-context approximation compared to the universal approximation. Is one a subset of the other? How are they related / what are their difference? Given that one of the contributions of the paper is the introduction of this notion, answers to these questions would be particularly valuable. - What is the interest of introducing such a low-level programming language? It feels to me that LSLR is a tiny abstraction on top of the neural equations that is not necessarily worth it. Why not directly include the primitives used in e.g. Figure 3 in this language? Some more open questions: - The paper shows that deep linear RNNs can implement a variety of functions in context, somehow supporting the argument that linear recurrence + nonlinear instantaneous processing is quite powerful. Does the framework provided by the authors give hints about which kinds of functions are difficult to learn with such networks? The authors mention something around these lines in lines 165-167, but more detail would be appreciated. - Are there some links between the in-context learning approximation notion introduced here and the notion of controllability in control theory?

Rating

7

Confidence

4

Soundness

4

Presentation

4

Contribution

3

Limitations

The authors have correctly addressed the limitation of the applicability of their construction to more practical settings as well as highlighted that better understanding in-context learning is critical in a world where LLMs are available through APIs.

Reviewer 3Cyh8/10 · confidence 3/52024-07-13

Summary

This paper designs a new programming language LSRL that compiles to a fully recurrent structure and shows that multiple recurrent architectures including RNNs, LSTMs, and SSMs can serve as universal in-context approximators. They also show that multiplicative gating allows more numerically stable construction.

Strengths

1. This paper reveals interesting properties of multiple recurrent structures and shows they can perform universal in-context approximation. 2. The discovery of the numerical instabilities when gating is missing is also interesting and provides intuitions on the role of gating. 3. The programming language created by this paper may be of independent interest.

Weaknesses

1. In the introduction, the paper mentions that RNNs can be prompted to act as any token-to-token function over a finite token sequence. However, in the actual construction, the prompt specifying the function must be put after the query. This claim, while necessary for RNNs, is not very standard. Clarity will be improved if this caveat is mentioned earlier in the paper.

Questions

1. If one considers a hybrid architecture that consists of both RNN and Transformer Layer, can one use a combination of LSRL and RaSP language to compile such a model? 2. In the conclusion, it is mentioned that the compiled transition matrix is often diagonal. Are those matrices exactly diagonal here?

Rating

8

Confidence

3

Soundness

4

Presentation

4

Contribution

3

Limitations

Limitation are adequately addressed.

Reviewer Aa6c7/10 · confidence 4/52024-07-14

Summary

The paper shows that sequence-to-sequence networks like RNNs, LSTMs, and Mamba are universal in-context approximators, which was defined as the ability to compute any function with an appropriate prompt. The authors propose a programming language called LSRL which can express any language expressible by a linear RNN (and vice-versa). The authors discuss numerical stability issues in their proposed language and discuss possible solutions. Overall, the paper streamlines a theoretical framework to understand expressivity of recurrent models and will prove to be an interesting contribution to the wider community.

Strengths

The strength of the paper lies in its simplistic exposition of its motivation, proposed framework, and the discussions of various frailties and solutions. Sequence-to-sequence models have proven to be competitive to transformers, but the gaps between the two architectures are still under exploration. Expressivity for transformers has been studied through RASP (Weiss et al.'21), and this paper shows a similar programming language to understand linear RNNs. Through LSRL, the authors argue about the kind of languages linear RNNs can express and the impact of gating in RNNs. Overall, the paper takes an important step towards understanding sequence-to-sequence models.

Weaknesses

As such, I don't see clear weakness with the work. However, I would like the authors to be more clearer on their contributions. How is the theoretical framework different from the expressivity studies on feedforward networks and RNNs [1, 2]? That is, as far as I understand, the constructions in section 4.1 and 4.2 still construct a RNN that can do a dictionary lookup for each possible query, very similar to ones constructed in previous works. If I understand correctly, the strength of the paper is more on creating a systematic programming language to compile languages into RNNs. The universal expressivity happens to be a by-product of this framework and is very similar to previous constructions. References: 1: Andrew R Barron. 1993. Universal approximation bounds for superpositions of a sigmoidal function. IEEE Transactions on Information Theory, 39(3):930–945. 2: Recurrent Neural Networks Are Universal Approximators. AM Schäfer, HG Zimmermann. In Artificial Neural Networks–ICANN 2006: 16th International Conference, Athens, Greece, September 10-14, 2006. Proceedings, Part I 16, pages 632–640. Springer.

Questions

Please check my questions above.

Rating

7

Confidence

4

Soundness

4

Presentation

4

Contribution

3

Limitations

The authors discuss the limitations of their work in section 7, and clearly indicate the future directions that the community can pursue starting from their work.

Reviewer uwk64/10 · confidence 2/52024-07-15

Summary

The paper explores the potential of various recurrent neural network architectures (RNNs, LSTMs, GRUs, Linear RNNs, and gated architectures) to act as universal in-context approximators, crucial for zero-shot and in-context learning without fine-tuning. It introduces the LSRL programming language to facilitate this, highlighting the role of multiplicative gating in enhancing model stability for practical applications.

Strengths

The concept of universal approximation in the context of in-context learning is both intriguing and innovative. This research presents a unique angle that adds valuable insights to the field.

Weaknesses

- The paper is very dense and hard to read and follow. The construction is rather tricky. Do you have any high-level idea in the proof? - I don't understand the practical value of proving that linear RNNs are in-context universal approximators. Linear RNNs are known to be inferior at in-context learning and retrieval (see references [1], [2], [3]). How does demonstrating that linear RNNs are in-context universal approximators mitigate this issue in practice? Isn't it somewhat contradictory to claim that RNNs are in-context universal approximators but cannot perform in-context learning well? - Many theoretical papers claim that non-linear RNNs are universal approximators or Turing-complete, often under impractical assumptions like infinite precision and exponential hidden state sizes. What about the assumptions in this paper? Do you think all assumptions are practical? - The definition of gated (linear) RNNs in this paper is very unusual. Typically, gating refers to the recurrence itself being gated by forget gates or data-dependent decays, rather than gating the output. [1] In-Context Language Learning: Architectures and Algorithms https://arxiv.org/abs/2401.12973 [2] Simple linear attention language models balance the recall-throughput tradeoff https://arxiv.org/abs/2402.18668 [3] RNNs are not Transformers (Yet): The Key Bottleneck on In-context Retrieval https://arxiv.org/abs/2402.18510

Questions

See weakness.

Rating

4

Confidence

2

Soundness

3

Presentation

2

Contribution

2

Limitations

N/A

Reviewer 3Cyh2024-08-07

Thank the authors for the detailed response. I will keep my score.

Reviewer qz762024-08-08

Thanks to the authors for their answers! I'll keep my score as it is. [Minor point] In their rebuttal, the authors mention that the universality of linear RNNs was only proven in 2023. To the best of my understanding, Boyd and Chua already proved a universality result in 1985 (https://stanford.edu/~boyd/papers/pdf/fading_volterra.pdf).

Authorsrebuttal2024-08-12

Thank you for highlighting Boyd and Chua's work! The connection between what we now call Linear RNNs and the results in the Boyd and Chua (due Wang and Xue) was recent but the fundamental results are indeed quite old. Thank you for the insight, we will add the Boyd and Chua reference to our updated manuscript for completeness.

Reviewer Aa6c2024-08-12

I thank the authors for their response. After going through the response, I am maintaining my score.

Reviewer uwk62024-08-13

- How does the proof of universal in-context learning of linear RNNs guide the practical development of these models? While I am not opposed to theoretical papers, I'm not convinced that this proof will significantly benefit the development of the field. As a researcher who leans more towards empirical work, I cannot recommend acceptance for this paper unless it clearly guides practice or explains some successes or flaws in existing empirical phenomena. However, I would not oppose others in the theory community who may find this work valuable. I believe my perspective is typical among empirical researchers; theory should either guide empirical study or explain existing empirical phenomena. - Regarding gated RNNs, gating the recurrence remains linear if no activation is involved in the middle of the recurrence. For example, current linear models like Griffin, HGRN, Mamba, GLA, and RWKV6 all incorporate such gating in the recurrence and can leverage either parallel scan [1] or chunkwise form [2] for parallel training. Gated linear recurrence should definitely reference these linear RNN models with data-dependent forget gates or decays. The definition used in this work seems questionable to me. [1] https://arxiv.org/abs/1709.04057 Parallelizing Linear Recurrent Neural Nets Over Sequence Length [2] https://arxiv.org/abs/2312.06635 Gated Linear Attention Transformers with Hardware-Efficient Training

Authorsrebuttal2024-08-14

> How does the proof of universal in-context learning of linear RNNs guide the practical development of these models? While I am not opposed to theoretical papers, I'm not convinced that this proof will significantly benefit the development of the field. As a researcher who leans more towards empirical work, I cannot recommend acceptance for this paper unless it clearly guides practice or explains some successes or flaws in existing empirical phenomena. However, I would not oppose others in the theory community who may find this work valuable. I believe my perspective is typical among empirical researchers; theory should either guide empirical study or explain existing empirical phenomena. Our paper has the following contributions that are directly applicable to empirical research: 1. **LSRL is a tool with practical applications in itself.** We develop LSRL, a new programming language that is isomorphic to a large class of recurrent models. Using this language and the compiler we have developed, one can directly program behaviours that can be then incorporated into RNNs, LSTMs, GRUs and Hawk/Griffin models. Due to this isomorphism, conversely, given a model with these architectures, we can “decompile” it as an LSRL program. This would be quite useful for people doing interpretability, explainability and safety research for models with these architectures. 2. **We explain the successes of architectures with multiplicative gating.** Recurrent architectures with multiplicative gating such as Mamba and Hawk have outperformed architectures without it. With our experiments, we show that multiplicative gating is much more numerically stable when one wants the model to follow an algorithm in-context precisely, which is how a lot of the evaluation and benchmarks are set up. We also show that multiplicative gating enables a much more compact implementation of concrete algorithms, and hence can explain why smaller models with multiplicative gates are sometimes comparable in performance to larger models that do not have them. Therefore, our work **explains one aspect that can drive the success** of gating architectures and **guides the practice to use multiplicative gating**. We believe that beyond serving as a basis for engineering and applied research, the foundation of science is a desire to understand the world around us for the joy of discovery and knowledge. The development of machine learning is not restricted to building new models, but also includes understanding, characterizing and organizing the properties of the methods, tools and mathematical models we already have. We are positive that a large part of the NeurIPS audience feels the same way, hence why “Theory” is one of the areas explicitly mentioned in this year’s Call for Papers. In this way, our work fills key gaps in the characterization of the universal approximation properties of neural network models, an area with a long history, while also serving as a guide for design decisions for recurrent architectures and explaining some successes of multiplicative gating. > Regarding gated RNNs, gating the recurrence remains linear if no activation is involved in the middle of the recurrence. For example, current linear models like Griffin, HGRN, Mamba, GLA, and RWKV6 all incorporate such gating in the recurrence and can leverage either parallel scan [1] or chunkwise form [2] for parallel training. Gated linear recurrence should definitely reference these linear RNN models with data-dependent forget gates or decays. The definition used in this work seems questionable to me. Perhaps we are using two different definitions of “linear recurrence”. We mean it in the sense of a “linear time-invariant system” (LTI). As such, models like Mamba and Griffin would not satisfy this definition. They would be something like a “linear time-variant system” (LTV). However, as every time-invariant system is a trivial time-variant system, the class of LTV systems is a proper superset of the class of LTI systems. Therefore, if there is an instance of an LTI system with a certain property (in our case, universal in-context approximation), then it immediately follows that there is an instance for an LTV system with that property. In our work we show that the more restricted setting already is a universal in-context approximator, automatically making the more general setting you are referring to a universal in-context approximator as well. We show this connection explicitly and formally in Appendix D, where we show that the Hawk/Griffin architecture is also a universal in-context approximator. Hence, the definition we use is not limiting our results in any way whatsoever, it is just the most general (or, if one wants, _abstract_) definition that serves the goal of our work.

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC