Introduction
The integration of Transformer architectures into Reinforcement Learning (RL) has led to significant performance gains in complex environments. However, the specific mechanisms driving these improvements have remained largely opaque. While Transformers are often praised for their ability to handle long sequences, it is unclear whether their advantage stems from superior information retention or a better ability to link actions to distant rewards. This paper investigates this distinction by decoupling two fundamental temporal challenges: long-term memory and long-term credit assignment.
Defining the Temporal Challenges
To analyze agent performance rigorously, the authors propose a mathematical framework to quantify two distinct "lengths":
- Memory Length ($L_M$): This represents the minimum history an agent must maintain to represent the optimal policy or value function accurately. It is the "recall" requirement—knowing what happened in the past to make the right choice now.
- Credit Assignment Length ($L_C$): This is the minimum number of future steps required for a "greedy" action to demonstrably outperform a "non-greedy" one in terms of cumulative reward. It measures the difficulty of determining which specific action in a long sequence was responsible for a later success.
By isolating these variables, the study aims to identify where the Transformer’s "superpower" actually lies.
Methodology
The researchers compared GPT-2 based RL agents against traditional LSTM-based agents using standard model-free algorithms, specifically Double Deep Q-Networks (DDQN) and Twin Delayed DDPG (TD3). To ensure a fair comparison, the architectures were normalized: both used the same sequence model for the actor and critic, and hyperparameters such as layer depth and attention heads were carefully tuned.
The evaluation centered on two configurable "unit tests":
- Passive T-Maze: Tests pure memory. An agent receives a color-coded hint at the start and must traverse a long corridor to select the matching door.
- Active T-Maze: Tests both memory and credit assignment. The agent must proactively move away from the goal to collect a hint before proceeding to the final choice.
Beyond these unit tests, the models were evaluated on pixel-based tasks (Key-to-Door) and standard PyBullet benchmarks with occlusions to test short-term dependency handling.
The Memory-Credit Disconnect
The experimental results reveal a stark contrast in how Transformers handle these two challenges.
The 1,500-Step Memory Milestone
In the Passive T-Maze, Transformers demonstrated a massive leap in capability over LSTMs. While LSTMs began to fail when the memory length exceeded 250 steps and were no better than a random policy at 500 steps, Transformers maintained near-perfect performance up to 1,500 steps. This confirms that Transformers are exceptionally well-suited for tasks requiring the recall of distant observations.
The Credit Assignment Wall
Surprisingly, this superior memory does not translate to better credit assignment. In the Active T-Maze, both architectures failed once the credit assignment length reached approximately 500 steps. Despite having the "memory" to remember the hint, the Transformer could not figure out that the initial "wrong-way" movement was the causal factor for the eventual reward. This suggests that Transformers are just as susceptible to the "vanishing credit" problem as LSTMs when using standard Temporal Difference (TD) learning.
Performance and Sample Efficiency
The study also highlighted a "sample efficiency tax" for Transformers. In environments requiring only short-term dependencies (like standard PyBullet tasks), LSTMs consistently reached higher rewards faster than Transformers in 7 out of 8 tasks. The attention mechanism, while powerful for long-range dependencies, appears more data-hungry and less efficient than LSTMs for simpler, reactive tasks.
Discussion and Limitations
The findings suggest that the bottleneck in modern RL is not necessarily the sequence model’s architecture, but the RL algorithms themselves. Increasing the number of layers or attention heads in a Transformer provides some benefit for medium-term credit assignment (up to ~100 steps), but it does not solve the fundamental long-term issue.
Limitations: * Computational Overhead: Transformer training scales quadratically ($O(T^2)$) with context length, making them significantly more expensive than LSTMs for extremely long sequences. * Reward Variance: The current measure of credit assignment does not fully account for the noise or variance of intermediate rewards found in real-world scenarios.
Conclusion
Transformers are a transformative tool for RL agents requiring long-term memory, effectively extending the usable history to 1,500 steps. However, they do not inherently solve the problem of long-term credit assignment. Future research should prioritize the development of RL-specific algorithms—such as improved return redistribution or more robust value estimation—rather than relying solely on scaling sequence architectures to bridge the credit assignment gap.
Summary updated