Abstract
When learning common skills like driving, beginners usually have domain experts standing by to ensure the safety of the learning process. We formulate such a learning scheme under the Expert-in-the-loop Reinforcement Learning (ERL) where a guardian is introduced to safeguard the exploration of the learning agent. While allowing sufficient exploration in the uncertain environment, the guardian intervenes under dangerous situations and demonstrates the correct actions to avoid potential accidents. Thus ERL enables both exploration and expert's partial demonstration as two training sources. Following such a setting, we develop a novel Expert Guided Policy Optimization (EGPO) method which integrates the guardian in the loop of reinforcement learning. The guardian is composed of an expert policy to generate demonstrations and a switch function to decide when to intervene. Particularly, a constrained optimization technique is used to tackle the trivial solution where the agent deliberately behaves dangerously to deceive the expert into taking over. Offline RL techniques are further used to learn from the partial demonstrations generated by the expert. Safe driving experiments show that our method achieves superior training and test-time safety, outperforms baselines with a substantial margin in sample efficiency, and preserves generalizability to unseen environments.
Introduction
Reinforcement Learning (RL) typically relies on a trial-and-error process to discover optimal policies. In safety-critical domains like autonomous driving, this exploration is inherently risky; an agent must encounter dangerous states to learn how to avoid them, yet experiencing these states in reality leads to catastrophic failures. Existing Safe RL methods often minimize expected costs but fail to prevent individual critical failures during training. Conversely, Imitation Learning (IL) provides safety but is limited by the expert's performance and poor generalization to out-of-distribution states.
Expert Guided Policy Optimization (EGPO) addresses this by introducing an "Expert-in-the-loop" framework. By placing a guardian between the agent and the environment, the system ensures that exploration remains safe while providing the agent with high-quality corrective demonstrations when it veers into danger.
Methodology
The Guardian Mechanism
The core of EGPO is the Guardian, which consists of a pre-trained expert policy $\mathcal{E}$ and a switch function $\mathcal{T}$. The switch monitors the agent's proposed action $a$ in state $s$. If the action is deemed "unreasonable"—falling outside a confidence threshold $\eta$ of the expert's action distribution—the guardian intervenes. It executes a safe action $\hat{a} \sim \mathcal{E}(\cdot|s)$ and records the transition as a partial demonstration.
Constrained Optimization and PID-Lagrangian
A significant challenge in ERL is the "deception problem," where the agent learns to intentionally drive dangerously to force the expert to take over and provide high rewards. To mitigate this, EGPO treats intervention frequency as a constraint. The authors utilize a Lagrangian multiplier to penalize takeovers, updated via a PID controller rather than standard dual gradient descent. This PID approach significantly stabilizes the training process by reducing the oscillations common in Lagrangian methods.
Learning from Partial Demonstrations
Because the expert's interventions are highly off-policy, EGPO incorporates Conservative Q-Learning (CQL). This offline RL technique allows the agent to learn effectively from the expert's "save" maneuvers, helping it understand how to recover from risky states without being misled by the distributional shift between its own exploration and the expert's demonstrations.
Experimental Evaluation
Setup
The method was evaluated using the MetaDrive simulator, featuring procedurally generated driving scenes with dense traffic and complex obstacles. The agent was trained on 100 unique scenes and tested on 50 unseen environments to evaluate generalization.
Key Results
- Training Safety: EGPO maintained near-zero episodic costs throughout the training process, whereas standard RL and Safe RL baselines (like CPO) suffered frequent crashes.
- Success Rate and Generalization: In test environments, EGPO achieved an 85% success rate, outperforming SAC with reward shaping (68%) and PPO-Lagrangian (43%). It also significantly outperformed pure Behavior Cloning (57%), which tended to drive overly conservatively.
- Sample Efficiency: In human-in-the-loop experiments, EGPO reached a 90% success rate in just 15,000 steps, while the best baseline required 185,000 steps to reach comparable performance.
Conclusion
EGPO demonstrates that integrating an expert guardian into the RL loop can bridge the gap between safe exploration and high-performance policy acquisition. By combining constrained optimization with offline RL, the framework ensures training-time safety while producing agents that generalize well to unseen, complex driving environments. Future work may focus on reducing sensitivity to the threshold hyperparameter $\eta$ and expanding the framework to broader robotic control tasks.
Summary updated