atlas

Research map / Large language models / Language, safety and interpretability

Bias Unveiled: Investigating Social Bias in LLM-Generated Code

AAAI 2025 · Large language models › Language, safety and interpretability · approach: Bias measurement and mitigation · 17 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes Solar, a metamorphic-testing fairness framework with a 343-task dataset to measure social bias in LLM-generated code, and tests prompting-based mitigation (CoT, role-play CoT, iterative feedback prompting) on four code LLMs.

Problem

Social biases in code generated by LLMs for human-centered tasks (e.g., eligibility or suitability decisions based on demographics) are not evaluated or mitigated, and existing benchmarks lack realistic scenarios and severity quantification.

Approach

Generate code prompts and executable metamorphic test cases from a DSL (textX) task definition, mutating one protected attribute at a time, and use the failing-test results both to quantify bias (CBS, BLS) and as iterative feedback to the LLM to reduce bias.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
use Solar-feedback iterative prompting for three rounds (ablation)GPT-3.5-turbo-0125 · Solar social-bias datasetCBS overall (%): 60.58 -> 8.77Helped
use Solar-feedback iterative prompting for three rounds (ablation)GPT-3.5-turbo-0125 · Solar social-bias datasetPass@attribute: 81.14% to 85.66%Helped
add Chain-of-Thought prompting (ablation)GPT-3.5-turbo-0125 · Solar social-bias datasetCBS overall (%): 60.58 -> 72.65Hurt
add positive role-play with Chain-of-Thought prompting (ablation)GPT-3.5-turbo-0125 · Solar social-bias datasetCBS overall (%): 60.58 -> 68.66Hurt
add positive role-play with Chain-of-Thought prompting (ablation)GPT-3.5-turbo-0125 · Solar social-bias datasetCBS by demographicMixed
lower temperature from 1.0 to 0.2 (ablation)CodeLlama-70b-instruct-hf · Solar social-bias datasetCBS (%): 28.34% to 65.19%Hurt
vary temperature (ablation)GPT-3.5-turbo-0125, Qwen2.5-7B, and claude-3-haiku-20240307 · Solar social-bias datasetCBSMixed

Surprising findings

Limitations

Experimental setup

Datasets: HumanEval

Benchmarks: Solar code bias dataset HumanEval

Metrics: Code Bias Score (CBS) Bias Leaning Score (BLS) Pass@attribute pass@1

Baselines: CoT prompting positive role-play + CoT prompting

Builds on: metamorphic testing textX HumanEval

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy