NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Elucidating Mechanisms of Demographic Bias in LLMs for Healthcare

Hiba Ahsan, Arnab Sen Sharma, Silvio Amir, David Bau, Byron C. Wallace · DOI

Introduction

Large Language Models (LLMs) are increasingly being integrated into clinical workflows, such as Epic's deployment of GPT-4. However, these models often exhibit significant social biases. For instance, when prompted to generate a clinical vignette for rheumatoid arthritis, GPT-4 assumes a female patient 97% of the time. While such biases are well-documented, the internal mechanisms—how these demographic attributes are represented within the model's neural architecture—remain poorly understood. This research applies mechanistic interpretability to healthcare LLMs to locate and manipulate these internal representations.

Methodology: Activation Patching

The core technique used is Activation Patching. This involves identifying specific internal activations (typically in Multi-Layer Perceptron or MLP layers) that correspond to a demographic trait and "patching" them into a target prompt's processing stream.

Overview of activation patching for clinical tasks.

The researchers primarily evaluated OLMo-7B-Instruct, alongside other models like Llama-3.1-8B and Gemma-2-9B. The process involves:

  1. Localization: Using a "rewrite score" to find the layers and tokens where demographic information is most concentrated.
  2. Intervention: Overwriting activations in a target clinical prompt with those from a demographic-specific source prompt (e.g., "The patient is Male").
  3. Scaling: Multiplying patched activations by a factor to amplify the effect.
  4. Implicit Bias Testing: Patching the residual stream at the final token of a neutral clinical note to observe how the model's internal "perception" of a patient's race or gender affects downstream predictions, such as depression risk.

Localization of Demographic Traits

A key finding is that demographic information is often highly localized. In OLMo-7B, gender representation is concentrated in a specific middle layer (Layer 18).

Heatmap showing the localization of demographic information across layers and tokens.

Interestingly, racial representations were found to be more distributed across multiple layers compared to gender. To effectively alter racial perceptions, the authors employed "sliding window patching," intervening across approximately five adjacent layers simultaneously. Furthermore, the study revealed that certain medical conditions act as "demographic vectors." For example, activations associated with "prostate cancer" could serve as a universal "male" patch, even influencing gendered pronoun generation in non-medical contexts.

Impact on Clinical Tasks

The ability to surgically intervene on internal representations allowed the researchers to quantify implicit bias without triggering safety filters or altering the input text.

Clinical Vignette Generation

By patching and scaling the target layer (scaling factor $\ge 2$), the authors successfully flipped the gender of generated patients 100% of the time for conditions like Multiple Sclerosis and Sarcoidosis. Crucially, the quality of the generated text remained high, with perplexity scores showing negligible change (remaining around 3.5).

Implicit Bias in Diagnosis and Risk Assessment

The study demonstrated that internal demographic "perceptions" directly influence clinical outcomes:

  • Depression Risk: When a patient was implicitly assigned a "female" identity via patching, the model predicted a 3.5% higher risk of depression compared to a "male" patch on the same clinical note. An implicit "Black" identity increased the predicted risk by 8.25% over "white."
  • Differential Diagnosis: Demographic patching significantly altered the ranking of correct diagnoses in expert-level medical cases (NEJM Healer), showing a statistically significant mean rank difference ($p=0.004$).

Conclusion

This work demonstrates that demographic biases in LLMs are not just surface-level statistical correlations in text but are encoded in specific, manipulatable neural circuits. By localizing these representations, researchers can better understand the "black box" of clinical LLMs and develop more targeted methods for bias mitigation. Future work will aim to expand these techniques to more diverse and non-binary demographic categories, moving toward safer and more equitable AI in healthcare.

Summary updated

BibTeX
@misc{ahsan2025elucidating,
  author = {Hiba Ahsan and Arnab Sen Sharma and Silvio Amir and David Bau and Byron C. Wallace},
  title = {{Elucidating Mechanisms of Demographic Bias in LLMs for Healthcare}},
  year = {2025},
  eprint = {2502.13319},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.13319},
}
Figure