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.
Figures & tables
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.
Figure 2: Three trajectory shapes on i2b2 (LLaMA 3.1 8B), each implying a different safe action. The y-axis shows the direction-aligned logit margin: the difference between the logit values of the two answer tokens, oriented so that the model’s preferred direction points upward. Thin lines: individual documents; thick line with markers: group mean. Blue solid: correct predictions; red dashed: incorrect predictions. Panel A : Growing conviction (reinforce). Correct and incorrect follow nearly identical trajectories. Panel B : Static conviction (oppose). Incorrect predictions fail to accumulate the conviction growth seen in correct predictions. Panel C : Internal conflict (leave unchanged). Correct and incorrect are fully indistinguishable.
Method
Train
Net ↑
Fix% ↑
Break% ↓
Full test set
TGS (ours)
none
+201
17.7
1.3
Prompt: clinical
none
− 126
12.9
2.8
Prompt: objective
none
− 83
20.5
3.6
Prompt: CoT
none
− 6206
35.7
47.5
Same ∼ 70% subset (CAA/FairSteer reserve 30% to train)
Table 1: Baseline comparison on i2b2 (LLaMA, 16 diseases). Each block compares methods on identical data: the full test set (top) and the ∼ 70% subset left after CAA/FairSteer reserve 30% for training (bottom). TGS reserves no training data yet is net-positive in both blocks, while baselines are net-negative or only marginally positive. Net ↑ = errors fixed minus correct predictions broken; Fix%/Break% are rates. TGS (held-out): α and τ selected on the 30% split (Section 5.3 ).
Figure 3: Fix rate vs. break rate tradeoff on i2b2 (LLaMA, 16 diseases). The green upper-left region is preferable: it combines high error correction (fix rate) with little damage to correct predictions (break rate); points above the dashed net-zero line are net-positive. TGS’s fix–break curve (blue, varying α from 0.1 to 1.0) lies entirely in this region, and the starred point marks our reported configuration ( α=0.5 , τ=0.5 ). Baselines cluster near zero fix rate (CAA, labeled by its steering multiplier m ) or cross into net-negative territory at higher strengths (FairSteer, prompts). CoT (off-chart) achieves 35.7% fix rate but at 47.5% break rate.
Model
Dataset
Net
Fix%
Break%
LLaMA
i2b2
+201
17.7
1.3
Mistral
i2b2
+178
8.5
0.2
Qwen3
i2b2
+414
22.3
0.2
LLaMA
SHAC
+42
78.9
2.7
LLaMA
PubMedQA
+35
34.5
4.9
LLaMA
n2c2 2018
+51
6.6
1.2
Table 2: Generalization across models and datasets. All results are net-positive. Top: cross-model on i2b2. Bottom: cross-dataset with LLaMA.
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
Disease
Docs
Differ
%
Hypertension
531
284
53.5
Heart Failure
243
92
37.9
Diabetes
572
201
35.1
ASCVD
552
194
35.1
Venous Insufficiency
526
159
30.2
Depression
582
172
29.6
Appendix
Table 3: Prediction inconsistency rates across 16 i2b2 diseases. Each document is prompted under both male and female gender conditions; Differ counts cases where the prediction changes. Sorted by inconsistency rate.
Disease
Docs
Before %
After %
Δ pp
Hypertension
531
53.5
38.0
− 15.5
Diabetes
567
35.1
21.5
− 13.6
Heart Failure
243
37.9
28.0
− 9.9
Hypercholesterolemia
502
27.5
19.3
− 8.2
Obesity
553
24.6
17.2
− 7.4
ASCVD
548
34.9
30.1
− 4.8
Appendix
Table 4: Prediction inconsistency before and after TGS. Sorted by improvement ( Δ pp). TGS reduces inconsistency in 14/16 diseases, with an overall reduction from 25.1% to 21.5%.
Disease
Net
Fix%
Break%
Diabetes
+77
39.3
0.2
Hypertension
+75
27.3
0.7
Obesity
+41
30.9
0.2
Hypercholesterolemia
+39
28.2
0.6
Heart Failure
+22
27.5
0.0
GERD
+18
14.5
0.1
Appendix
Table 5: Per-disease results for TGS on i2b2 (LLaMA, α=0.5 , τ=0.5 ). Fix% and Break% are computed over all error types and all correct predictions, respectively.
Net
Fix%
Break%
α sensitivity ( τ=0.5 fixed)
α=0.25
+114
8.6
0.5
α=0.50
+201
17.7
1.3
α=0.75
+174
24.5
2.5
α=1.00
+21
29.7
4.3
τ sensitivity ( α=0.5 fixed)
Appendix
Table 6: Sensitivity analysis (LLaMA, i2b2, 16 diseases). α controls the fix–break tradeoff; performance is robust to τ within its tested range.
τ
α
0.25
0.50
0.75
1.00
0.25
− 32
− 32
− 32
− 32
0.50
− 3
− 3
− 3
− 3
0.75
+21
+33
+40
+40
1.00
+21
+33
+42
+40
Appendix
Table 7: Net gain across α×τ configurations on SHAC (LLaMA). Bold: reported configuration ( α=1.0 , τ=0.75 ).
τ
α
0.25
0.50
0.75
1.00
0.25
+6
+6
+6
+6
0.50
+17
+17
+17
+17
0.75
+26
+30
+32
+32
1.00
+26
+29
+35
+33
Appendix
Table 8: Net gain across α×τ configurations on PubMedQA (LLaMA, 890 documents). All configurations are net-positive. Bold: reported configuration ( α=1.0 , τ=0.75 ).
Bias
Fix
Break
Net
+ 0.10
219
274
− 55
− 0.10
80
116
− 36
+ 0.25
431
580
− 149
− 0.25
307
430
− 123
+ 0.50
798
1382
− 584
− 0.50
505
842
− 337
Appendix
Table 9: Constant logit bias on i2b2 (LLaMA). TGS: net +201.
University of California San Francisco, San Francisco, CA, USA · Waymark, San Francisco, CA, USA · University of Pennsylvania, Philadelphia, PA, USA +2