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

AI and LLM interview question Q456, Data, privacy, ethics and governance. Beginner, very common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/bias-and-fairness-in-llms

## Say it in 30 seconds

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.

## Say it in 2 minutes

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.

- **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)

*Diagram, Where LLM bias comes from: Two sources feed the model: its training text and the setting it is used in. Its bias shows up in tone and in yes or no calls. Teams measure each group's results to find it.*
1. Old writing carries old stereotypes into training.
2. The setting it is used in can change what it does.
3. The model learns patterns from all of it, and they show up in tone.
4. The same patterns can push its yes or no calls too.
5. Measuring 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.

```python
# 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:

```text
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
```

*Diagram, Name-swap test on a loan pre-check: Each of 200 files runs twice, once per name group, with only the name changed. The gap in approval rates decides what happens next.*
1. Each file goes to the model with one name changed.
2. The model's answers come back for all 400 runs.
3. A gap under the limit lets the change go ahead, with testing kept on.
4. A 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." Better: The 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." Better: Prompt wording helps and is worth testing, but it doesn't remove bias alone. Measure it.
- Trap: "Fairness means every answer is identical." Better: Fairness 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?

A. The model's approval rates were 71% and 70%, and the team logged the result.
B. The tone was polite for every name in the 400 test runs.
C. Same files, same income. Pre-approval was 80% for Group A and 65% for Group B.
D. After a prompt change, the gap fell to 3 points, and monthly testing continues.

**Answer:** C. The files are identical except for the name group, and the gap is 15 points. That is the warning sign the name-swap test exists to catch. The other results show equal rates or a fix that is still being watched.

**Quick check:** Which step gives the most reliable protection for a loan pre-check LLM?

A. Add "be fair" to the system prompt and ship it.
B. Use a bigger model, since bigger models are less biased.
C. Measure the gap across name groups before launch, set a limit, and keep a person on final loan decisions.
D. Remove every name from the data, so bias has nothing to attach to.

**Answer:** C. Measured gaps show what is happening, a written limit makes the team act, and a person catches cases the tests miss. Prompt wording alone, a bigger model or removing names do not end it, because other details can stand in for a group.

## Can you answer these from memory?

**Flash cards**

- **What is bias in an LLM?** Uneven treatment of people or ideas, sometimes from stereotypes in its training text.
- **Where does it come from?** The training data, the model's own training and inference procedure, and the setting it is deployed in.
- **What is the name-swap test?** Keep a request the same, change one detail such as the name, and compare the answers.
- **What are the two kinds of harm?** Representational (stereotyping a group) and allocational (uneven outcomes and resources).
- **Can a prompt remove bias?** It can cut the gap a lot, and in some cases remove it, but you still measure and keep testing.
- **Should an LLM make high-stakes yes or no calls alone?** Anthropic said in 2023 it does not permit automated decisions for high-risk cases. Keep a person in.

## Likely follow-up questions

- Q457 How do you measure fairness? (full answer coming)
- Q435 Data bias vs model bias? (full answer coming)
- Q462 Model cards vs system cards? (full answer coming)
- Q460 What are the EU AI Act risk tiers? (full answer coming)

## Learn it in depth

- [Checking Who Your AI Works For](https://designervenkat.online/learn/ai-engineering/bias-and-fairness)
