RAIL: Representation-Aligned Imitation Learning for Student-Compatible Teacher Policies

Meraj Mammadov, Pedro Zuidberg Dos Martires, Johannes A. StorkNeurIPS 2026

TL;DR

In reinforcement learning, it is common to train an omniscient "teacher" agent using privileged simulator data, and then have a "student" agent imitate it using only raw, limited sensor inputs. However, when a teacher relies on secret knowledge the student cannot possibly perceive, the student is doomed to fail. Representation-Aligned Imitation Learning (RAIL) solves this at the root by constraining the teacher to think and act only within a shared mental space containing information accessible to both agents, enabling seamless zero-shot policy transfer.

What Problem Does This Paper Address?

Teaching a robot or virtual agent directly from raw camera pixels or limited onboard sensors is notoriously slow and brittle. To bypass this, researchers often use a "learning by cheating" paradigm: first, train a teacher policy with full, privileged access to the environment's ground-truth state (e.g., exact map layouts and target coordinates), and then distill its behavior into a student policy that only sees deployment-ready inputs (e.g., a narrow camera feed).

There is a catch: information asymmetry. Suppose a teacher knows a goal is around a blind corner, so it walks straight toward it. A student with a forward-facing camera needs to actively look around to find that same goal. If the student blindly copies the teacher, it fails to gather the information it needs—creating an irreducible imitation gap.

Observation mismatch in TunnelVision: A privileged teacher (blue) sees all surrounding cells and moves directly, whereas the student (orange) only sees three cells ahead and must actively turn to spot obstacles.

Traditionally, researchers patch this after training the teacher—either by delicately reshaping rewards or running expensive reinforcement learning (RL) fine-tuning on the student. RAIL asks a cleaner question: instead of fixing a confused student afterward, why not stop the teacher from using unrecoverable private secrets in the first place?

Methods

RAIL builds a shared latent representation (an "embedding space") during the teacher's RL training loop and trains a single, shared policy network directly on top of it. At deployment, you simply swap out the teacher’s observation encoder for the student’s—no student fine-tuning required.

While RAIL uses standard Proximal Policy Optimization (PPO) for policy updates, its core novelty lies in an inner representation-learning loop driven by four mechanisms:

  • Contrastive Learning (InfoNCE): Paired teacher and student observations from the exact same moment in time are pulled together in the latent space, while observations from different states are pushed apart. This isolates overlapping information and filters out private teacher secrets.
  • Pairwise Alignment Loss: Contrastive learning enforces relative similarity, leaving tiny mathematical gaps between paired embeddings that can throw off sensitive RL policies. RAIL adds an explicit cosine-similarity objective to snap paired teacher–student embeddings into near-identical alignment.
  • Stability Regularization: Because the encoders update continuously alongside the policy, the policy’s input distribution constantly shifts. RAIL penalizes encoder updates that cause sudden jumps in the policy's output logits relative to a frozen reference copy.
  • Gradient Blocking: Crucially, RL policy gradients are blocked from flowing backward into the encoders. If allowed through, the RL optimizer immediately cheats by smuggling privileged teacher data back into the latent space.

Datasets

Because this is an online RL framework rather than offline learning on static datasets, RAIL is trained and evaluated across four asymmetric simulation environments introducing distinct imitation gaps:

Summary of the four simulation environments—Corners, TunnelVision, CollectHealth, and QuarterCheetah—detailing their observation spaces and specific imitation gaps.
  • Corners & TunnelVision: Grid-world navigation tasks where the teacher knows target identities or full 360° obstacle layouts, while the student must systematically explore corners or rotate its narrow field of view.
  • CollectHealth: A 3D room where the teacher gets exact coordinates of health kits, while the student relies on a stack of 5 limited-FOV first-person RGB frames.
  • QuarterCheetah: A continuous-control locomotion benchmark where the teacher gets full 17D joint positions and velocities, while the student only sees a third-person camera image with the left half completely blacked out.

Key Insights and Ideas

  • Stop RL gradients at the gate: In ablation studies, allowing RL gradients to update the encoders ("end-to-end") caused the student's success rate in TunnelVision to collapse from 1.00 to 0.18, even though the teacher scored 0.99. Blocking policy gradients is essential to keep private teacher data out of the shared space.
  • The representation actually forgets secrets: When the authors trained a probe network to guess the hidden target corner from RAIL's frozen teacher embeddings in Corners, it achieved 25.4% accuracy—statistically indistinguishable from a blind 25% coin-flip—while predicting shared agent coordinates at 100% accuracy.
  • Better than learning from scratch: Decoupling visual representation learning from policy optimization allows RAIL's student to learn faster and reach higher returns than an RL agent trained directly on student pixels—even though the direct RL agent gets environment rewards and RAIL's student does not.
  • Reusable world models for zero-shot transfer: Once encoders are trained on one task, you can freeze them, train a brand-new policy on a different task (e.g., collecting a new object class) using only fast teacher observations, and zero-shot deploy it onto the visual student without collecting a single new image.

Key Results

RAIL achieves the highest student performance ($S$) and smallest imitation gap ($\Delta = T - S$) across every benchmark, without reward hacking or post-hoc student RL:

Figure 3: Student evaluation curves for CollectHealth and QuarterCheetah. CollectHealth reports success rate, while QuarterCheetah reports episodic return. BC and DAgger are shown as horizontal lines corresponding to their final student performance.
  • Grid Worlds (Corners & TunnelVision): RAIL achieves a 1.00 success rate with a 0.00 imitation gap in both tasks. Standard Behavior Cloning (BC) and DAgger peak between 0.12 and 0.38.
  • 3D Vision (CollectHealth): RAIL hits a 0.98 success rate ($\Delta = 0.01$), beating DAgger (0.84), joint-training baseline SITT (0.49), and direct pixel-based Student RL (0.78).
  • Continuous Control (QuarterCheetah): RAIL achieves an episodic return of 2510.24 (vs. teacher's 2627.67), crushing BC (-268.17), DAgger (-484.25), SITT (721.12, where strict imitation penalties dragged the teacher down to 962.67), and direct Student RL (1824.27).

Limitations and Future Work

  • Strict temporal alignment required: RAIL assumes you can record synchronized pairs of $(o^T_t, o^S_t)$ from the exact same underlying simulation state. This is standard in simulation, but breaks down if teacher and student trajectories are collected independently or asynchronously.
  • No formal theoretical guarantees: While gradient blocking, alignment, and stability losses empirically shrink the imitation gap to near zero, the paper notes it does not provide a mathematical proof guaranteeing 100% policy realizability under all possible student observation spaces.
  • Same-environment transfer: Zero-shot task transfer was demonstrated within the same visual environments and observation manifolds; extending this to cross-domain visual shifts remains open territory.

Summary updated

Abstract

Reinforcement learning (RL) from raw sensory inputs such as images or onboard sensors can be challenging due to high-dimensional observations and sparse rewards. A common strategy is to train a teacher policy with access to privileged state information and then distill it into a student policy that acts from raw inputs alone. However, when the teacher relies on information unavailable to the student, exact imitation may be impossible, creating an irreducible imitation gap. Existing approaches typically mitigate this mismatch through careful reward shaping or additional reinforcement learning on the student policy after the teacher has been trained. Instead, we introduce Representation-Aligned Imitation Learning (RAIL), which addresses the mismatch during teacher training itself. RAIL learns a latent representation shared across teacher and student observations using contrastive learning, and trains the teacher policy directly in this space. Because the teacher policy is constrained to operate on this shared space, it learns behaviors that are reproducible from student observations. This substantially reduces the imitation gap while preserving task performance. Across multiple environments, RAIL outperforms strong baselines without reward modification or post-hoc student fine-tuning, and surpasses direct reinforcement learning from raw observations. The learned representations further enable zero-shot transfer to new tasks through teacher-only training. Implementation and more at https://merajmammadov.com/rail/.
BibTeX
@inproceedings{mammadov2026rail,
  author = {Meraj Mammadov and Pedro Zuidberg Dos Martires and Johannes A. Stork},
  title = {{RAIL: Representation-Aligned Imitation Learning for Student-Compatible Teacher Policies}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=DEj92qDbTo},
}
Figure