TL;DR
This paper introduces OSIL, a novel algorithm for offline safe imitation learning. OSIL learns policies that are both safe and performant by inferring safety from "non-preferred" (unsafe) trajectories, rather than relying on explicit safety cost annotations, which are often hard to obtain. This approach allows for safer robot and autonomous system behavior in real-world scenarios where online learning is risky.
What Problem Does This Paper Address?
Learning intelligent behaviors for agents like robots or autonomous vehicles is a key goal in AI. Reinforcement Learning (RL) offers a powerful framework for this, but its real-world application is hindered by several factors:
- Risk of Online Learning: Many domains (e.g., autonomous driving, robotics) make extensive online interaction with the environment too risky or costly.
- Difficulty in Reward Specification: Designing accurate reward functions that perfectly capture desired behavior is challenging. Poorly designed rewards can lead to unintended and dangerous actions.
- Safety Constraints: Real-world applications demand adherence to safety constraints, which are often difficult to quantify with precise per-timestep costs.
While imitation learning (IL) can learn from expert demonstrations, it often assumes these demonstrations are safe. However, in practice, it's often easier to collect trajectories that represent undesirable or unsafe behavior (termed "non-preferred trajectories") than to meticulously label every action with a safety cost. This paper addresses the challenge of learning safe and reward-maximizing policies offline using demonstrations that include both high-return (desirable) and non-preferred (unsafe) trajectories, without explicit safety cost labels.
Methods
OSIL tackles this problem by formulating it as a Constrained Markov Decision Process (CMDP). The core innovation lies in how it handles the lack of explicit reward and cost information:
- Inferring Safety from Non-Preferred Trajectories: Instead of explicit safety costs, OSIL learns a cost model that estimates the likelihood of a state-action pair being "non-preferred." This model is trained using a contrastive loss to ensure temporally adjacent states within a trajectory are represented similarly, and a preference-based loss to ensure non-preferred trajectories are assigned higher costs than union trajectories.
- Reformulating CMDP: OSIL derives a lower bound on the reward-maximizing objective and uses the learned cost model to approximate safety constraints. This allows it to optimize a reformulated CMDP problem.
- Adaptive Policy Learning: The learned cost action-value function is used to train a policy that balances safety and performance. This is achieved through a Lagrangian relaxation with an adaptive penalty coefficient, which dynamically adjusts the trade-off between imitating high-return behavior and adhering to safety constraints.
Datasets
The experiments were conducted using the Datasets for Offline Safe RL (DSRL) benchmark. This dataset includes:
- Velocity-constrained tasks: Walker-Velocity, Swimmer-Velocity, and Ant-Velocity.
- Navigation tasks: Point-Circle2, Point-Goal1, and Point-Button1.
The authors specifically used:
- Union Trajectory Dataset ($D_u$): A large collection of high-return trajectories with varying degrees of safety cost.
- Non-preferred Trajectory Dataset ($D_N$): A limited set of high-return, high-cost trajectories.
Crucially, the reward and cost annotations were removed from these datasets for the experiments, simulating the scenario where such labels are unavailable.
Key Insights and Ideas
- Safety from "Bad" Examples: The most significant insight is that unsafe behavior can be effectively learned from demonstrations of that unsafe behavior, even without explicit cost labels. This is a more practical approach than requiring precise safety cost annotations.
- Cost Model as a Safety Oracle: The learned cost model acts as a proxy for safety, allowing the agent to understand and avoid undesirable actions.
- Balancing Act: The adaptive penalty coefficient is crucial for balancing the desire for high performance (from imitation learning) with the necessity of safety.
- Contrastive Learning for Temporal Coherence: Using contrastive loss in the cost model helps capture local temporal correlations, leading to more robust safety inference.
Key Results
- Outperforming Baselines: OSIL consistently learned safer policies than existing state-of-the-art offline safe IL methods (BC-Union, DWBC, PPL, SafeDICE) across various tasks.
- Safety Without Performance Degradation: The learned policies satisfied cost constraints without significantly compromising reward performance. For instance, in one setting, OSIL achieved nearly 2.8x better performance than the best baseline.
- Robustness to Dataset Size: OSIL's performance degraded gracefully with smaller non-preferred datasets, but it still outperformed baselines.
- Significance of Contrastive Loss: Ablation studies showed that the contrastive loss component significantly contributed to learning lower-cost policies.
Limitations and Future Work
- Union Dataset Coverage: A key limitation is the assumption that the union dataset ($D_u$) contains a large number of high-return trajectories and has sufficient state coverage under the expert policy. If $D_u$ lacks coverage, the learned policy might diverge. Relaxing this requirement is a direction for future work.
- Non-preferred Dataset Diversity: The paper notes that if key undesirable behaviors are missing from the non-preferred dataset, the agent may fail to learn to avoid them.
- Human Bias: The reliance on human-provided demonstrations means OSIL can inherit human biases present in the data.
- Low-Reward Trajectories: The paper discusses the challenge of learning safe policies when low-reward trajectories are included in the non-preferred dataset, suggesting this is a complex scenario for future exploration.
Summary updated