ARM-FM: Automated Reward Machines via Foundation Models for Compositional Reinforcement Learning

Roger Creus Castanyer, Faisal Mohamed, Pablo Samuel Castro, Cyrus Neary, Glen Berseth · DOI

Introduction

Reinforcement Learning (RL) has long faced a fundamental challenge in reward specification. Sparse rewards, where an agent only receives feedback upon task completion, often lead to inefficient exploration and failure in complex environments. Conversely, dense rewards—designed to guide the agent through intermediate steps—are notoriously difficult to engineer and frequently lead to "reward hacking," where agents exploit loopholes in the reward function without achieving the intended goal.

Reward Machines (RMs) have emerged as a robust solution by representing tasks as finite state automata that decompose complex objectives into structured sub-goals. However, the practical utility of RMs has been limited by the need for human experts to manually define states, transitions, and the "labeling functions" (code that detects event triggers). This paper introduces ARM-FM (Automated Reward Machines via Foundation Models), a framework that automates the creation of these structures using Large Language Models (LLMs), enabling agents to solve long-horizon tasks with minimal human intervention.

The ARM-FM Framework

ARM-FM bridges the gap between high-level human intent and low-level reinforcement learning through a three-stage pipeline:

1. Automated Generation

Given a natural language task description and a visual observation of the environment, a "Generator" Foundation Model (FM) constructs the Reward Machine. This includes defining the logical states, the transitions between them, and the Python-based labeling functions required to ground these transitions in the environment's API.

2. Self-Improvement Loop

To mitigate the risks of hallucination or logical errors common in LLM-generated code, ARM-FM incorporates a "Critic" FM. This model reviews the generated RM for syntax errors, logical inconsistencies, or potential reward-hacking vulnerabilities. The system iteratively refines the RM based on this feedback before it is passed to the RL agent.

3. Language-Conditioned RL and LARMs

A key innovation of this work is the Language-Aligned Reward Machine (LARM). In traditional RMs, states are represented by discrete identifiers (e.g., State 1, State 2). In a LARM, each state is associated with a natural language instruction and its corresponding semantic embedding. By conditioning the RL agent’s policy on these embeddings, the framework creates a "shared skill space." This allows the agent to treat sub-goals as compositional skills, facilitating transfer learning across diverse tasks.

Experimental Evaluation

The authors evaluated ARM-FM across a variety of challenging environments to test its planning, scaling, and generalization capabilities:

  • MiniGrid & BabyAI: Used to evaluate long-horizon planning in 2D grid worlds. In tasks like UnlockToUnlock, where standard RL baselines (DQN) failed entirely, ARM-FM achieved near-perfect success rates.
  • Craftium: A 3D Minecraft-inspired environment requiring complex resource-gathering chains (e.g., Wood → Stone → Iron → Diamond). ARM-FM enabled PPO agents to solve these sequences, which were previously intractable for standard RL.
  • Meta-World: Demonstrated the framework's efficacy in continuous control and robotic manipulation tasks.
  • XLand-MiniGrid: Used to measure multi-task learning and zero-shot generalization.

Key Findings

  • Zero-Shot Generalization: Because the agent learns semantic concepts (e.g., "pick up the red key") rather than abstract state IDs, it can solve novel tasks composed of familiar sub-goals without any additional training.
  • Scaling Effects: The reliability of the generated RMs is highly correlated with the size of the FM. Larger models, such as Qwen-32B, significantly outperformed smaller models in generating valid Python code and logical RM structures.
  • Superiority over VLMs: ARM-FM outperformed approaches that use Vision-Language Models (like CLIP) directly as reward signals. While VLMs provide general semantic feedback, they often lack the precise spatial and logical reasoning required for complex RL tasks, which the structured RM provides.

Discussion and Future Work

ARM-FM represents a significant step toward autonomous reward engineering. By using FMs as high-level planners and RMs as the grounding mechanism, the framework provides the granular feedback necessary for RL while maintaining the flexibility of natural language.

Despite its success, the authors note that the system's reliance on code generation makes it sensitive to the FM's knowledge of specific environment APIs. Future research directions include the integration of formal verification to make the self-correction loop entirely autonomous and extending the framework to multi-agent environments where complex coordination is required.

Summary updated

BibTeX
@inproceedings{castanyer2026arm,
  author = {Roger Creus Castanyer and Faisal Mohamed and Pablo Samuel Castro and Cyrus Neary and Glen Berseth},
  title = {{ARM-FM: Automated Reward Machines via Foundation Models for Compositional Reinforcement Learning}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=OBpQdCWLfd},
}
Figure