Visual Reward Machines: Learning Temporal Logic from Raw Pixels
Abstract
Reinforcement learning in non-Markovian environments requires agents to reason about the history of their interactions. While Reward Machines provide a symbolic framework for such tasks, they typically rely on pre-defined symbol grounding. We present Visual Reward Machines (VRM), a neurosymbolic architecture that learns to ground symbols and perform temporal reasoning directly from visual input. By integrating a convolutional symbol grounder with a differentiable Probabilistic Moore Machine, VRMs achieve high accuracy and sample efficiency in complex visual tasks.
Introduction
Standard Reinforcement Learning (RL) assumes the Markov property, where the optimal action depends only on the current state. However, many real-world objectives are defined by sequences of events—for instance, "collect a key before opening a door." These non-Markovian tasks are often addressed using Linear Temporal Logic (LTL) or Reward Machines (RM).
The primary bottleneck in applying RMs to high-dimensional visual data is symbol grounding: the process of mapping raw pixels to the logical symbols used by the machine. Manual grounding is brittle and difficult to scale. Visual Reward Machines (VRM) address this by learning symbol grounding and temporal logic end-to-end.
The VRM Framework
The VRM architecture is designed to be both neural and interpretable. It consists of two primary components:
- Symbol Grounder: A Convolutional Neural Network (CNN) that transforms raw image inputs into a probability distribution over a set of abstract symbols.
- Probabilistic Moore Machine (PMM): A specialized recurrent module where the weights are constrained to represent the transition and reward matrices of a finite state automaton.
To enable end-to-end training, the authors employ a $\tau$-softmax (temperature-controlled softmax). This allows the model to maintain differentiable "fuzzy" logic during training, which gradually hardens into discrete symbolic transitions as the temperature is lowered.
Experimental Evaluation
The framework was evaluated on two distinct benchmarks:
- Visual Minecraft: A grid-world environment where an agent must navigate to collect items (pickaxe, gem) in any order before reaching a door, while avoiding hazards like lava.
- Tomita Languages: A standard benchmark for formal language induction, used here to verify the model's ability to learn automaton structures from noisy sequences.
Key Insights
- Inductive Bias: Constraining the recurrent module to the structure of a Moore Machine provides a powerful prior, leading to significantly better sample efficiency compared to standard LSTMs.
- Contextual Disambiguation: The temporal logic of the RM can correct perceptual errors. If the symbol grounder is uncertain between two objects, the machine's internal state—representing progress toward the goal—can resolve the ambiguity.
- Robustness: The differentiable nature of the VRM allows it to handle noisy inputs that would cause traditional symbolic solvers to fail.
Results
In offline learning tasks, the VRM achieved near-perfect accuracy, whereas a CNN+LSTM baseline reached only 40% due to difficulties with temporal label imbalance. In online RL settings using Advantage Actor-Critic (A2C), the VRM-based agent demonstrated faster convergence and higher cumulative rewards.
While symbol grounding accuracy on individual frames may fluctuate, the overall sequence classification remains robust, demonstrating that the temporal reasoning layer effectively filters out perceptual noise.
Conclusion and Future Work
Visual Reward Machines represent a significant step toward integrating high-level reasoning with low-level perception. Future work will focus on automated structure discovery within the visual RL loop and scaling the framework to 3D environments and continuous control tasks.
Summary updated