Demystifying active inference

Noor Sajid, Philip J. Ball, Karl J. FristonarXiv 2019 · DOI

Abstract

Active inference is a first principle account of how autonomous agents operate in dynamic, non-stationary environments. This problem is also considered in reinforcement learning (RL), but limited work exists on comparing the two approaches on the same discrete-state environments. In this paper, we provide: 1) an accessible overview of the discrete-state formulation of active inference, highlighting natural behaviors in active inference that are generally engineered in RL; 2) an explicit discrete-state comparison between active inference and RL on an OpenAI gym baseline. We begin by providing a condensed overview of the active inference literature, in particular viewing the various natural behaviors of active inference agents through the lens of RL. We show that by operating in a pure belief-based setting, active inference agents can carry out epistemic exploration, and account for uncertainty about their environment in a Bayes-optimal fashion. Furthermore, we show that the reliance on an explicit reward signal in RL is removed in active inference, where reward can simply be treated as another observation; even in the total absence of rewards, agent behaviors are learned through preference learning. We make these properties explicit by showing two scenarios in which active inference agents can infer behaviors in reward-free environments compared to both Q-learning and Bayesian model-based RL agents; by placing zero prior preferences over rewards and by learning the prior preferences over the observations corresponding to reward. We conclude by noting that this formalism can be applied to more complex settings if appropriate generative models can be formulated. In short, we aim to demystify the behavior of active inference agents by presenting an accessible discrete state-space and time formulation, and demonstrate these behaviors in a OpenAI gym environment, alongside RL agents.

1. Introduction

In the field of artificial intelligence, Reinforcement Learning (RL) has established itself as the primary framework for decision-making. However, RL faces two persistent challenges: the "Reward Problem," where agents require carefully handcrafted numerical signals to avoid degenerate behaviors, and the "Exploration-Exploitation Dilemma," which typically requires heuristic solutions like $\epsilon$-greedy strategies or ad-hoc novelty bonuses.

Active Inference (AI), a framework derived from neuroscience and the Free Energy Principle, offers a more principled alternative. Instead of maximizing a scalar reward, AI agents act to minimize "surprise" (Variational Free Energy). This paper demystifies AI for the machine learning community by providing a direct, head-to-head comparison with RL in a controlled, discrete-state environment.

2. The Active Inference Framework

Active Inference is formulated using a discrete state-space and time framework, resting on two mathematical pillars:

  • Variational Free Energy (VFE): This is used for perception. The agent maintains a generative model of the world and updates its internal beliefs to minimize the discrepancy between its expectations and incoming sensory data.
  • Expected Free Energy (EFE): This is used for action selection. When evaluating potential policies (sequences of actions), the agent selects the one that minimizes future surprise.

Crucially, the EFE objective naturally decomposes into epistemic value (information-seeking to resolve uncertainty) and extrinsic value (seeking preferred outcomes). In this paradigm, exploration is not a secondary "bonus" but a mathematical necessity of the objective function. Furthermore, "reward" is not an external signal but an observation that the agent prefers to see based on its prior beliefs.

3. Experimental Setup

To compare AI and RL, we utilized a modified version of the OpenAI Gym FrozenLake environment. The task involves a $3 \times 3$ grid where an agent must navigate to a goal (the "Frisbee") while avoiding hazards ("holes").

To test the agents' robustness, we introduced non-stationarity by flipping the locations of the goal and the holes at specific intervals. This requires the agent to "unlearn" previous environmental layouts and adapt to new dynamics—a significant challenge for traditional RL algorithms.

4. Key Results and Analysis

4.1 Superior Adaptation to Change

In the non-stationary FrozenLake task, the Active Inference agent demonstrated remarkable agility. It recovered its performance almost immediately—often within a single episode—after the environment changed. In contrast, Bayesian RL and Q-learning agents required approximately 40 episodes to re-learn the environment and reach comparable performance levels.

4.2 Emergent Curiosity and Exploration

One of the most striking findings was the AI agent's behavior in the total absence of rewards. While the Q-learning agent remained stagnant or moved in circles without a reward signal, the AI agent systematically explored the entire grid. This behavior emerges because the agent seeks to resolve uncertainty about the environment's layout to minimize future Expected Free Energy.

4.3 Preference Learning and Self-Evidencing

In AI, rewards are subjective features of the agent. We demonstrated that agents could learn their own "prior preferences" over time using Dirichlet hyper-priors. This allows agents to effectively "invent" their own goals based on past experiences. However, this can lead to "self-evidencing": if an agent spends enough time in a specific state (even a "hole"), it may eventually conclude that it prefers that state and begin seeking it out.

5. Discussion and Conclusion

Our results suggest that RL can be viewed as a special case of Active Inference. When uncertainty is removed from the environment, the "pragmatic" component of AI becomes mathematically equivalent to reward maximization in RL. However, the broader AI framework provides a more robust foundation for handling non-stationarity and intrinsic motivation.

Despite these advantages, challenges remain. The current implementation relies on exhaustive policy search, which is computationally expensive. Future work must focus on scaling these models to high-dimensional, continuous environments through amortized inference or efficient tree-search methods. Additionally, exploring how these "self-evidencing" agents interact in multi-agent settings could provide new insights into social behavior and game theory.

Summary updated

BibTeX
@misc{sajid2019demystifying,
  author = {Noor Sajid and Philip J. Ball and Karl J. Friston},
  title = {{Demystifying active inference}},
  year = {2019},
  eprint = {1909.10863},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1909.10863},
}
Figure