WFA-IRL: Inverse Reinforcement Learning of Autonomous Behaviors Encoded as Weighted Finite Automata

Tianyu Wang, Nikolay Atanasov

TL;DR

WFA-IRL is a novel framework that learns both the high-level logical structure and the low-level cost functions of a task from expert demonstrations. By representing task logic as a Weighted Finite Automaton (WFA) and integrating it with differentiable planning, the system can successfully imitate complex, multi-stage behaviors that traditional Inverse Reinforcement Learning (IRL) methods struggle to capture.

What Problem Does This Paper Address?

Most autonomous systems rely on cost functions to define "good" behavior. However, designing these functions by hand is incredibly difficult for complex tasks involving sequences and dependencies—for example, "pick up a key, then unlock the door, then enter the room, but avoid the lava."

Traditional Inverse Reinforcement Learning (IRL) attempts to learn these costs from expert demonstrations, but it usually assumes a "flat" cost structure. It struggles with compositional logic: the idea that a task is a series of sub-goals that must be completed in a specific order. Without explicitly modeling this logic, an agent might learn to stand near a door but never understand that it first needs to find a key. This paper fills that gap by combining formal language theory (automata) with reward learning.

Methods

The authors propose a two-stage approach called WFA-IRL:

  1. Learning the Logic (Spectral Learning): Instead of using a "black box" like a Recurrent Neural Network (RNN), the authors use Spectral Learning to extract a Weighted Finite Automaton (WFA) from demonstration sequences. The WFA acts as a high-level supervisor that tracks task progress. It is more interpretable than an RNN and can be trained effectively from smaller datasets.

  2. Learning the Costs (Differentiable Planning): The agent creates a "Product Space" by combining the environment (a Markov Decision Process) with the learned WFA. It then uses a shortest-path planning algorithm (like Dijkstra or A*) to find the best path to a "success" state in this combined space.

  3. Backpropagation through Planning: To refine the low-level costs, the authors use a subgradient descent method. They compare the expert's demonstrated actions to the agent's planned path and "backpropagate" the error through the planning algorithm to update the neural network representing the cost function.

Datasets

The method was evaluated using the MiniGrid environment, a common benchmark for RL agents requiring logical reasoning. Specifically, they tested on three tasks:

  • T1 (MultiRoom): Pick up a key, unlock a door, and reach a goal.
  • T2 (Sequential Doors): Open a series of three doors to reach a goal.
  • T3 (Blocked Unlock): Move a blocking object, unlock a door with a key, and pick up a box.

The authors used two types of demonstration sets: $\mathcal{D}_1$ (strictly optimal expert) and $\mathcal{D}_2$ (suboptimal/stochastic expert).

Key Insights and Ideas

  • Logic as a Constraint: By explicitly learning a WFA, the agent treats task stages as hard logical constraints. This prevents the "forgetting" or "looping" behaviors often seen in reactive agents (like those trained with Behavioral Cloning).
  • WFAs vs. RNNs: While RNNs are more expressive, WFAs are "rational," meaning they are better suited for modeling discrete logical transitions. The paper shows they can be learned with near-zero loss from relatively few demonstrations.
  • Generalization through Planning: Because the agent plans using the learned costs rather than just reacting to pixels, it can generalize to entirely new room layouts it hasn't seen before, provided the underlying logic (e.g., "get key first") remains the same.

Key Results

  • Superior Performance: WFA-IRL achieved near-perfect mean episode returns (~0.73 to 0.79) across all tasks, matching the expert's performance.
  • Outperforming Baselines: It significantly outperformed standard imitation learning (Behavioral Cloning) and adversarial methods (GAIL). For instance, in Task T3, GAIL achieved a return of ~0.34, while WFA-IRL reached ~0.73.
  • Ablation Success: The authors tested a version of their model without the WFA component. Performance dropped significantly, proving that the explicit logical structure is what allows the agent to solve long-horizon tasks.

Limitations and Future Work

  • Known Labeling Function: The current model assumes the agent already knows how to identify "events" (e.g., it knows when a "door open" event occurs). In real-world scenarios, these labels might need to be learned from raw sensor data.
  • Sequence Sensitivity: As shown in Figure 5, if an expert always performs a task in one specific sequence (e.g., move ball, then get key), the WFA might fail to recognize a more efficient sequence (e.g., get key, then move ball) during testing.
  • Scalability: Spectral learning involves constructing a Hankel matrix, which can become computationally expensive as the complexity of the task logic (the number of possible event strings) grows.

Overall, WFA-IRL represents a powerful bridge between the reliability of formal methods and the flexibility of deep reinforcement learning.

Summary updated

BibTeX
@inproceedings{wang2022wfa,
  author = {Tianyu Wang and Nikolay Atanasov},
  title = {{WFA-IRL: Inverse Reinforcement Learning of Autonomous Behaviors Encoded as Weighted Finite Automata}},
  booktitle = {IEEE/RSJ International Conference on Intelligent Robots and Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=tQsrI6Ob60},
}
Figure