Occupation influences code style more than identity in AI programming

Identity or Prompt Noise? A Calibrated Invariance Audit of LLM Code Generation

Software Engineering

Summary

This paper looks at whether computer programs written by AI change depending on the identity given to the AI, like gender or country. The researchers found that the type of job or occupation given to the AI has a small but consistent effect on how it writes code, while gender and country make little difference. The changes don't affect whether the code works, just small style differences. This suggests AI code generation isn't biased against identities but can slightly adjust style based on occupation.

What this means in practice

  • For software development teams: Detect subtle style shifts in AI-generated code influenced by occupation prompts to ensure consistent coding standards.
  • For ai product managers: Design AI coding assistants that account for occupation-based style differences to better match developer preferences.

Authors

Maksim E. Eren, Ryan Barron, Eric Michalak, Charles Nicholas, Manish Bhattarai

Abstract

Identity cues are irrelevant to a fixed programming specification, but raw counterfactual differences can arise from unequal samples and prompt wording. We audit 30.73 million executed Python generations from seven checkpoints on HumanEval+ and MBPP+, supplemented by an exploratory 550B slice, under model-assigned gender, country, and occupation personas. Within-task randomization and false-discovery-rate control identify occupation as the most consistent structural axis: CodeBLEU dispersion exceeds its exchangeability null in 10/14 model--benchmark cells, remains significant in 8/12 full-coverage cells, and exceeds the country ratio in every paired cell, although the median excess is only 0.141 points. In six high-pass-rate cells, occupation dispersion replicates across token similarity, length, comments, reference similarity, and complexity, while pass-rate dispersion is significant in none. Country leads raw dispersion in 12/14 cells but has a median calibrated ratio of 1.00. Gender-associated variation cannot be separated from persona wording in this design. Thus, the evidence supports small, reproducible occupation-conditioned changes in code form, not stable disadvantage to named identities or demonstrated downstream harm. We use this finding to motivate a broader commentary on the potential impacts of bias in code generation, including the possibility that models may condition their outputs on identity information available from prior conversational context.