cs.CLOct 16, 2026

Aligning Language Models Towards Counterfactual Invariance

Authors: Basar Demir, Emily Shen, Ksheeraj Sai Vepuri, Sourabh Kulkarni, Harihar Subramanyam, Ankit Jain, Nan Jiang, Chirag Nagpal

Organizations: Meta Superintelligence Labs · University of California, San Diego · Independent Researcher

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. 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.

Figures & tables

Appendix figures & tables18 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. Compared to What? Baselines and Metrics for Counterfactual Prompting

    May 1, 2026Zihao Yang, Mosh Levy, Yoav Goldberg +1Counterfactual EvaluationCausal Interventions in Language Models

  2. COFT: Counterfactual-Conformal Decoding for Fair Chain-of-Thought Reasoning in Large Language Models

    May 28, 2026Arya Fayyazi, Mehdi Kamal, Massoud PedramSocial Bias in Language ModelsCounterfactual Fairness

  3. Emergent Unfaithfulness: How Alignment Training Causes Language Models to Silently Override Task Faithfulness

    Sep 30, 2026Pardis Sadat Zahraei, Janvijay Singh, Gokhan Tur +1LLM AlignmentInstruction Following