TL;DR: The Recurrent Action Transformer with Memory (RATE) is a novel architecture for offline reinforcement learning designed to solve the "forgetting" problem in long-horizon, partially observable tasks. By combining segment-level recurrence with a unique Memory Retention Valve (MRV), RATE maintains crucial information across thousands of steps, significantly outperforming standard Transformers and RNNs on memory-intensive benchmarks.
The Challenge: Context Limits in POMDPs
In Reinforcement Learning (RL), Transformers have become a go-to tool for modeling agent trajectories as sequences. However, they face a major hurdle: quadratic complexity. Because the cost of self-attention grows quadratically with sequence length, Transformers are usually restricted to a relatively small "context window."
In Partially Observable Markov Decision Processes (POMDPs), this limitation is a dealbreaker. Imagine an agent in a maze that sees a "turn left" cue at step 1 but doesn't reach the corresponding junction until step 1,000. If the Transformer's window is only 50 steps, it will have "forgotten" the cue long before it's needed. While Recurrent Neural Networks (RNNs) handle long sequences better, they often struggle with vanishing gradients and fail to capture complex dependencies as effectively as Transformers.
The RATE Architecture
To bridge the gap between the high capacity of Transformers and the long-term persistence of recurrence, the authors introduce RATE. The architecture relies on three main pillars:
- Segmented Processing: Instead of feeding the whole trajectory at once, RATE splits it into non-overlapping segments.
- Memory Embeddings: Each segment is prepended and appended with "memory tokens." The prefix copy allows the model to read from the past, while the suffix copy allows it to write an updated state for the next segment.
- Memory Retention Valve (MRV): This is the paper's core innovation. The MRV is a cross-attention module sitting between segments. It uses the previous memory state as a "Query" to filter the newly generated memory (the "Keys" and "Values"). This allows the model to selectively decide what to keep and what to discard, preventing "catastrophic overwriting" where new, irrelevant data pushes out old, vital cues.
The authors also include hidden-state caching (similar to Transformer-XL), which provides a dense, short-term history alongside the sparse, long-term memory tokens.
Key Insights: The "Read-Write" Duality
By placing memory tokens at both the start and end of a segment within a causal Transformer, the model can attend backward to "read" and allow final layers to attend forward to "write" the next state in a single pass.
Furthermore, the authors provide a theoretical proof showing that if the model maintains a certain geometric "alignment" between memory states, the MRV mathematically guarantees a lower bound on how much information is preserved.
Ablations revealed that memory tokens are best for sparse, discrete cues (like a single bit of information at the start of a level), while cached hidden states are better for dense, continuous feedback (like navigating a 3D environment).
Performance and Results
The researchers evaluated RATE against a massive battery of tests, including memory-intensive tasks (ViZDoom-Two-Colors, T-Maze, Memory Maze, Minigrid-Memory, and the 46-task POPGym suite) as well as standard benchmarks (Atari and MuJoCo).
- T-Maze Dominance: On the T-Maze task, standard Decision Transformers (DT) fail as soon as the corridor length exceeds their context window. RATE maintains near-perfect performance even at 10x the training length, demonstrating remarkable generalization via extrapolation.
- POPGym Leaderboard: RATE achieved the highest overall score across 48 tasks. Critically, on the "Memory" sub-category, RATE was the only model to maintain a positive average score, while all other baselines (including DT and LSTMs) fell into the negatives.
- Efficiency: Despite the added memory mechanism, RATE actually has 1.0% to 7.7% fewer parameters than a standard Decision Transformer because it can operate effectively without a heavy feed-forward network (FFN) in the decoder. It also uses significantly less GPU memory during training due to its segmented approach.
Limitations and Future Work
While highly effective for complex environments, RATE’s memory machinery might introduce unnecessary overhead for simple, fully observable tasks where the agent sees everything it needs at the current moment. Additionally, the optimal number of memory tokens and segments can vary by task, requiring some hyperparameter tuning.
Future directions include exploring adaptive memory scaling, where the model dynamically adjusts its memory capacity based on environment complexity, and extending this architecture from offline RL to online settings.
Summary updated