Failure of contextual invariance in large language models
Authors: Sagar Kumar, Ariel Flint, Luca Maria Aiello, Andrea Baronchelli
Organizations: Network Science Institute, Northeastern University, USA · Center for Health Informatics Program, Boston Children’s Hospital, USA · Dept. of Mathematics, City St George’s, University of London, UK · IT University of Copenhagen, DK
Standard evaluation practices assume that large language model (LLM) outputs are stable when prompts are embedded in contextually equivalent discourses. Here, we test this assumption in the setting of gender inference. Using a controlled pronoun selection task, we introduce minimal, theoretically uninformative discourse context and find that this induces large, systematic shifts in model outputs. Correlations with cultural gender stereotypes, present in decontextualized settings, weaken or disappear once context is introduced, while theoretically irrelevant features, such as the gender of a pronoun for an unrelated referent, become the most informative predictors of model behavior. A Contextuality-by-Default analysis reveals that, in 19--52% of cases across models, this dependence persists after accounting for all marginal effects of context on individual outputs and cannot be attributed to simple pronoun repetition. These findings show that LLM outputs violate contextual invariance even under near-identical syntactic formulations, with implications for bias benchmarking and deployment in high-stakes settings.
Figures & tables
Figure 1: Discourse context destabilizes pronoun generation probabilities across all models. (a-e) Distribution, over all templates, of empirical generation probabilities. The height of the curve at the left extrema of each plot indicates the fraction of templates for which, in that context setting, p^(f∣c)=0 (the model always generates the masculine pronoun in context setting c ). The inverse is true for the right extrema, indicating the fraction of templates for which p^(f∣c)=1 . (f-j) Average Kullback-Leibler Divergence, ⟨KL(c∥c∅)⟩ (in bits), between the distribution of responses for each template in the unprimed setting, c∅ , and each of the primed settings tested, c∈{cf,cm,c0,1,c0,2} .
Figure 2: Correlations with cultural stereotypes vanish once discourse context is introduced. Spearman Correlation between the cultural gender stereotypes as measured by Misersky et al. (2014) and empirical generation probabilities in the unprimed ( c∅) , masculine-primed ( cm ), and feminine-primed ( cf ) context settings measured in our experiment, with significance ( ∗∗∗:=p<.001 , ∗∗:=p<.01 , ∗:=p<.05 ).
Figure 3: Discourse context shifts predictive dominance towards the priming pronoun, away from cultural and syntactic features. Average mutual information (in bits) between features of the prompt and the pronoun generated by the model in unprimed settings and primed settings with standard error. Prompt features: ‘Role Type’ refers to the type of role of the antecedent of the target pronoun, ‘Stereotype’ refers to cultural stereotypes about the antecedent. ‘Case’ refers to the grammatical case of the pronoun, ‘Order’ refers to the linear order of options presented in the prompt, and ‘Priming Pronoun’ refers to the gender of the priming pronoun (present only in the primed settings).
Figure 4: Contextual effects vary across models and are sensitive to the linear order of pronoun options. (a) Fraction of template pairs which exhibited contextual measurements, disambiguated by the linear order of pronoun options presented in the prompt. (b) Fraction of template pairs which exhibited contextual measurements in both members of each model pair.
Model
% Contextual Measurements
GPT
27%
Phi-4
52%
Gemma
39%
Llama
22%
Qwen
19%
Table 1: Total fraction of the 180 template pairs tested in each model that exhibited contextuality in their pronoun generation probabilities in either option ordering.
Model
Params.
gpt-oss-20b
22B
Phi-4
14B
gemma-3-12b-it
12B
Llama-3.1-8B-Instruct
8B
Qwen2.5-7B-Instruct
7.6B
Table 2: Model name (per Hugging Face convention) and reported number of parameters for all models tested.
Figure 5: Example set of templates. The template shown in the unprimed setting is modified by adding a priming sentence, as shown in the Discourse Primed and Null Primed examples. Each of these is tested by being substituted for the template variable in Box 9 .
Unprimed
Masc Primed
Fem Primed
MF
FM
MF
FM
MF
FM
GPT
144800144800
144800144800
7240072400
7240072400
7240072400
7240072400
Phi
127200126966
127200126860
6360063324
6360063256
6360063316
6360063178
Gemma
107200107170
107200106800
5360053500
5360053396
5360053476
5360053238
Llama-8B
181000181000
181000181000
9050090500
9050090500
9050090500
9050090500
Qwen
173600173600
173600173600
8680086800
8680086800
8680086800
8680086800
Table 3: Fraction of valid measurements out of total number of measurements made by each model in each context setting.
Anaphora
PoS
Tracking
GPT
0.62
1.00
0.85
Phi
0.74
1.00
0.91
Gemma
0.74
1.00
0.73
Llama-8B
0.58
0.94
0.96
Qwen
0.45
0.99
0.36
Table 4: Model accuracy in the three metaprompting tasks.
Figure 8: Statistical stability across temperatures. (a-c) Distribution of pi(f∣c) in GPT for the three context settings shown across three generation temperatures. As before, the left extrema represents the case where pi(f∣c)=0 (and therefore, pi(m∣c)=1 ) while the right is the case where pi(f∣c)=1 . (d-f) Correlations between pronoun generation probabilities in each context setting and empirical femininity ratings, measured across three temperatures. (g-i) Average mutual information between generation probabilities at each temperature and the feature specified, with bars depicting standard error.
Figure 9: Contextuality across temperatures. (a) Fraction of templates that exhibited contextual measurements in both linear orderings in GPT across three generation temperatures. (b) Fraction of templates which measured as contextual in row temperature that were also measured as contextual by the column temperature.
Understanding gender biases in large language models (LLMs) is increasingly important as these systems become embedded in decision-support tools with real consequences. Prior research has focused only on a small set of models, leaving open the extent to which gender biases are common and heterogeneous across LLMs. We address this gap across ten models released between April 2025 and June 2026, spanning nine vendors, using two paradigms: gender attribution to stereotyped phrases (Study 1) and moral judgment of abuse or torture against a woman or a man to prevent a catastrophic outcome (Study 2). In Study 1, two of ten models attributed masculine-stereotyped phrases to female writers more often than the reverse, while three models showed the opposite pattern. In Study 2, several models converged on a male-disadvantaging asymmetry that was directionally consistent with a documented human tendency to protect female targets from harm, though the specific conditions under which this asymmetry emerged varied by model; three other models, by contrast, showed no variation across conditions. These results indicate that gender-related biases are common in LLMs. Their direction and magnitude, however, are highly heterogeneous, to the point that some models behave in diametrically opposite ways to others. Bias auditing should therefore be treated as an ongoing, multi-vendor process, rather than a one-time assessment.
Instruct-based large language models (LLMs) have been shown to propagate and even amplify gender bias when prompted with contextually constrained instructions (e.g., writing a text from a description or selecting a gendered pronoun). However, little attention has been paid to biases in responses to contextually unconstrained (generic) instructions conveyed by gendered language, particularly masculine generics (MG). MG, found in many gender-marked languages, denote the use of the masculine gender as a supposedly neutral reference to mixed-gender groups or individuals whose gender is unknown or non-binary. Yet, psycholinguistic studies demonstrate that MG are not neutral and systematically induce gender bias. This study investigates how both local and proprietary LLMs are MG-biased when responding to generic prompts in French, examining LLMs' MG bias rates and use of gender-fair language (GFL). We create a 16k+ human noun database from existing lexical resources and evaluate six LLMs on four instruction-response datasets under two conditions: prompts with and without MG. Overall, we find that ≈27.57% of LLMs' responses to MG-filtered generic instructions are MG-biased (≈78.55% with MG-containing prompts). Moreover, we find that LLMs rarely use GFL spontaneously. These findings highlight the persistence of MG bias in LLM outputs and models' limited tendency towards GFL strategies.
We audit six large language models (LLMs) for gender stereotyping across English, Korean, Chinese, and Japanese. Three were developed primarily for English-language use (Claude, GPT, Gemini) and three for East Asian use (DeepSeek, Syn-Pro, HyperCLOVA X). We adopt the HEXACO-100 personality inventory and anchor each model against a cross-cultural human dataset spanning 48 countries to ask not whether LLMs are biased, but how far their gender attributions drift from the populations they are deployed among. Our findings show that their stereotyping spans a range roughly 2.5 times wider than the entire cross-country range found in humans, and the effect can compound across languages. One English-centric model, prompted in Korean, reached 5 times the local baseline, even when the prompt stated the candidate had already been hired, which often dampens human stereotyping. To characterize such behaviors without ranking them, we introduce a four-pattern framework -- concordance, suppression, reorganization, and amplification -- across 24 (model x language) cells. Item-level analysis reveals that translation does not just rescale stereotypes, but changes the attributes tied to it, hiding significant rearrangement under the surface while appearing well-calibrated. Our results ultimately suggest that no single debiasing pipeline is likely to address bias evenly across linguistic boundaries.
Jiwoo Choi, Seonwoo Ahn, Tongxin Zhang +1
School of Digital Humanities and Computational Social Sciences, KAIST, South Korea