arXiv:2611.00298cs.LGOct 2026

Manuscript Offprint

arXiv:2611.00298

A Framework for Task-Agnostic Counterfactual Fairness in Transformers through Activation Steering

Joshua Wolff Anderson, Yanshan Wang, Shyam Visweswaran

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

JOSHUA WOLFF ANDERSON ⋆^{\star}, University of Pittsburgh, USA

YANSHAN WANG, University of Pittsburgh, USA

SHYAM VISWESWARAN, University of Pittsburgh, USA

Bias in transformer-based models is a growing concern as these architectures become more prevalent in automated decision-making systems, such as prediction models for hiring, lending, and clinical treatment recommendation. Mechanistic interpretability (MI) is a growing body of work that measures meaningful causal effects of activations on model output by identifying human-interpretable features encoded in model activations. When such features correspond to sensitive attributes, they provide a direct way to quantify the bias those attributes introduce and to causally intervene to mitigate it. However, counterfactual fairness (CF) methods have not been systematically adapted to this setting of intervening on interpretable mechanisms in transformers. We propose a framework, Mechanistic Interpretability for Counterfactual Fairness (MICF), that utilizes MI tools to reformulate CF constraints in terms of transformer activations, unifying former approaches into a single pipeline for fairness analysis in transformers. MICF does not require a prior causal model or specific transformer architecture. We evaluate MICF on real-world tabular data and show that CF can be improved across different prediction tasks.

1 Introduction

As machine learning (ML) models increasingly inform high-stakes decisions, from criminal risk assessment to clinical decision-making, demand for greater transparency in ML systems has grown substantially; transparency refers to the degree to which a model's internal computations are human-understandable [20]. Even prior to the rise of large language models (LLM), transformer architectures have increasingly been used for high-stakes decision-making such as clinical prediction [26], legal judgment prediction [42], hiring decisions [45], as well as in broader domains such as education, finance, marketing, and entertainment [5, 28]. However, the scale and complexity of transformer models make their internal reasoning hard to inspect, limiting accountability for whether their decisions are reliable and equitable. As these models take on consequential roles, stakeholders have increasingly called for greater understanding and justification of their outputs, driving demand for transparency [8, 9, 44]. Two active areas concerning model transparency are interpretability and fairness. Interpretability methods aim to visualize or explain how a model maps input to output in a way understandable to humans, while fairness methods seek to ensure that its predictions do not encode bias [6, 17]. Yet, fairness and interpretability are typically pursued separately [3], and work at their intersection remains understudied.

Mechanistic interpretability (MI) is an interpretability framework that reverse-engineers neural networks' internal computations to identify components that causally mediate specific model behaviors [6]. MI differs from traditional post-hoc explanation methods like SHAP [22], which approximate model behavior from the outside rather than examining its internal structure. MI enables inspection through mechanisms related to sensitive attributes that causally influence model predictions at the level of a model's internal representations, providing a principled basis for verifying fairness properties beyond aggregate output statistics.

Counterfactual fairness (CF) provides a complementary, causally grounded notion of algorithmic fairness: a prediction is fair for an individual if it would remain unchanged in a counterfactual world where they belonged to a different

Authors' Contact Information: Joshua Wolff Anderson, University of Pittsburgh, Pittsburgh, Pennsylvania, USA; Yanshan Wang, University of Pittsburgh, Pittsburgh, Pennsylvania, USA; Shyam Visweswaran, University of Pittsburgh, Pittsburgh, Pennsylvania, USA.

group [17]. Unlike group fairness metrics, CF respects the causal structure of sensitive attributes with respect to the outcome. A well-known limitation, however, is that traditional CF requires explicit structural causal models to measure causal effects, which are often non-identifiable in the presence of complex real-world confounding [34].

A unified framework is needed to explicitly specify and ground modern counterfactual generation methods, identify the causal structure of model internals, and, in principle, apply across transformer architectures and modalities to achieve CF. In this work, we propose Mechanistic Interpretability for Counterfactual Fairness (MICF), a framework that achieves these goals by connecting the normative concepts of CF with the mechanistic understanding of internal model computations. We leverage MI analysis of transformer internals to identify and intervene on the computational pathways through which sensitive attributes influence predictions.

References (13)