Introduction
Standard Bayesian inference is built on the assumption of a stationary world—the idea that data is independent and identically distributed (i.i.d.). In this setting, as an agent sees more data, its "posterior" (its belief) becomes increasingly certain, and its variance shrinks.
However, the real world is often non-stationary. If the environment changes, a standard Bayesian agent becomes "confidently wrong." Because its uncertainty has already shrunk to near zero, it lacks the flexibility to update its beliefs quickly in response to new, conflicting evidence. Common fixes involve "forgetting" mechanisms—like sliding windows or exponential decay—that discard old data. The problem is that these methods treat every change as a brand-new state. If an agent moves from Earth to Mars and back to Earth, a "forgetting" agent has to learn Earth's gravity from scratch all over again.
To address this, researchers propose BAM (Bayes with Adaptive Memory), a novel framework for online learning that allows Bayesian agents to navigate non-stationary environments by selectively remembering or forgetting past experiences. By treating past observations as a library of potential priors and using Bayesian model selection to pick the most relevant ones, BAM enables rapid adaptation to environmental shifts and efficient "re-learning" when old conditions reappear.
The BAM Framework
BAM endows the agent with an explicit memory buffer and a set of readout weights. The core mechanism operates through four key steps:
- Adaptive Prior Construction: Instead of just using the previous time step's posterior as the current prior, BAM constructs a prior by selecting a subset of past observations from its memory. Each past observation is assigned a binary weight.
- Bayesian Model Selection: To decide which memories to "activate," the agent treats different weight configurations as different models. It performs a Maximum A Posteriori (MAP) estimate to find the weights that best explain the current batch of data.
- Complexity Regularization: To prevent overfitting (i.e., picking a memory that fits the current noise perfectly but isn't representative), the framework uses a "penalized model complexity" prior. This favors simpler models with fewer active memories unless the data strongly suggests otherwise.
- Greedy Optimization: Since checking every possible combination of memories is computationally impossible, BAM uses greedy "Bottom-Up" or "Parallel" selection algorithms to find effective weights efficiently.
Key Insights
- Generalization of Existing Methods: BAM acts as a generalized algorithm. By choosing specific weights, it can recover standard recursive Bayes, power priors, exponential forgetting, and even "Bayesian unlearning."
- Modulating Learning Speed: By discarding irrelevant memories, BAM can artificially increase its own uncertainty. This "unshrinking" of the variance is exactly what allows the agent to increase its learning speed when the environment shifts.
- The Power of Recall: Unlike Changepoint Detection (BOCD), which resets to a blank slate when a change is detected, BAM can look into its buffer and recognize previously visited states, allowing for near-instantaneous adaptation.
- Feedback Mechanism: Standard Bayes is "open-loop" (data in, posterior out). BAM is "closed-loop"; it evaluates how well its internal models fit the incoming data and adjusts its prior accordingly.
Experimental Results
The paper evaluates BAM across four distinct scenarios: synthetic 1D inference, Cartpole control, non-stationary bandits, and Rotated MNIST domain adaptation.
Tracking Performance and Variance Unshrinking: In a 1D synthetic inference task where the underlying probability parameter oscillates following a sine wave, BAM tracked the parameter with much lower error than recursive Bayes (which failed to adapt) and showed less lag than BOCD. Crucially, BAM achieves this by allowing its posterior variance to "unshrink" when the environment changes, preventing it from becoming confidently wrong.
Rapid Recovery in Control: In a Cartpole reinforcement learning task, non-stationarity was introduced by changing the gravity constant (simulating moving between different planets). BAM initially learned a new gravity setting like any other agent. However, upon returning to a previously visited gravity setting, it recovered high performance almost immediately by recalling the relevant memories, while other agents had to re-learn from scratch.
Bandits and Domain Adaptation: * Lower Regret in Bandits: A version of the algorithm called UCBAM (combining BAM with Upper Confidence Bound) outperformed standard UCB and Thompson Sampling in non-stationary bandit environments, particularly as the number of arms increased. * Domain Adaptation: On Rotated MNIST, BAM achieved 71.8% accuracy on novel domains by leveraging past experiences, significantly higher than the 55% achieved by standard Ordinary Least Squares (OLS) trained across all domains.
Limitations and Future Work
While BAM offers a powerful approach to non-stationary learning, it has current limitations. The implementation relies on conjugate priors to keep the marginal likelihood analytically tractable, which limits its immediate use with complex models like deep neural networks. Additionally, the authors restricted weights to binary values for simplicity, though continuous weights could provide more granular control. Finally, as the agent lives longer, the memory buffer grows indefinitely; future work is needed to develop efficient buffer management or pruning schemes. The authors point toward "streaming variational inference" as a potential path to integrate BAM with deep Bayesian neural networks.
Summary updated