DRIV-EX: Counterfactual Explanations for Driving LLMs
Organizations: Aptikal, Université Grenoble Alpes, Grenoble, France · Valeo.ai, Paris, France
Abstract
Large language models (LLMs) are increasingly used as reasoning engines in autonomous driving, yet their decision-making remains opaque. We propose to study their decision process through counterfactual explanations, which identify the minimal semantic changes to a scene description required to alter a driving plan. We introduce DRIV-EX, a method that leverages gradient-based optimization on continuous embeddings to identify the input shifts required to flip the model's decision. Crucially, to avoid the incoherent text typical of unconstrained continuous optimization, DRIV-EX uses these optimized embeddings solely as a semantic guide: they are used to bias a controlled decoding process that re-generates the original scene description. This approach effectively steers the generation toward the counterfactual target while guaranteeing the linguistic fluency, domain validity, and proximity to the original input, essential for interpretability. Evaluated using the LC-LLM planner on a textual transcription of the highD dataset, DRIV-EX generates valid, fluent counterfactuals more reliably than existing baselines. It successfully exposes latent biases and provides concrete insights to improve the robustness of LLM-based driving agents. The code is available at "https://github.com/Amaia-CARDIEL/DRIV_EX" .
Figures & tables
| Flip rate | Fluency | Similarity | Aggregation | ||||
| has top | Min | Template | BERTSc | Aggreg | Aggreg | ||
| Method | LLM | rank (%) | fluency | filter (%) | filter (%) | (%) | & col (%) |
| DAB | Llama3 | 100.0 | 9e-4 | 86.7 | 33.3 | 33.3 | 14.7 |
| ( Pynadath and Zhang, 2025 ) | Mistral | 91.8 | 6e-3 | 30.6 | 26.5 | 24.5 | 20.4 |
| Qwen2.5 | 98.9 | 2e-3 | 7.8 | 10.0 | 7.8 | 7.8 | |
| DAB | Llama3 | 46.7 | 5e-3 | 100.0 | 94.7 | 41.3 | 30.7 |
| Proximity | BERTSc | Aggreg | Aggreg |
|---|---|---|---|
| regularization | filter (%) | (%) | &Col(%) |
| (base, no reg) | 82.7 | 52.0 | 48.0 |
| + B (Bias) | 93.3 | 54.7 | 45.3 |
| + P (Proj) | 74.7 | 50.7 | 46.7 |
| + L (Loss) | 90.7 | 58.7 | 50.7 |
| + B + P + L | 96.0 | 61.3 | 56.0 |
| # of | Change | Token change (%) | ||
|---|---|---|---|---|
| Bias | data | type | Biased | Unbiased |
| Vehicle | 19 | any | 89.5 | 8.0 |
| revealing | 84.2 | / | ||
| Digit | 135 | any | 52.9 | 5.3 |
| revealing | 34.0 | / | ||
| Text | Classif (F1 ) | Traj (RMSE ) | #of | %of | ||
|---|---|---|---|---|---|---|
| modif | macro | micro | lon | lat | col | col |
| None | 0.93 | 0.93 | 0.68 | 0.40 | 753 | 3.1 |
| no | 0.92 | 0.92 | 0.48 | 0.51 | 736 | 3.1 |
| no | 0.90 | 0.90 | 1.33 | 0.55 | 631 | 2.6 |
Appendix figures & tables16 assets
Supplementary material from the paper’s appendix.
Appendix
| LLM | Data | Consistence (%) |
|---|---|---|
| Llama3 | GT val set | 99.8 |
| CF samples | 100.0 | |
| Mistral | GT val set | 99.7 |
| CF samples | 91.8 | |
| Qwen2.5 | GT val set | 99.9 |
| CF samples | 90.0 |
| LLM | Minimum fluency |
|---|---|
| Llama3-8B | |
| Mistral-7B | |
| Qwen2.5-7B |
| LC Classif (F1) | Traj (RMSE) | |||
|---|---|---|---|---|
| LLM | macro | micro | lon | lat |
| Llama2-13B | 0.971 | NA | 0.655 | 0.210 |
| Llama3-8B | 0.930 | 0.929 | 0.678 | 0.399 |
| Mistral-7B | 0.925 | 0.924 | 0.553 | 0.423 |
| Qwen2.5-7B | 0.932 | 0.932 | 0.510 | 0.402 |
| Flip | Templ | BERTSc | Aggreg | Aggreg | ||
|---|---|---|---|---|---|---|
| LLM | RF | rate | filt(%) | filt(%) | (%) | &col(%) |
| Llama | 64.0 | 88.0 | 96.0 | 61.3 | 56.0 | |
| 66.7 | 90.7 | 96.0 | 65.3 | 57.3 | ||
| Mistral | 83.7 | 79.6 | 95.9 | 69.4 | 61.2 | |
| 85.7 | 83.7 | 98.0 | 75.5 | 61.2 | ||
| Qwen | 58.9 | 47.8 | 73.3 | 34.4 | 22.2 |
| Train | Val | LC Classif | Maneuver eval | |
|---|---|---|---|---|
| bias | bias | F1 | Col% | Dis% |
| No | No | 0.91 | 3.5 | 1.6 |
| Yes | 0.95 | 3.4 | 1.8 | |
| Vehicle | No | 0.59 | 2.5 | 7.3 |
| Inv | 0.26 | 3.0 | 25.2 | |
| Yes | 0.99 | 3.2 | 1.7 | |
| LLM | Size | Count | Source | Target |
|---|---|---|---|---|
| Llama3 | 75 | keep lane | right lane | |
| keep lane | left lane | |||
| left lane | right lane | |||
| right lane | keep lane | |||
| Mistral | 49 | keep lane | right lane | |
| keep lane | left lane |
| Method | Hyperparameters | Evaluated range | Best value |
|---|---|---|---|
| PEZ | Learning rate ( ) | ||
| Loss regularization weight ( ) | 9 | ||
| PEZ | Loss regularization weight ( ) | 8 | |
| Proj ( ) | 25 | ||
| DAB | (S1) Temperature ( ) | ||
| (S1) Exploration cap ( ) | 250 |
Counterfactual Explanations
Counterfactual explanations show how changing an input could alter a model’s prediction, supporting model understanding, auditing, and actionable recourse.
See all 115 papers