DEV Community

Manohar Papasani
Manohar Papasani

Posted on

How do you check if output content of an LLM is biased or not?

Asked in a GenAI developer interview.

What they are really testing: whether you can turn a vague fairness concern into a measurable evaluation pipeline with clear criteria, statistics, and ongoing monitoring.

A strong answer:

  • Define bias for the specific use case first: which groups or attributes matter, and which harms to measure, such as stereotyping, unequal answer quality, differing refusal rates, or skewed recommendations. Bias is task-specific, so there is no single universal score.
  • Build a counterfactual (paired-prompt) test set: identical prompts that vary only one protected or proxy attribute, such as names, pronouns, regions, or age. Compare outputs for differences in tone, accuracy, refusals, and recommendations.
  • Score outputs with a structured rubric, using an LLM judge plus human review. Calibrate the judge against a labeled sample and report agreement (for example, Cohen's kappa) instead of trusting one automated judge.
  • Slice results by group and apply statistical tests over a large enough sample. Track rates like refusal, positive-sentiment, or shortlisting outcomes, and check whether gaps are significant rather than relying on a few eyeballed examples.
  • Use public benchmarks such as BBQ, StereoSet, or CrowS-Pairs as a baseline, then add domain-specific data, since general benchmarks often miss the failure modes of your application.
  • Operationalize it: run these tests as regression suites in CI for every prompt, model, or retrieval change, sample live traffic for monitoring, and feed flagged cases back into the test set. Re-evaluate mitigations such as prompt changes, grounding, fine-tuning, or output filters before shipping them.

Common mistakes:

  • Relying on one generic "is this biased?" prompt or a off-the-shelf toxicity classifier, which misses subtle disparities in quality or treatment.
  • Checking a handful of hand-picked examples with no group slicing, no baseline, and no significance testing.
  • Treating bias as a one-time pre-launch check instead of monitoring drift after model, prompt, or data changes.

How would you structure this evaluation for a hiring or lending assistant, where the stakes are much higher? Curious how others would approach it.


Originally shared on LinkedIn.

An AI interview question every day, leadership for tech people and hands-on AI learning:

Top comments (2)

Collapse
 
aitrainingjobs profile image
AITraining.jobs •

For the hiring or lending case I'd add two things to your list, both about who sets the bar.

First, borrow the legal tests instead of inventing a threshold. For hiring, the four-fifths rule in the federal Uniform Guidelines treats a group's selection rate below 80% of the highest group's as evidence of adverse impact, and New York City's Local Law 144 requires an independent bias audit of automated hiring tools that reports selection rates and impact ratios by sex and race/ethnicity. So the shortlisting slice of your eval can report exactly the numbers an auditor will ask for. For credit, ECOA and Regulation B require specific reasons for an adverse action, and the CFPB has said a complex model is no excuse, so "does the assistant give the correct principal reasons for a denial" becomes its own dimension, scored per group.

Second, the human review step has to be domain review. A generic annotator can tell you the tone differs between two counterfactual prompts; it takes an underwriter or a recruiter to say whether a different recommendation reflects a legitimate credit or job-related factor or a proxy for the attribute. That is also the expensive part of the pipeline. I work on AITraining.jobs, which reads the job boards of the platforms AI labs pay for this kind of expert grading: on 2 Nov, 242 roles for finance professionals were open across 25 of them, typically $50 to $150/hr with a median of $80, including commercial and retail banking expert roles at $100+/hr posted in the last week. Red-teaming and safety roles, the nearest thing to dedicated bias testers, were rarer: 55 open, median $80/hr.

So for high stakes I'd keep the expert-labelled calibration set small and targeted: spend it on the cases where the LLM judge and the counterfactual pair disagree, and on the decision boundary, not on a random sample.

Collapse
 
technaom profile image
Manohar Papasani •

This is a really useful addition, thank you. Using existing legal tests like the four-fifths rule, NYC Local Law 144 impact ratios and ECOA adverse-action reasons is a much better starting point than inventing your own thresholds. It also means the eval reports the numbers an auditor will actually ask for. Treating "correct principal reasons for denial" as its own per-group dimension is a great idea. I agree on domain review too: a generic annotator can catch a change in tone, but only an underwriter or recruiter can tell a legitimate factor from a proxy. And spending the small expert-labelled set where the LLM judge and the counterfactual pair disagree is the right way to use that budget.