On the Representation Gap Between Modern RNNs and Transformers: The Curse of Memory Efficiency and the Fix of In-Context Retrieval

Kaiyue Wen, Xingyu Dang, Kaifeng LyuME-FoMo @ ICLR 2024

TL;DR

This paper reveals a fundamental "representation gap" where modern RNNs struggle with algorithmic tasks that Transformers handle with ease, even with advanced prompting techniques like Chain-of-Thought (CoT). The authors demonstrate that augmenting RNNs with in-context retrieval, specifically using regular expressions, can effectively bridge this gap, allowing RNNs to achieve Transformer-level performance on complex reasoning tasks while maintaining their memory efficiency.

What Problem Does This Paper Address?

The paper tackles the growing disparity in capabilities between modern Recurrent Neural Networks (RNNs) and Transformers, particularly in handling algorithmic and reasoning tasks. While RNNs offer superior memory efficiency (constant memory with sequence length), they falter on tasks requiring complex reasoning, even when employing techniques like Chain-of-Thought (CoT). Transformers, on the other hand, can solve these tasks, but at a higher computational cost due to their quadratic attention mechanism. This creates a dilemma: choose memory efficiency with limited reasoning or computational power with greater memory demands. The paper aims to resolve this by finding a way for RNNs to achieve robust reasoning capabilities without sacrificing their memory advantage.

Methods

The core of the paper's contribution lies in proposing and analyzing "Retrieval Augmented RNNs." The authors first establish the theoretical limitations of standard RNNs and even RNNs with CoT on a specific graph-based reasoning task called "IsTree." They then introduce a mechanism where RNNs can perform "in-context retrieval" by using regular expressions to query their past computations. This allows the RNN to access and utilize relevant information from its history, effectively overcoming its inherent limitations in representing complex sequential dependencies. The paper provides theoretical proofs and experimental validation to show that this retrieval augmentation enables RNNs to solve tasks in $\mathsf{P}$ (polynomial time complexity) with memory complexity proportional to $O(\log n)$, thus closing the representation gap with Transformers.

Datasets

The paper uses a synthetic dataset for the "IsTree" task. Graphs of varying sizes (16, 32, 64 nodes) are generated to test the models. The paper does not introduce new benchmark datasets but focuses on a well-defined algorithmic problem.

Key Insights and Ideas

  • The "Curse of Memory Efficiency": The paper highlights that while RNNs' constant memory usage is a significant advantage, it also imposes a fundamental limitation on their ability to represent and process complex algorithmic information, leading to a "representation gap" compared to Transformers.
  • Chain-of-Thought Isn't Enough for RNNs: Even with CoT prompting, which helps Transformers break down complex problems, RNNs still struggle to maintain the necessary state and reasoning chain for tasks like IsTree.
  • Regular Expressions as a Powerful Retrieval Tool: The key insight is that augmenting RNNs with the ability to query their past using regular expressions is surprisingly powerful. This mechanism allows RNNs to effectively "look up" relevant information, mimicking a form of external memory access.
  • Bridging the Gap without Sacrificing Efficiency: The proposed retrieval augmentation allows RNNs to achieve the computational power of Transformers on certain tasks while retaining their memory efficiency, offering a compelling alternative for resource-constrained environments.

Key Results

  • RNNs Fail on IsTree: Standard RNNs, even with CoT, cannot solve the IsTree task for graphs of size $n$ with $o(n)$ parameters.
  • Transformers Succeed: Transformers, with CoT and $O(\log n)$ precision, can solve the IsTree task.
  • Retrieval Augmentation Fixes RNNs: RNNs augmented with in-context retrieval (using regular expressions) can solve IsTree and other $\mathsf{P}$ problems with $O(\log n)$ memory and $O(n)$ chain-of-thought length.
  • Experimental Validation: Figure 1 visually demonstrates that while both RNNs and Transformers struggle with IsTree without CoT, RNNs' performance degrades significantly with increasing graph size even with CoT. However, both architectures achieve near-perfect accuracy when enhanced with retrieval.

Limitations and Future Work

  • Focus on Algorithmic Tasks: The paper primarily focuses on algorithmic and reasoning tasks. Its applicability to broader natural language understanding tasks where Transformers currently excel is not explicitly explored.
  • Regular Expression Specificity: While regular expressions prove effective, the paper doesn't extensively explore the space of other potential retrieval mechanisms or their comparative effectiveness.
  • Future Work: The authors suggest that their findings are sufficient for RNNs to solve any polynomial-time algorithmic problem. Future work could explore the practical implementation and scaling of these retrieval-augmented RNNs on a wider range of complex tasks and real-world datasets. The paper also hints at the potential for more sophisticated retrieval mechanisms beyond simple regular expressions.

Summary updated

BibTeX
@inproceedings{wen2024representation,
  author = {Kaiyue Wen and Xingyu Dang and Kaifeng Lyu},
  title = {{On the Representation Gap Between Modern RNNs and Transformers: The Curse of Memory Efficiency and the Fix of In-Context Retrieval}},
  booktitle = {ME-FoMo @ ICLR},
  year = {2024},
  url = {https://openreview.net/forum?id=fN8qyEgSES},
}
Figure