---
title: 'DRIV-EX: Counterfactuals in Autonomous Driving'
url: https://www.emergentmind.com/topics/driv-ex
type: topic
---

# DRIV-EX: Counterfactuals in Autonomous Driving

Searching arXiv for the DRIV-EX paper and closely related autonomous-driving explainability work.
DRIV-EX is a counterfactual-explanation method for LLM-based driving planners that identifies the smallest semantic change to a driving scene description required to alter a planner’s decision, typically by crossing a decision boundary between safe and dangerous maneuvers. It was introduced for autonomous-driving settings in which a language model takes a structured textual scene description and generates a lane-change intention together with a trajectory. Rather than relying on free-form rationales, DRIV-EX searches for counterfactual scene edits that are close to the original input but sufficient to flip a key semantic decision token, and then reconstructs the result through controlled decoding so that the final explanation remains fluent, domain-valid, and near the source description [2603.00696].

## 1. Definition and problem formulation

DRIV-EX studies the interpretability of autonomous-driving LLMs through counterfactual explanations. In its primary setting, the target model is **LC-LLM**, a **LoRA-finetuned planner** trained on the **textual highD dataset**, where each sample is a rigid template describing the ego vehicle and surrounding traffic in terms of vehicle type, speeds, accelerations, positions, and the resulting maneuver and future trajectory [2603.00696].

The method is formulated around a safety-critical case: scenarios where the **ground-truth scene is dangerous**—defined as a **collision within 4 seconds at constant velocity**—but the model nevertheless predicts a **safe** maneuver. The objective is to find a modified input $\mathbf{x}$ that stays as close as possible to the original scene description $\mathbf{x}^o$ while forcing a target decision $y_T^*$ at a key semantic decoding step $T$:

$$
\begin{aligned}
& \underset{\mathbf{x} \in V^m}{\arg\min} & & c(\mathbf{x}^o, \mathbf{x}) \\
& \text{s.t.} & & y^*_T = \underset{z\in V}{\arg\max} \; P_{\mathcal{M}(z \mid \mathbf{y}_{<T}, \mathbf{x})}.
\end{aligned}
$$

In this formulation, $c(\mathbf{x}^o,\mathbf{x})$ trades off proximity and fluency, $\mathcal{M}$ is the autoregressive driving model, and the decision is taken at a **semantic step** rather than a fixed token index. The paper argues that, in the rigid driving-template setting, changing the first critical decision token is usually sufficient to redirect the rest of the generation.

This positions DRIV-EX as a local interpretability method. It does not attempt to provide a global theory of model behavior; instead, it asks a sharply defined instance-level question: what minimally changed scene description would make the planner choose differently?

## 2. Continuous counterfactual search and controlled decoding

The central design choice in DRIV-EX is to **decouple counterfactual search from counterfactual generation**. The method uses gradient-based optimization in continuous embedding space to discover the semantic direction that changes the model’s decision, but it does not treat the resulting optimized embeddings as final explanations. Instead, those embeddings guide a controlled autoregressive decoding process that reconstructs a valid textual counterfactual [2603.00696].

The search begins with a sequence of **soft embeddings**

$$
\mathbf{e} = (\mathbf{e}_1, \dots, \mathbf{e}_m) \in \mathbb{R}^{m \times d},
$$

initialized from the original scene description. At each iteration, each soft embedding is projected to the nearest vocabulary embedding by cosine similarity:

$$
\mathbf{x}_i = \text{Proj}_E(\mathbf{e_i}) := \arg\max_{\mathbf{v} \in E} \frac{\mathbf{e}_i \cdot \mathbf{v}}{\|\mathbf{e}_i\|\|\mathbf{v}\|}.
$$

The projected input is then evaluated by the driving LLM with a **decision loss** that increases the probability of the target token:

$$
\mathcal{L}_{\text{dec}}(\mathbf{x}) = - \log P_{\mathcal{M}(y^*_T \mid \mathbf{y}_{<T}, \mathbf{x})}.
$$

Because the projection step is non-differentiable, DRIV-EX uses a **straight-through estimator** and updates the underlying soft embeddings with Adam:

$$
\mathbf{e} \leftarrow \text{Adam}\!\left(\mathbf{e}, \nabla_{\mathbf{x}} \mathcal{L}_{\text{dec}}, \eta \right).
$$

This repeated project-forward, backward, and update cycle searches for an embedding configuration that makes the target decision likely. The distinctive contribution lies in what happens next. Rather than outputting the projected optimized tokens directly, DRIV-EX instantiates a fluency model $\mathcal{F}$ as the base model of $\mathcal{M}$ without the instruction-tuned adapter, thereby preserving tokenizer and embedding-space compatibility. For each position $i$, it computes a vocabulary-distance penalty

$$
b_{i,v} = \lVert \mathbf{v} - \text{Proj}_E(\mathbf{e_i}) \rVert_2^2,
$$

rescales it with

$$
r_i = \lVert \mathbf{l}_i \rVert_2 / \lVert b_i \rVert_2,
$$

and forms a decoding bias

$$
\mathcal{B}_{i,v} = - w \cdot r_i \cdot b_{i,v}.
$$

Greedy decoding then selects

$$
x_i = \arg\max_{v \in \mathcal{V}} \left( l_{i,v} + \mathcal{B}_{i,v} \right).
$$

The paper’s claim is that this controlled decoding preserves fluency because the base-model logits remain active, while the bias steers generation toward the optimized semantic direction. This suggests that DRIV-EX treats continuous optimization as a semantic probe rather than as a direct text generator.

## 3. Proximity preservation, candidate selection, and task constraints

DRIV-EX explicitly constrains counterfactuals to remain close to the original scene description. It does so through three complementary mechanisms [2603.00696].

The first mechanism, **Proj**, restricts projection candidates to the top-$K$ nearest neighbors of the original tokens in cosine similarity. The second, **Loss**, adds a semantic similarity penalty to the optimization objective:

$$
1 - \frac{1}{m}\sum_{i=1}^{m}\cos\!\left(\mathbf{x}_i,\mathbf{x}^o_i\right),
$$

weighted by $\lambda$. The third, **Bias**, adds a second decoding bias term $\mathcal{B}'$ computed relative to the original input $\mathbf{x}^o$, yielding

$$
x_i = \arg\max_{v \in \mathcal{V}} \left( l_{i,v} + \mathcal{B}_{i,v} + \mathcal{B}'_{i,v} \right).
$$

These mechanisms are intended to preserve semantic fidelity while still allowing decision-flipping edits. The method applies counterfactual search only to **variable template fields** such as vehicle type, speeds, positions, and accelerations, rather than to arbitrary parts of the prompt. This restriction keeps the search space aligned with semantically meaningful driving-scene attributes.

After $N$ iterations, DRIV-EX keeps a pool of candidates. If any candidate flips the decision, it returns the one with the highest semantic proximity to the original input; otherwise, it returns the candidate with the highest target-token probability. The paper also describes an **optional refinement step** in which modified token groups are reverted one by one to test whether the counterfactual still succeeds. In the reported **Llama3** results, refinement slightly improves performance.

This architecture reflects a specific interpretability criterion: a useful driving counterfactual should not merely be adversarially effective, but also structurally valid and semantically local. In the paper’s terms, counterfactual quality is inseparable from **linguistic fluency**, **domain validity**, and **proximity to the original input**.

## 4. Evaluation protocol, baselines, and quantitative results

The evaluation compares DRIV-EX against **DAB** and **PEZ**, together with proximity-regularized variants marked with $\dagger$. The reported metrics are tightly matched to the counterfactual task: **Decision (P@1)**, **Template fitness**, **Minimum fluency**, **BERTScore**, **Aggregated success rate**, and **Aggregated collision rate**. The **Aggregated success rate** requires all of the following simultaneously: the decision must flip, the output must remain template-valid, and the **BERTScore** must be at least **0.95** [2603.00696].

On the main safety-critical highD subsets, DRIV-EX is reported as the strongest method under this strict aggregated criterion. For **Llama3**, the paper reports: **Decision 64.0%**, **min fluency $1\times10^{-3}$**, **temp fitness 99.5%**, **BERTScore 98.3%**, **Aggregated 61.3%**, and **collision subset 56.0%**. For the same model family, **PEZ** reaches **Aggregated 45.3%**. For **Mistral**, DRIV-EX reaches **Decision 83.7%**, **Aggregated 69.4%**, and **collision subset 61.2%**. For **Qwen2.5**, it reaches **Decision 58.9%**, **Aggregated 34.4%**, and **collision subset 22.2%**.

The paper emphasizes a consistent tradeoff pattern. **DAB** can flip decisions aggressively but often degrades semantic closeness. **PEZ** tends to remain nearer to the original prompt but struggles with fluency and structural validity. DRIV-EX is reported to balance these criteria more effectively because its fluency model steers search outputs back into valid text.

The ablation on proximity regularization further supports that interpretation. On **Llama3**, the paper reports: **base method: Aggregated 52.0%, collision 48.0%**; **+ Bias: 54.7%**; **+ Proj: 50.7%**; **+ Loss: 58.7%**; and **+ Bias + Proj + Loss: 61.3%, collision 56.0%**. The stated conclusion is that the three regularizers are synergistic rather than redundant.

## 5. Qualitative findings, exposed biases, and robustness implications

The qualitative analysis presents DRIV-EX as a tool for isolating **minimal, semantically meaningful changes** that alter the planner’s output. Reported examples include slightly adjusting vehicle speed, changing the ego vehicle type from **car** to **truck**, modifying lateral velocity $v_y$, and changing a nearby vehicle’s speed by only a few km/h. One example shows that decreasing a surrounding vehicle’s speed and adjusting the ego vehicle’s longitudinal speed is sufficient to turn a safe plan into a collision-inducing one [2603.00696].

The paper argues that such counterfactuals expose **latent biases** in the driving LLM. Two categories are highlighted. First, **injected shortcut biases** can be recovered: in one experiment, the model learns to associate ego vehicle type with decision; in another, it relies on the last digit of nearby vehicles’ speeds. DRIV-EX identifies these shortcut features. Second, the method reveals **real dataset bias**: for **Llama3** on textual highD, high negative lateral velocity $v_y$ is found to strongly push the model toward a right-lane-change decision even when that decision causes a collision.

These findings are used to motivate debiasing experiments. The paper reports that removing lateral kinematic features, or removing all kinematic features from the text template, reduces collisions. The reported pattern is: **Baseline** has good F1 but more collisions; **No $v_y, a_y$** yields similar classification performance with fewer collisions; **No $v, a$** yields fewer collisions still, but with more trajectory error. A plausible implication is that DRIV-EX can function as a diagnostic instrument for feature-level safety auditing, especially when an LLM planner over-relies on shortcut correlations that are predictive in-distribution but unsafe under counterfactual perturbation.

The method’s explanatory force therefore lies less in post-hoc narration than in boundary tracing. By identifying which semantic edits are sufficient to change a decision, it reveals which parts of the input the planner is actually using.

## 6. Scope, limitations, and nomenclatural disambiguation

DRIV-EX is explicitly limited to **textual inputs**, **white-box** access, and **fixed input length**; it does not insert or delete tokens. Its evaluation is confined to the **textual highD dataset** and its rigid template format, and the method is computationally expensive because it combines gradient optimization with autoregressive decoding. It is also described as a **local interpretability** method rather than a source of global explanations. The paper further notes a dual-use risk: the same mechanism that helps audit safety can also generate adversarial corner cases [2603.00696].

Within the autonomous-driving literature, the name is easily confused with several adjacent systems. **DriveX** is a self-supervised world model for generalizable scene knowledge and **Omni Scene Modeling**, not a counterfactual explanation method [2505.19239]. **DRIVE** has also been used for **Dynamic Rule Inference and Verified Evaluation**, a framework for learning soft driving constraints and embedding them into convex planning [2508.04066], and for **Dependable Robust Interpretable Visionary Ensemble**, a robustness framework for concept-based explanation in the **DCG** model [2409.10330]. In a separate just-in-time explanation setting, **DriCon** characterizes unexpected driving events on a dashboard-mounted edge device using a **Self-Organizing Map**, maneuver features, and spatial micro-events [2301.05277]. These systems share a concern with interpretability or generalizable driving knowledge, but they address different objects: world modeling, rule inference, dependable concept explanations, edge explanation of unexpected events, and counterfactual explanation for driving LLMs.

In that taxonomy, DRIV-EX occupies a specific niche. It is a counterfactual method for textual autonomous-driving planners that combines continuous embedding-space search with controlled decoding to produce fluent, template-valid, semantically local decision-flipping scene edits. Its reported value lies in revealing model sensitivities, uncovering latent shortcut biases, and suggesting targeted changes to input representation for safer LLM-based driving systems.

Source: https://www.emergentmind.com/topics/driv-ex