Explain My Surprise: Learning Efficient Long-Term Memory by Predicting Uncertain Outcomes

Artyom Sorokin, Nazar Buzun, Leonid Pugachev, Mikhail Burtsev

TL;DR

MemUP (Memory for Uncertainty Prediction) is a novel training method that enables recurrent neural networks to learn long-term dependencies across thousands or even millions of steps without the prohibitive memory cost of full backpropagation. By focusing memory updates only on "surprising" future events—those characterized by high local uncertainty—it achieves performance superior to standard LSTMs and Transformers while requiring up to 250x less intermediate data storage.

What Problem Does This Paper Address?

Deep learning models struggle with long-term memory. Standard training via Backpropagation Through Time (BPTT) requires storing intermediate computations for every single step in a sequence to calculate gradients. For sequences with millions of steps, this leads to a "memory wall" where hardware limits make training infeasible.

While Transformers and LSTMs are the standard tools for sequential data, they are often optimized for "local" dependencies (like the next word in a sentence). In many real-world scenarios, especially Reinforcement Learning (RL), an agent might see a crucial hint at step 1 and not need it until step 1,000,000. Storing gradients for all those intermediate, often irrelevant steps is incredibly wasteful. The authors identify that most steps in a sequence are locally predictable; the challenge is identifying and storing only the sparse, "surprising" information needed for distant future outcomes.

Methods

The core idea of MemUP is to train a memory module to "explain away" surprise. It uses an information-theoretic framework to maximize the conditional mutual information between the memory state and future outcomes.

The process involves three main components:

  1. Uncertainty Detector ($d_\psi$): This model scans the sequence to find "surprising" events—steps where the target $y_k$ cannot be easily predicted using only local information $x_k$.
  2. Memory Module ($g_\theta$): A recurrent network (like an LSTM) that selectively stores information from the past.
  3. Predictor ($q_\phi$): A network that takes the current memory state and local observation to predict the "surprising" future events identified by the detector.

Instead of backpropagating through the entire sequence, MemUP only propagates gradients through a few selected high-uncertainty future steps and a very short local window (Truncated BPTT). This allows the model to link a distant past observation directly to a far-future outcome without caring about the millions of steps in between.

Figure 1: MemUP gradient update. The recurrent memory gθ processes a sequence. The number of prediction targets K = 2 and TBPTT length r = 2. Blue circles denote states with the highest uncertainty estimates dψ(yk|xk). Here x2 marked by red circle contains information that can help to predict outcomes yT −2 and yT . At the end of RNN TBPTT rollout these states are selected to form a set U3 = {T −2, T}. Then, m3, xT −2, yT −2, xT , yT are used to compute CE-Loss according to eq. 5. While states 2 and T could be separated by many millions steps, MemUP allows memory to capture the utility of information from x2 by propagating gradients only through the sequence of K + r = 4 elements at a time.

Datasets

The authors evaluated MemUP on both supervised and reinforcement learning benchmarks:

  • Supervised Learning:
    • Copy & Scattered Copy: Tasks requiring the model to remember a sequence of digits and reproduce them much later.
  • Add Task: A regression problem where the model must sum two numbers indicated by markers in a long sequence of noise.
  • pMNIST: Permuted sequential MNIST, where image pixels are fed one by one in a scrambled order.
  • Reinforcement Learning:
    • Noisy T-Maze: An agent receives a hint at the start and must remember it to choose the correct turn at the end of a long corridor.
  • Vizdoom-Two-Colors: A complex 3D environment where an agent must collect items matching the color of a column that disappears early in the episode.

Key Insights and Ideas

  • Surprise as a Utility Signal: The most important finding is that local uncertainty (entropy) is an excellent proxy for memory utility. If a model is "surprised" by an outcome, it likely lacks the necessary context from the past to explain it.
  • Sparse Gradient Updates: By only updating the memory when it helps reduce future surprise, the model avoids the "vanishing gradient" problem common in long sequences.
  • Efficiency via Skipping: MemUP effectively "skips" the intermediate steps during the gradient calculation phase, which is why it can handle sequences that would crash a standard Transformer or LSTM due to memory limits.
  • Robustness to "Noisy TVs": The authors specifically tested the "Noisy-TV" problem—where a model might get distracted by purely random, unpredictable noise. They found that by sampling multiple future events ($K > 1$), the model can distinguish between useful long-term dependencies and useless random noise.

Key Results

MemUP consistently outperformed or matched baselines while being significantly more resource-efficient:

  • Memory Efficiency: MemUP required 10 to 250 times less intermediate data storage than full BPTT baselines on supervised tasks.
  • Scaling: In the T-Maze task, MemUP successfully learned dependencies across 20,000 steps, whereas standard PPO-LSTM and AMRL baselines failed to learn even with 1,000-step rollouts.
  • Supervised Performance: On the pMNIST task (length 3136), MemUP achieved 94.3% accuracy, significantly higher than the 33.6% achieved by a standard LSTM.
Figure 2: Final performance on supervised learning tasks. X-Axis shows task scaling, while Y-axis correspond to metric score at the end of training. Metrics: Inverted Accuracy (1. - Accuracy) in Copy, Scattered copy and pMNIST tasks, MSE in Add task. All curves are averaged over 3 runs.

Limitations and Future Work

  • Noisy-TV Vulnerability: While sampling helps, the method is still theoretically vulnerable to environments with extreme amounts of unpredictable, high-entropy noise that provides no useful information.
  • RL Training Phases: The current RL implementation often requires a pre-training phase with a random policy to gather trajectories, which might not be ideal for all applications.
  • Hyperparameter Sensitivity: The performance depends on the number of sampled future events ($K$) and the uncertainty threshold, which may require tuning for new tasks.
  • Future Direction: The authors suggest integrating MemUP into end-to-end RL training more tightly and exploring its application to even more complex, non-recurrent architectures.

Summary updated

Abstract

In many sequential tasks, a model needs to remember relevant events from the distant past to make correct predictions. Unfortunately, a straightforward application of gradient based training requires intermediate computations to be stored for every element of a sequence. This requires to store prohibitively large intermediate data if a sequence consists of thousands or even millions elements, and as a result, makes learning of very long-term dependencies infeasible. However, the majority of sequence elements can usually be predicted by taking into account only temporally local information. On the other hand, predictions affected by long-term dependencies are sparse and characterized by high uncertainty given only local information. We propose MemUP, a new training method that allows to learn long-term dependencies without backpropagating gradients through the whole sequence at a time. This method can potentially be applied to any recurrent architecture. LSTM network trained with MemUP performs better or comparable to baselines while requiring to store less intermediate data.
BibTeX
@inproceedings{sorokin2022explain,
  author = {Artyom Sorokin and Nazar Buzun and Leonid Pugachev and Mikhail Burtsev},
  title = {{Explain My Surprise: Learning Efficient Long-Term Memory by Predicting Uncertain Outcomes}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=xnsn9E9ceW},
}
Figure