Reinforcement Learning (RL) has a "reward problem." If you give an agent a sparse reward (e.g., "only get a point when you finish the whole task"), it wanders aimlessly. If you give it a dense reward (e.g., "get points for moving closer to the goal"), it often finds loopholes—learning to spin in circles to rack up points without ever finishing the job.
A new paper, ARM-FM: Automated Reward Machines via Foundation Models, proposes a clever solution: use the reasoning power of Foundation Models (FMs) to automatically build structured "Reward Machines" from natural language.
TL;DR
ARM-FM uses Large Language Models (LLMs) to translate natural language instructions into executable state machines that guide RL agents. By conditioning policies on language embeddings of these states, the framework enables agents to solve complex, long-horizon tasks and achieve zero-shot generalization to entirely new missions.
What Problem Does This Paper Address?
The "dark art" of RL is reward engineering. Designing a reward function that is both informative enough for learning and robust against "reward hacking" is incredibly difficult and usually requires human experts.
While Foundation Models are great at high-level planning (e.g., "To make coffee, first find a mug..."), they struggle to "ground" those plans into the low-level, step-by-step feedback an RL agent needs. Conversely, Reward Machines (RMs)—automata-based representations of a task—are excellent for structured learning but are notoriously tedious to build by hand. ARM-FM bridges this gap by using FMs to automate the construction of RMs, turning abstract human intent into concrete learning signals.
Methods
The core innovation is the Language-Aligned Reward Machine (LARM). The framework operates in two main phases: generating the reward machine and integrating it into the RL training loop.
- Generation Loop: A "Generator" FM takes a natural language task description and environment details to produce a formal RM specification. This includes states (sub-goals), transitions (logic), and executable Python labeling functions (code that checks if a sub-goal, like "holding a key," is met).
- Self-Correction: A "Critic" FM reviews the generated code and logic for errors. A human can optionally step in to provide feedback if the FM misses an edge case.
- Semantic Grounding: Each state in the RM is associated with a natural language instruction (e.g., "Pick up the red key"). These are converted into language embeddings.
- Policy Conditioning: Unlike standard RL agents that only see the environment, the ARM-FM agent also receives the language embedding of its current sub-goal. This allows the agent to learn a "skill space" where similar instructions share knowledge.
Datasets
The authors evaluated ARM-FM across a diverse set of benchmarks:
- MiniGrid & BabyAI: 2D grid worlds requiring complex logic like unlocking nested doors.
- Craftium: A 3D, Minecraft-inspired voxel world used to test scaling to visual complexity and long-horizon resource gathering.
- Meta-World: A robotic manipulation benchmark used to test continuous control.
- XLand-MiniGrid: A massive benchmark of 1,000 diverse tasks used to evaluate multi-task learning and zero-shot generalization.
Key Insights and Ideas
- Compositionality is the Secret Sauce: By breaking a massive task into a state machine, the agent never faces a "needle in a haystack" exploration problem. It always has a clear, immediate sub-goal.
- Language as a Universal Interface: Because the policy is conditioned on language embeddings rather than arbitrary state IDs, the agent doesn't just learn "State 1"; it learns the concept of the task. This enables it to solve a new task composed of sub-goals it saw in previous tasks without any further training.
- The Scaling Law of Logic: The researchers found a clear trend: larger FMs (like Qwen-32B) are significantly more reliable at generating syntactically correct and logically sound Reward Machines than smaller models.
- Semantic Clustering: PCA visualizations of the state embeddings showed that the FM naturally clusters sub-goals by their role in a task (e.g., "start," "middle," and "end" states), providing a coherent structure for the agent to navigate.
Key Results
- Solving the "Unsolvable": In the
KeyCorridorandUnlockToUnlockenvironments, standard RL baselines and even intrinsic motivation methods (like ICM) failed to make any progress. ARM-FM agents achieved near-perfect success rates. - Zero-Shot Generalization: On the XLand-MiniGrid benchmark, agents trained on a set of tasks could immediately solve novel compositions of those tasks, maintaining high performance even as the number of simultaneous tasks increased.
- Efficiency in 3D: In the Minecraft-like Craftium environment, ARM-FM enabled a PPO agent to solve a complex resource-gathering chain that was completely intractable for the baseline.
Limitations and Future Work
- Human-in-the-Loop: While many RMs were generated fully autonomously, complex robotics tasks (Meta-World) still required a human to "scale" reward values to avoid local minima (like an agent grabbing an object but never moving it).
- Code Reliability: The system relies on the FM's ability to write bug-free Python labeling functions. While the "Critic" model helps, hallucinations remain a risk.
- Predicate Limits: The current framework is limited to tasks that can be defined by boolean predicates (True/False checks). Future work could involve using Vision-Language Models (VLMs) as labeling functions to handle more "fuzzy" or visual sub-goals.
Summary updated