In a simple grid-world, reinforcement learning (RL) agents can easily track which states they have visited by maintaining a table of counts. If a state has a low count, the agent is incentivized to explore it. However, this "count-based exploration" breaks down in high-dimensional environments like video games or robotics. In these settings, an agent rarely sees the exact same pixel configuration or joint angle twice, making traditional tabular counting impossible.
To bridge this gap, researchers have turned to Locality-Sensitive Hashing (LSH). By mapping high-dimensional observations into discrete, low-dimensional "buckets," agents can once again count their experiences and identify truly novel regions of an environment.
The Intuition of Hashing for Novelty
The core challenge in high-dimensional RL is that the state space is effectively infinite. As Aya Kayal and colleagues note in The impact of intrinsic rewards on exploration in Reinforcement Learning, while simple state-counting is the "gold standard" for low-dimensional tasks, it becomes fragile when dealing with pixels.
Hashing provides a solution by discretizing the continuous. Unlike standard cryptographic hashes (which are designed to give wildly different outputs for similar inputs), Locality-Sensitive Hashing is designed to map similar inputs to the same hash code. This allows an agent to group "similar enough" states into a single bucket.
Marius Captari, Matthia Sabatelli, and Remo Sasso demonstrate this in their VDSC framework, where visual states are mapped into discrete bit-codes. By tracking the frequency of these bit-codes, the agent can calculate a "novelty" score. When the agent encounters a state with a low hash count, it triggers an increase in exploration, effectively moving beyond "blind" random actions like $\epsilon$-greedy.
Informed Exploration and Future Imagination
Hashing does more than just track where an agent has been; it can help an agent decide where to go. In Hashing Over Predicted Future Frames for Informed Exploration of Deep Reinforcement Learning, Haiyan Yin and Sinno Jialin Pan introduce a model that "imagines" the future. The agent predicts the visual outcome of potential actions, hashes those predicted frames, and prioritizes paths that lead to the most novel (least-visited) hash buckets.
This concept is extended by Yao Fu and Honglak Lee in the GoBI framework. They use LSH to maintain an episodic memory, rewarding the agent for maximizing "episodic reachability"—essentially seeking out areas where the agent’s world model can imagine the highest number of unvisited states.
Applications in Continuous Control and Safety
The utility of hashing extends into continuous control and safety-critical domains:
- Sparse Rewards: In environments where rewards are rare, such as complex navigation, Ehsan Futuhi and Martin Müller 0003 use LSH within the ETGL-DDPG algorithm. By tracking state frequency, the agent can navigate complex topologies like mazes by systematically pushing toward unexplored hash buckets.
- Action Persistence: Jianshu Hu and Paul Weng developed SNAP, which uses hash-based novelty to decide how long to repeat an action. In familiar (high-count) areas, the agent uses fine-grained control; in novel (low-count) areas, it persists with actions longer to push deeper into the unknown.
- Human-in-the-loop Safety: Shashank Reddy Chirra and Pradeep Varakantham apply hashing to reduce human labeling effort. Their system only asks for safety feedback when the agent encounters a trajectory with a high concentration of novel hash codes, ensuring human intervention is reserved for truly new experiences.
Why It Works
Hashing works because it provides a computationally efficient way to implement the Count-Based Exploration principle in spaces where a literal count is impossible. As Nicolas Proellochs demonstrates in the ReinforcementLearning R package, hash-based indexing ensures that even as the observed state space expands, the cost of retrieving and updating values remains manageable. By turning high-dimensional "noise" into discrete "signals," hashing allows agents to systematically map their world, one bucket at a time.