Manuscript Offprint

arXiv:2610.22618

Trajectory-Guided Steering: Mitigating Spurious Feature Bias in Clinical Classification

Fardin Ahsan Sakib, Ziwei Zhu, Ozlem Uzuner

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Large language models rely on spurious features in clinical classification: swapping a single gender token in clinical notes alters gender-irrelevant diagnoses in up to 53.5% of cases. Existing inference-time corrections either need counterfactual data built around the specific spurious feature or behave unpredictably. We observe that how a model's preference between answers evolves across layers, its prediction trajectory, indicates for each document whether a correction is likely to help. We propose Trajectory-Guided Steering (TGS), which decides from the trajectory alone whether to correct each prediction and in which direction, with no counterfactual data and no knowledge of the spurious feature. On 16 clinical classification tasks from i2b2, TGS fixes 17.7% of errors while breaking only 1.3% of correct predictions and stays net-positive across all tested hyperparameter settings; all baselines are net-negative or near zero. The same corrections reduce reliance on the spurious feature: on the most affected diseases, gender-swap inconsistency falls sharply (hypertension 53.5%→38.0%, diabetes 35.1%→21.5%). Applying the correction to every document instead raises breaks on correct positive predictions from 0.1% to 6.4%, so per-document selection is essential. TGS also transfers to three model families and three other clinical and biomedical datasets.

1 Introduction

Large language models are increasingly applied to clinical NLP tasks such as screening, triage, and diagnostic support. Yet their predictions can depend on spurious features, aspects of the input irrelevant to the clinical question. This is documented in clinical use: changing only a patient's gender or race affects GPT-4's ability to rank the correct diagnosis first in 37% of cases (Zack et al., 2024), LLMs repeat race-based medical misconceptions (Omiye et al., 2023), and they infer drug use from mentions of alcohol or smoking (Sakib et al., 2025). Consider a discharge summary documenting Type 2 diabetes with multiple insulin prescriptions: with identical symptoms and medications, the model's predicted diagnosis flips from positive to negative when only the gender word changes, even though gender carries no diagnostic information for this disease. Such reliance makes the model's predictions untrustworthy: they can change with information that has no bearing on the diagnosis. To quantify it, we swap a single gender token across 16 diseases for which gender is diagnostically irrelevant, holding all clinical evidence constant. Because the evidence alone determines the correct answer, any change in prediction is an error; this inconsistency occurs in 9.7% to 53.5% of cases (Appendix B).

Existing ways to reduce reliance on spurious features are costly. Training-time methods such as invariant or domain-adversarial learning require retraining, often with labels for the feature or for distinct environments (Arjovsky et al., 2020; Ganin et al., 2016). Inference-time methods avoid retraining, but prompt changes have unpredictable effects, and activation steering (e.g., CAA (Rimsky et al., 2024), FairSteer (Li et al., 2025)) or editing demographic information inside the model (Ahsan et al., 2025) needs counterfactual training pairs or knowledge of which feature drives the errors.

Clinical settings rarely provide either. Records are restricted by data use agreements (Agrawal et al., 2022), counterfactual data requires expert annotation, and the features that sway a model are rarely known in advance. A correction must also be selective, because changing a correct clinical prediction is itself a harm. Clinical classification therefore needs a correction that works at inference time, uses no additional data, and leaves correct predictions intact.

We propose Trajectory-Guided Steering (TGS), which decides from the model’s own forward pass

Figure

Figure 1: Overview of Trajectory-Guided Steering (TGS). Before generating, TGS reads which answer the model prefers at each layer and how strongly, giving a prediction trajectory. Comparing an early and a late layer, it finds whether the preference strengthens, stays flat, or changes between the two. Based on this shape, TGS pushes toward the early preference, pushes against it, or keeps the original answer, by shifting the two answer-token logits during generation.

whether and how to correct each prediction. Using the logit lens (nostalgebraist, 2020), which projects each layer's hidden state through the unembedding matrix, TGS tracks the model's preference between the answer tokens across layers; we call this curve the prediction trajectory. Its shape, whether early and late layers agree and whether the preference strengthens, indicates when a correction is safe and in which direction. When it is, a second forward pass adjusts the logits of the answer tokens toward the direction the trajectory supports; otherwise, the prediction is left unchanged. TGS needs no counterfactual data and no knowledge of the spurious feature. Empirically, these corrections also reduce the model's reliance on the gender token.

On the i2b2 clinical benchmark (Uzuner, 2009), TGS fixes 17.7% of prediction errors while breaking only 1.3% of correct predictions. Its net gain exceeds that of every baseline. The same corrections reduce gender-swap inconsistency, most on the diseases where gender sways the model most (e.g., hypertension 53.5%→38.0%). TGS also transfers to three model families and three other clinical and biomedical datasets. Figure 1 provides an overview. Our contributions are threefold. (1) A new signal for correction: we show that logit-lens trajectory shape distinguishes correctable errors from predictions that should be left untouched, turning a layer-wise readout of the model's predictions into a control signal. (2) Selective, per-document correction from the model's own forward pass: unlike activation steering (CAA, FairSteer), TGS needs neither counterfactual data nor knowledge of the spurious feature. (3) Robust net-positive performance that baselines do not achieve: TGS is net-positive across three model families and four clinical and biomedical datasets, and on i2b2 steering and prompting baselines are net-negative or near zero; an ablation shows that per-document selection is essential for preserving correct predictions.

References (35)