Bias and Fairness in LLMs
What bias and fairness mean in LLMs, where the bias comes from, how to measure it and where it stops, explained simply for your AI interview.
In short
Bias in an LLM is when it treats people or ideas unevenly, sometimes by repeating stereotypes from its training text. Fairness means checking that the outcomes are even enough for the people affected, and measuring that rather than assuming it.
13 min readBeginnerVery common · estimateFacts checked 26 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
Bias in an LLM means it treats people or ideas unevenly, sometimes by repeating stereotypes from its training text. I measure it with a counterfactual test: the same request, one detail changed, then compare the results. Prompt wording can cut the gap, but it can't be trusted alone. So I set a limit in writing, keep testing, and keep a person on decisions that affect someone's money, job or health.
A language model learns from huge amounts of human writing, and that writing carries old habits. So the model can pick up stereotypes and treat people differently, even when nobody meant it to. That uneven treatment is bias. Fairness is the standard I test against: outcomes that are even enough for the people affected.
There are two main kinds of harm. The first is representational: the model stereotypes a group or talks down to them. The second is allocational: the model's answers change who gets a loan, a job or a claim paid. The second is where the real cost lands, so that's where I measure first.
To measure it, I use a counterfactual test. I keep the request identical, change one detail such as the applicant's name, and compare the results across many files. In a made-up bank example, 200 loan files with the same income and credit ran twice, once per name group. The pre-approval rate was 80% for one group and 65% for the other. That 15-point gap is a warning I can act on.
Prompt wording helps. In a 2023 Anthropic study, prompt changes significantly reduced discrimination, and in some cases removed it. But prompts alone aren't enough. So I set a limit in writing, keep testing after every model change, and keep a person on decisions that affect someone's money, job or health.
What are bias and fairness in an LLM, in plain words?
A language model learns from huge amounts of human writing, and that writing carries old habits. So the model can pick up stereotypes and treat people differently, even when nobody meant it to. That uneven treatment is bias.
Fairness is the standard you test against. It asks whether the outcomes are even enough for the people affected. Which kind of evenness matters for your product is a choice a team has to write down.
Think of a new bank officer trained only on last decade's loan files. If those files turned down some neighbourhoods more often, the officer may copy that habit without anyone teaching it. An LLM picks up patterns in a similar way, at a far bigger scale. A pre-check assistant reading loan forms can lean the same way.
Key words
- Bias
- A skew in a model's answers that treats people or ideas unevenly.
- Stereotype
- A fixed, often unfair belief about a group, repeated as if it were fact.
- Disparity
- A gap in results between groups, such as their approval rates.
- Counterfactual test
- Keep a request the same, change one detail, and see whether the answer changes.
Where does bias in an LLM come from?
Bias can enter at several points. The survey lists the training data, the model's own training and inference procedure, and where it is deployed. The picture below shows two of these: the text it learned from and the setting it is used in.
“Research has shown that language models can still sometimes absorb and repeat social biases from training data, such as gender or racial stereotypes.”
OpenAI, October 2024
“these models can learn, perpetuate, and amplify harmful social biases”
Gallegos and colleagues, a 2023 survey of bias research
Where LLM bias comes from
Past writing
carries old stereotypes
Where it is used
the setting changes its effect
The model
learns patterns, not written rules
What users get
Tone and detail
quietly differs by group
Yes or no calls
loans, jobs, claims
Measure each group
then set a limit and fix
- 1Old writing carries old stereotypes into training.
- 2The setting it is used in can change what it does.
- 3The model learns patterns from all of it, and they show up in tone.
- 4The same patterns can push its yes or no calls too.
- 5Measuring each group's results is how a team finds the gap.
Researchers split the harm into two kinds. Representational harms stereotype a group or treat it in a demeaning way. Allocational harms spread opportunities or resources unevenly between groups.
- Representational
Who gets stereotyped
The model describes or treats a group in a demeaning way, such as assuming a name points to a job or a role.
- Allocational
Who gets the outcome
The model's answers change who is approved, offered a call back or sent for review. That is where people pay the price.
How do you measure bias in an LLM?
You can't see bias in one answer. You see it across many similar cases. A common method is the counterfactual test: keep the request the same, change one detail such as the name, and compare. OpenAI used this kind of approach in its October 2024 study of ChatGPT. It asked how the answers changed for each name, in an otherwise identical request.
OpenAI found no difference in overall response quality across names linked to different genders, races or ethnicities. Its automated grader, a language model, judged harmful stereotypes in around 0.1% of overall cases, and up to around 1% in some domains on older models. It said more work is needed to define a harmful stereotype.
Here is a worked example with made-up numbers. A mid-size bank puts an LLM in front of its small-loan pre-check. Its team builds 200 loan files with the same income, credit history and loan size. Each file runs twice, once with a Group A name and once with a Group B name, so the model gives 400 answers, 200 per group. The model says pre-approve for 160 of the 200 Group A runs and 130 of the 200 Group B runs. That is 80% against 65%, a 15-point gap. Nothing else in the files differs, so the team treats the gap as a finding to explain and fix.
The code below does the same sum on those made-up numbers. It flags the gap against a limit the team agreed in advance.
# A bank's loan pre-check model, tested on 200 made-up files, each run once per name group.
# Only the applicant's name group differs. Each row: (group, did the model say pre-approve?)
LOG = (
[("Group A", True)] * 160 + [("Group A", False)] * 40
+ [("Group B", True)] * 130 + [("Group B", False)] * 70
)
def approval_rate(rows, group):
answers = [ok for g, ok in rows if g == group]
return sum(answers) / len(answers)
rate_a = approval_rate(LOG, "Group A")
rate_b = approval_rate(LOG, "Group B")
gap = abs(rate_a - rate_b)
print(f"Group A pre-approved: {rate_a:.1%}")
print(f"Group B pre-approved: {rate_b:.1%}")
print(f"Gap: {gap * 100:.1f} points")
if gap > 0.05:
print("Gap over our 5-point limit: stop and investigate before launch")Output
Group A pre-approved: 80.0% Group B pre-approved: 65.0% Gap: 15.0 points Gap over our 5-point limit: stop and investigate before launch
Name-swap test on a loan pre-check
Two copies of a file
same facts, one name changed
Model
answers all 400 runs
Compare the groups
approval rate and tone
Result
Gap under the limit
keep testing after each change
Gap over the limit
stop, find the cause, retest
- 1Each file goes to the model with one name changed.
- 2The model's answers come back for all 400 runs.
- 3A gap under the limit lets the change go ahead, with testing kept on.
- 4A gap over the limit stops the release until the team finds the cause and retests.
The 5-point limit is the team's own choice, written down before the test. A gap tells the team where to look. It doesn't prove the cause on its own, so the team checks the rest of the file and tests again. At 200 runs per group, one standard error of the gap is about 4.4 points, so chance alone can move it that far. Treat the 5-point limit as a trigger to look and retest with more files, not as proof.
Can you reduce bias, and where does it stop?
Partly. In a 2023 study, Anthropic's researchers built 70 decision scenarios across society, such as financing and housing eligibility. They systematically varied the demographic information in each prompt. Their Claude 2.0 model showed positive and negative discrimination in some settings when nothing was done about it.
Prompt changes helped a lot: the study found discrimination could be significantly reduced, and in some cases removed altogether, with prompt-based interventions. One of their tested lines asked the model to think about answering in a way that avoids bias or stereotyping. The authors also asked whether these fixes make the model's decisions less useful.
“While we do not endorse or permit the use of language models to make automated decisions for the high-risk use cases we study”
Anthropic, December 2023
In its December 2023 post, Anthropic said it does not endorse or permit automated decisions for the high-risk cases it studied. A prompt is one layer, and it has to sit beside the others.
Bias also covers opinions. In November 2025 Anthropic published an automated test for political even-handedness, built on thousands of prompts across hundreds of political stances. Its stated aim is to treat opposing viewpoints with equal depth, engagement and quality of analysis.
- 1
Measure before launch
Run paired tests on every group the product touches, and write the limit down before you look at the results.
- 2
Test after every change
New prompts, new models and new data can move the gap again, so run the same tests each time.
- 3
Keep people on high-stakes calls
Let the model summarise and draft. Keep yes or no calls on loans, jobs and claims with a trained person, or leave the model out.
- 4
Watch it in use
Track the gap each month and log complaints by group. Act when the gap grows.
Tip
Asked how to fix bias? Don't claim it's gone. Say how you measure it, which limit you set, what you changed, and who signs off the risky calls.
How would you check an LLM that ranks job applicants?
A recruiter's team builds a tool that reads 3,000 made-up applications for 40 roles and ranks them for the hiring manager. Before launch I would run the name-swap test on paired CVs, with the same skills and experience and only the name changed.
Then I would check the details that can stand in for a group, such as postcode, school name or a gap in work history. Those can carry bias even when names are removed. I would measure the ranking gap, set a limit with the hiring team in writing, and ask legal what the law requires in each place they hire.
A person makes the final call, and the tool's notes say so. Anthropic's study looks at high-risk use cases, such as determining financing or housing eligibility. In 2023 it said it does not endorse or permit automated decisions for the high-risk cases it studied.
What does the interviewer want to hear?
A strong answer covers
- A plain definition: bias is uneven treatment, sometimes learned from text, and fairness is a standard you measure.
- Where it comes from: training data, the model's own procedure, and where it is used.
- Two kinds of harm: stereotyping, and unequal outcomes.
- How you measure it: the same request with one detail changed, then the gap compared.
- What helps and where it stops: prompt wording helps, but limits and human review are still needed.
- Honest limits: defining fairness is a team choice, and checks must keep running after launch.
Common traps
Trap"Our model is unbiased."
BetterThe survey says LLMs can learn, perpetuate and amplify harmful social biases, so show the tests, the gaps you found and the limits you set.
Trap"A system prompt that says be fair fixes it."
BetterPrompt wording helps and is worth testing, but it doesn't remove bias alone. Measure it.
Trap"Fairness means every answer is identical."
BetterFairness is measured against a defined standard. Equal quality and equal outcomes can differ, so define which one matters for this product.
Can you spot the bias problem?
Spot the gap
A loan pre-check team tests its LLM. Which result should they act on first?
Quick check
Which step gives the most reliable protection for a loan pre-check LLM?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
- Q457How do you measure fairness?Coming soon
- Q435Data bias vs model bias?Coming soon
- Q462Model cards vs system cards?Coming soon
- Q460What are the EU AI Act risk tiers?Coming soon
Learn it in depth
Last updated on 26 November 2026
Building an LLM that makes decisions about people?
I design and build AI products and agents, including the checks that catch bias before launch: paired tests, limits and human review. Book a short call and tell me what your model decides.