← Latest papers
🤖 machine learning

Lyapunov-Guided Self-Alignment: Test-Time Adaptation for Offline Safe Reinforcement Learning

This paper introduces SAS, a transformer-based framework that enables test-time adaptation for offline safe reinforcement learning by generating and selecting Lyapunov-compliant imagined trajectories as in-context prompts to realign agent behavior toward safety without retraining.

Original authors: Seungyub Han, Hyungjin Kim, Jungwoo Lee

Published 2026-04-30
📖 5 min read🧠 Deep dive

Original authors: Seungyub Han, Hyungjin Kim, Jungwoo Lee

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you hire a highly skilled robot driver who learned to drive by watching thousands of hours of expert driving videos. This robot is great at following the road, but it has a problem: it was trained in a perfect, sunny simulation. When you finally put it on a real road with unexpected rain, potholes, or a sudden detour, the robot panics. It tries to apply its old rules to a new situation and might drive straight into a wall or a ditch.

This is the core problem the paper addresses: Offline Reinforcement Learning (RL). It's like training a robot on a massive dataset of past experiences without letting it practice in the real world. When the real world changes slightly, the robot becomes unsafe.

The authors propose a solution called SAS (Self-Alignment for Safety). Think of SAS not as a new teacher, but as a safety coach that talks to the robot right before it starts driving.

Here is how SAS works, broken down into simple concepts:

1. The "Imagination" Phase

Before the robot takes a single real step, SAS asks it to imagine several different ways it could drive the next few seconds.

  • The Metaphor: Imagine you are about to cross a busy street. Before you step out, you quickly imagine three scenarios: "If I walk left, I might hit a car," "If I walk right, I might trip," and "If I walk straight, I'm safe."
  • The Tech: The robot uses its internal "world model" (a mental map of how the world works) to generate these imaginary paths, or "rollouts."

2. The "Lyapunov" Safety Check

How does the robot know which imagined path is safe? It uses a mathematical tool called a Lyapunov function.

  • The Metaphor: Think of the robot's safety as a ball rolling down a hill. A "Lyapunov" check is like a sensor that ensures the ball is always rolling down toward a safe valley (the goal) and never rolling up toward a cliff (danger).
  • The Tech: The paper defines a "safety score" based on how often the robot has seen similar situations in its training data. If an imagined path leads to a place the robot has never seen before (a "low-density" area), the safety score drops, and the path is flagged as dangerous. The robot checks: "Does this path keep the safety score going down (or staying safe)?"

3. The "Self-Alignment" (The Magic Trick)

This is the most unique part. Usually, to fix a robot, you have to retrain it from scratch, which takes a lot of time and data. SAS does something smarter: It uses the robot's own imagination to correct itself.

  • The Metaphor: Imagine the robot is about to drive. Instead of retraining it, SAS says: "Hey, look at these three imaginary paths you just made. Two of them hit a wall. One of them is safe. Let's pretend that safe path is a hint or a prompt."
  • The robot then takes that safe imaginary path and feeds it back into its own brain as a "demonstration." It's like the robot saying, "Okay, I see the safe way now. I will follow this specific example."
  • The Result: The robot aligns its behavior to be safe without changing its underlying code or weights. It's a "self-correction" using a prompt, similar to how you might ask a smart AI, "Here is a safe example, now do the same," without needing to retrain the AI.

4. The "Hierarchical" Brain

The paper explains that the robot's brain (a Transformer model) works like a two-level manager.

  • The Metaphor: There is a Boss (high-level policy) who decides the general strategy (e.g., "Go to the goal"), and a Worker (low-level policy) who actually moves the wheels.
  • The Tech: SAS acts as the Boss. By feeding the safe "imagined" path as a prompt, SAS is essentially whispering a new instruction to the Boss: "For this specific situation, the strategy should be 'follow this safe path'." This allows the robot to adapt instantly to new hazards.

What Did They Find?

The authors tested this on various robot simulations (like moving a car, a point, or a drone through obstacles).

  • The Outcome: Robots using SAS made significantly fewer mistakes and crashed less often than robots that just used their original training.
  • The Bonus: They didn't sacrifice performance. The robots were still fast and reached their goals, but they did so much more safely.
  • The Key Takeaway: SAS allows a robot trained on old data to adapt to new, dangerous situations instantly by using its own "imagination" to find a safe path and then following that path as a rule.

Summary

SAS is like a safety net made of the robot's own thoughts. Instead of forcing the robot to learn new rules (which is slow and hard), SAS asks the robot to imagine the future, pick the safest version of that future, and then use that safe version as a guide for what to do right now. It turns "what if" into "what to do," keeping the robot safe without needing a single second of retraining.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →