TL;DR
This paper introduces Hierarchies of Reward Machines (HRMs), a powerful extension to standard Reward Machines that allows finite-state reward representations to call one another like subroutines. By enabling modularity and abstraction, HRMs allow agents to solve complex, long-horizon tasks significantly faster than "flat" models and make learning feasible in scenarios where standard methods fail due to state-space explosion.
The Challenge: Sparse Rewards and "Flat" Limitations
Reinforcement Learning (RL) often struggles with "sparse rewards"—situations where an agent performs many actions before receiving any feedback. For example, building a house requires hundreds of steps before a single "success" signal is achieved. Reward Machines (RMs) were recently proposed to help by using finite-state machines to track subgoals (e.g., "get wood" then "get stone").
However, standard RMs have a major limitation: they aren't modular. If you have an RM for "making a cake," you cannot easily reuse it as a component in a larger "host a party" RM. As tasks get more complex, these "flat" RMs become massive, tangled, and difficult to learn or hand-design. This paper tackles this lack of abstraction by allowing RMs to be nested hierarchically.
Methods: Formalizing and Learning HRMs
The authors propose three core contributions to overcome the limitations of flat RMs:
- The HRM Formalism: They redefine the Reward Machine so that transitions can trigger a "call" to another RM. This creates a stack-based execution similar to a programming language. Crucially, they prove that while any HRM can be "flattened" into a standard RM, the flat version can be exponentially larger in terms of states and edges.
- HRL Exploitation: To use these hierarchies, they employ Hierarchical Reinforcement Learning (HRL) via the options framework. They define two types of options:
- Formula Options: Low-level policies that aim to satisfy a specific logical condition (e.g., "touch the blue ball").
- Call Options: High-level policies that treat an entire sub-RM as a single action (e.g., "execute the 'get-wood' routine").
- Learning HRMs (LHRM): They introduce an algorithm to learn these hierarchies from scratch using agent traces. It uses Inductive Logic Programming (ILASP) to find the simplest logic rules that explain the observed rewards. To make this tractable, they use a curriculum-based approach, learning simple RMs first and then using them as "callable" building blocks for more complex tasks.
Evaluation Environments
The researchers evaluated their approach on two primary environments designed to test sequential logic, long horizons, and the ability to avoid terminal failure states:
- CraftWorld: A grid-world inspired by Minecraft. Tasks involve collecting resources and combining them in specific sequences (e.g., "Batter" requires Flour and Eggs; "Cake" requires Batter, Milk, and Sugar).
- WaterWorld: A continuous 2D environment where an agent must collide with colored balls in specific orders while avoiding "dead-end" balls.
Key Insights and Results
- The Power of Abstraction: The theoretical proof that hierarchies provide exponential compression is a major highlight. A task requiring a 100-state flat RM might only need a few 5-state RMs arranged hierarchically.
- Modularity Equals Reusability: By treating sub-RMs as "Call Options," the agent can learn a policy for a sub-task once and reuse it across many different high-level goals. This mirrors how humans solve problems by breaking them into known routines.
- Curriculum as a Necessity: The paper shows that for the most complex tasks (like baking a "Cake" in CraftWorld), learning a flat RM from scratch is essentially impossible. The only way to succeed is to learn the hierarchy piece-by-piece.
- Faster Convergence: In CraftWorld, using a handcrafted HRM led to significantly faster learning than an equivalent flat RM, especially as task complexity increased.
- Feasibility: The LHRM algorithm successfully learned hierarchies for complex tasks where flat-RM learners (like JIRP or DeepSynth) timed out or failed to find a valid representation.
- Exploration Efficiency: Using options for exploration was up to 128x more efficient than using primitive (random) actions in sparse reward settings, as the agent could "jump" between meaningful subgoals rather than wandering aimlessly.
Limitations and Future Work
- Known Propositions: The current model assumes the high-level events (propositions like "at-tree" or "has-milk") are already defined and provided to the agent. Learning these directly from raw pixels or sensor data remains a challenge.
- Fixed Curriculum: The learning process currently requires a pre-defined set of tasks to build the curriculum. Developing an "autotelic" agent that proposes its own sub-tasks to build a hierarchy would be a major step forward.
- Global Optimality: While the policies are "recursively optimal" (optimal for each sub-task), they aren't necessarily globally optimal for the entire root task. Refining these policies to account for higher-level goals is an open area for future research.
Summary updated