[R] I built a “Safety Oracle” for L4 Autonomous Driving using Flow Matching (and why it’s better than standard Heuristics).

Hey r/MachineLearning,

I just finished a project/paper tackling one of the hardest problems in AV safety: The Long-Tail Problem.

Most safety filters rely on simple rules (e.g., “if brake > 5m/s2, then log”). These rules are brittle and miss 99% of “semantic” safety risks (erratic lane changes, non-normative geometry).

I wanted to see if we could automate this using Generative AI instead of manual rules.

The Approach:
I developed “Deep-Flow,” a framework that uses Optimal Transport Conditional Flow Matching (OT-CFM) to learn the probability density of expert human behavior.

https://preview.redd.it/s735u0dscnng1.jpg?width=2387&format=pjpg&auto=webp&s=16aa26f1ab0d93b2829a6876ddd49da964bcadad

  1. Spectral Bottleneck: Instead of predicting raw coordinates (which causes jitter), I projected trajectories into a 12-D PCA manifold. This forces the model to learn smooth “physics” rather than noisy points.
  2. Goal-Conditioned Flow: I injected the destination lane into the model so it understands intent (e.g., turning vs. straight) before predicting the path.
  3. Exact Likelihood Detection: Unlike Diffusion models, Flow Matching allows us to compute the exact Jacobian trace to get a deterministic anomaly score, making it SOTIF-ready for safety cases.

The Results:

  • AUC-ROC of 0.77 on the Waymo Open Motion Dataset.
  • The model successfully identified “Hidden Anomalies” (drivers cutting corners or performing unsafe lane merges) that were missed by standard kinematic filters.

Lessons Learned:
The most surprising takeaway was the “Predictability Gap.” Anomalies aren’t just “fast moving” cars; they are trajectories that “fight the flow” of the learned expert manifold.

I’ve open-sourced the training pipeline, the PCA basis, and the evaluation notebooks. Would love to hear your thoughts on how to further improve the manifold stability for complex roundabouts.

Link to Arxiv

Link to Arxiv Github

Happy to answer any questions about the implementation or the math behind the ODE integration!

submitted by /u/Pale_Location_373
[link] [comments]

Liked Liked