Aligning Language Models Towards Counterfactual Invariance

Basar Demir, Emily Shen, Ksheeraj Sai Vepuri, Sourabh Kulkarni, Harihar Subramanyam +3 more
10/16/2026
cs.CLcs.AIcs.LG
rl

No confident code implementation found for this paper.

Abstract

Small variations in prompt characteristics can meaningfully alter the semantics, tone, and contextual assumptions of large language model outputs. Such characteristics can involve group variables such as demographics or other sensitive latent attributes.

Show full abstract

Sensitivity to such input variables is undesirable when demographic information is causally irrelevant to the task, but might still be relevant for generation of semantically coherent responses. This makes the task of enforcing counterfactual invariance while preserving model utility difficult. To study this problem, we first show that standard model alignment recipes (such as reinforcement learning) increase differences in response quality across demographics, while improving overall response quality, ultimately amplifying what is known as counterfactual bias. To address this, we develop a policy gradient technique involving a group-level reward function that operates on matched pairs of counterfactual prompts. For completeness, we build a dataset of controlled counterfactual prompt pairs and design an evaluation that separately measures cases where demographic information is causally relevant to the answer. Finally, we validate our findings on several fairness benchmarks. We demonstrate that our methods reduce counterfactual differences while preserving overall response quality and that the models continue to adapt appropriately when such sensitive information is relevant.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{demir2026aligning,
  title  = {Aligning Language Models Towards Counterfactual Invariance},
  author = {Basar Demir and Emily Shen and Ksheeraj Sai Vepuri and Sourabh Kulkarni and Harihar Subramanyam and Ankit Jain and Nan Jiang and Chirag Nagpal},
  year   = {2026},
  eprint = {2610.22942},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2610.22942v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2610.22942.svg)](https://codeofpaper.com/paper/2610.22942)

Discussion