Measuring and Inverting How Transformers Rebuild Erased Bias

When you erase a demographic signal from one layer of a language model, later layers often put it back. Across the bias literature this is the most consistent failure. Scrubbing gender from RoBERTa's input embeddings drives embedding-level association scores to near zero, yet sentence-level likelihood bias stays significant or gets worse (Silva et al.). Removing names and pronouns from biographies still leaves gender predictable at over 65% accuracy (Bias in Bios). Density functional theory (DFT), the standard method for computing electron structure in molecules and materials, has a precise vocabulary for exactly this behavior. When you apply a "bare" perturbation to a system of electrons, the electrons rearrange and partly cancel or amplify it. This is called screening. The perturbation you must apply to get a desired net effect is found by inverting the system's response, and because the response depends on the state, it is solved iteratively until the answer is self-consistent.

We propose to treat bias reconstruction in transformers as a screening problem, in two steps. First, we measure a layer-by-layer response operator that says how much of an edit to the demographic signal at layer $l$ survives, is regenerated, or is amplified by layer $L$. Second, we design interventions that invert this operator. The goal is the smallest edit at a chosen layer whose screened effect on the decision-relevant signal is zero, rather than projecting blindly at one layer or at every layer. The bet is that this gets the fairness gains of all-layer interventions while making much smaller changes to the activations, and therefore loses less capability. It also turns the vague phrase "attention reconstructs bias" into a number that can be compared across layers, models and prompt formats.

Core Claim

DFT enters here as a methodological lens. We do not claim that transformers obey Hohenberg–Kohn-type theorems. What we borrow are three concrete tools: a linear-response description, the split between the bare and the induced response, and self-consistent solution with mixing. Let $s_l(x)$ be the coordinates of the hidden state at layer $l$ inside a demographic subspace for input $x$. That subspace is found per layer by Distributed Alignment Search (DAS), a causal-abstraction method that finds linear subspaces whose swapping changes model behavior, as in Nguyen and Tan. For a small edit $u$ added at layer $l$, define the response

$$\delta s_L = R_{L\leftarrow l}\,u, \qquad R_{L\leftarrow l} = \mathbb{E}_{x\sim\mathcal{C}}\left[\frac{\partial s_L(x)}{\partial h_l(x)}\right],$$

where $h_l$ is the full hidden state and the expectation runs over a broad distribution of contexts $\mathcal{C}$, not a single prompt template. If the residual stream only carried the edit forward, $R$ would be close to a projection of the identity. Any deviation measures regeneration: other positions and proxy tokens rebuild the signal through attention and the MLP layers.

The "screening ratio" $\sigma_{l\to L}$ is the fraction of an erased signal's decodability that returns by layer $L$. A value near 1 means the intervention is fully undone. We intervene with the least-norm edit whose screened effect cancels the decision-relevant signal,

$$u^\star = -R_{L\leftarrow l}^{+}\, s_L,$$

with $R^{+}$ the pseudo-inverse. Because the model is nonlinear, we re-linearize around the edited state and repeat, averaging old and new edits as DFT codes do to stabilize self-consistent loops, until $s_L$ stops changing.

The new element is measuring and inverting the downstream response. Existing methods choose an edit locally and hope it survives. DAS race averaging edits one layer. Dawkins et al. project at chosen BERT layers. Kaneko and Bollegala fine-tune all layers with an orthogonality loss.

Research Program

The first phase is diagnostic. For Gemma-2B-Instruct and LLaMA-3.2-3B-Instruct on the ADMISSIONS and HIRING tasks, and for Llama-3.1-8B on the name–gender probing setup of An et al., we estimate $R_{L\leftarrow l}$ for every pair of source and target layers. We compute it with Jacobian-vector products restricted to the DAS subspace, which keeps the cost at a few hundred backward passes per layer pair. From these we build screening-ratio maps.

This phase tests two hypotheses. The first is that screening ratios explain the tension between the two main prior results: Kaneko and Bollegala find that single-layer debiasing fails, while Dawkins et al. find that deep projection damages SNLI accuracy. The second is that the ratios differ by prompt format in a way that accounts for the finding that DAS subspaces fitted on free-text admissions profiles fail on bullet-pointed ones (Nguyen and Tan).

We also measure per-token susceptibility: the response of a name's gender coordinate to occupational context. This quantifies the "Jody" effect, where ambiguous names shift with context and strongly gendered names do not (An et al.). We then test whether high-susceptibility tokens are where regeneration originates.

The second phase builds the response-inverted intervention. We estimate $R$ on contexts pooled across prompt formats, following the argument that bias lives in distributions over contexts rather than in single points (Guo; Dev et al.). We then solve for $u^\star$ at the layer with the best trade-off between edit size and cancellation.

The third phase ports the method to masked models. On BERT we apply it to StereoSet (Nadeem et al.) and to Gender-Occupation NLI with SNLI as the capability check, so that results compare directly with Dawkins et al.

Two related lines of work have a different role. The moment-constrained debiasing of automatic debiasing via moment constraints and the k-nearest-neighbor density-functional estimators of finite-sample kNN functionals supply our evaluation tool. We use them to estimate the divergence between activation distributions for different demographic groups before and after intervention. We do not use them as training regularizers, because the moment method was developed for static tabular and image features and never faced regeneration across layers.

Baselines

The naive reference is the unmodified model. It admits 26% more White than Black applicants for Gemma and hires 60% more Asian than White applicants for LLaMA (Nguyen and Tan). We also run the fairness system prompt from the same paper, which that paper reports increased Gemma's bias score by 44.75% in ADMISSIONS. It serves as the cheap behavioral reference.

The strongest existing representation method on the decision tasks is DAS race averaging at a single layer. It replaces race coordinates with the mean across groups and reduced Gemma's bias by 37–57% in ADMISSIONS and 37.89% in HIRING (Nguyen and Tan). We reproduce it with the same subspace dimension, candidate layers, and prompt pool as our method. Beating it means exceeding the upper end of its bias reduction on the in-format task. More importantly, it means keeping at least most of that reduction when the edit is transferred to bullet-point formats and from ADMISSIONS to HIRING, which is exactly where the paper reports DAS fails.

The second strong competitor is intervention at every layer: inference-time race averaging or projection applied to all layers at once. This mirrors the "all layers" conclusion of Kaneko and Bollegala, whose fine-tuned version kept BERT's GLUE score at 74.9 against 75.8 before debiasing. On BERT we compare against Dawkins et al.'s layer-11 projection, which raised NLI fairness from 0.0375 to 0.6493, and against their best intrinsic-bias configuration with attention, which lowered SNLI accuracy from 0.8889 to 0.7156. Beating these means matching their fairness at a smaller total edit norm and a smaller drop in SNLI or GLUE, under the same subspaces and the same tuning budget of layer choices and strength sweeps.

Two ablations isolate the key ingredient. The first replaces $R$ with the identity, which is plain least-norm cancellation at one layer. This tests whether measuring regeneration matters at all. The second estimates $R$ on a single prompt format instead of the pooled distribution. This tests whether averaging over contexts is what produces transfer across formats.

Why not just…?

Why not just intervene at every layer? This is the most direct competitor, and it may well match our fairness numbers. Our claim is about cost. If most layers have low screening ratios, all-layer editing moves the activations far more than necessary. Dawkins et al.'s SNLI drop and Kaneko and Bollegala's report that RoBERTa and ALBERT are more sensitive to debiasing are consistent with that picture. The decisive measurement is the capability loss at matched bias reduction. If the all-layer baseline matches us on both, the response operator is only a diagnostic, and we will report it as such.

Why not just optimize a steering vector end to end by backpropagating a disparity loss? This is the fully nonlinear version of our idea and a serious threat. It also implicitly accounts for regeneration. We include it as a baseline with the same edit budget. We expect it to overfit to the prompts it is optimized on, just as DAS did, because nothing in it averages over context distributions. The cross-format and cross-task transfer test settles this. If backprop steering transfers equally well, our contribution narrows to the screening diagnostic and the least-norm edits, and the note will say so.

Why not just fit DAS on pooled prompt formats? Pooling might fix transfer without any response modeling. We run this as the pooled-DAS baseline. Pooling fixes where the subspace sits but not how later layers refill it. If pooled single-layer DAS transfers but still leaves high downstream disparity, that points to regeneration. If it closes the gap entirely, the screening story is unnecessary for these tasks.

Why not just retrain with counterfactual data augmentation? Augmenting training data with swapped demographic terms cut the WinoBias F1 gap from about 29.6 to about 1.0 for ELMo (Zhao et al.). It is the best-documented fix, but it requires retraining, which is out of scope for the frozen 2B–8B instruction-tuned models studied here. We treat it as a reference for what bias reduction is achievable, not as a competitor under our compute budget.

Proposed Experiments and Decisive Checks

The first check is predictive. Screening ratios measured on held-out contexts should predict, before any intervention is tuned, the rank order of layers by how much single-layer DAS averaging reduces decision bias. If there is no correlation, the response operator does not describe the phenomenon, and the project stops at the diagnostic stage.

The second check is the transfer test on ADMISSIONS and HIRING. We fit on free-text ADMISSIONS and evaluate on bullet-point ADMISSIONS and on HIRING. We report the disparity in acceptance rates between groups and the rate of degenerate "accept everyone" behavior, against DAS averaging, pooled DAS, all-layer averaging and backprop steering.

The third check is the capability–fairness frontier on BERT. We plot Gender-Occupation NLI fairness $\eta$ against SNLI accuracy and GLUE, and StereoSet stereotype score against language-modeling score, as a function of total edit norm. Success is a frontier strictly above those of Dawkins et al. and the all-layer baseline.

A final measurement ties back to the core claim. After intervention, the kNN-estimated divergence between group-conditional activation distributions at the final layer should fall together with the behavioral disparity. If behavior improves while the distributions stay apart, the method is suppressing a readout rather than removing the signal.