---
title: "Evaluating Language Model Bias with 🤗 Evaluate"
description: "Hugging Face's Evaluate library now includes bias measurements for causal language models such as GPT-2 and BLOOM."
url: "https://swe.quest/articles/evaluating-language-model-bias-with-evaluate-b158fee88571748c"
canonical: "https://huggingface.co/blog/evaluating-llm-bias"
source: "Hugging Face"
published: "2022-10-24"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["evals","ai-safety","llms","python"]
---

# Evaluating Language Model Bias with 🤗 Evaluate

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2022-10-24, 8 min read, How-to. Original: [https://huggingface.co/blog/evaluating-llm-bias](https://huggingface.co/blog/evaluating-llm-bias)

## Summary

Hugging Face's Evaluate library now includes bias measurements for causal language models such as GPT-2 and BLOOM. The workflow is to prompt a model with curated datasets and then score the generations. Three measurements are demonstrated with code: toxicity (WinoBias prompts scored by the R4 Target hate classifier), regard/polarity across groups (BOLD profession prompts), and HONEST for hurtful completions about LGBTQAI+ groups. Small pronoun or group swaps produce measurably different toxicity, regard and hurtfulness scores, but these datasets are reductive, so several complementary metrics should be used together rather than treated as the whole truth about model bias.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Evaluation](https://swe.quest/tags/evals.md) (AI & ML)
- [AI safety](https://swe.quest/tags/ai-safety.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- Python ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- Hugging Face Transformers basics
- causal language models

## Keywords

Hugging Face Evaluate, GPT-2, WinoBias, BOLD, HONEST, Regard, Hugging Face Datasets

## Related posts

- [Red-Teaming Large Language Models](https://swe.quest/articles/red-teaming-large-language-models-a911211681792c3b.md): Hugging Face · 2023-02-24 · Easy · 6 min read · AI safety, Evaluation, LLMs
  Red-teaming evaluates LLMs by crafting natural-language prompts that elicit harmful outputs such as toxicity, bias, misinformation or leaked personal data, and it differs from adversarial attacks, which can use unintelligible inputs.
- [An Introduction to AI Secure LLM Safety Leaderboard](https://swe.quest/articles/an-introduction-to-ai-secure-llm-safety-leaderboard-3389612600bb2dd0.md): Hugging Face · 2024-01-26 · Easy · 5 min read · Evaluation, AI safety, LLMs
  The LLM Safety Leaderboard, built on the Hugging Face leaderboard template, ranks open and closed models using DecodingTrust, a NeurIPS 2023 evaluation framework covering eight trustworthiness perspectives: toxicity, stereotype bias, adversarial robustness, OOD robustness, adversarial demonstrations, privacy, machine ethics and fairness.
- [Can foundation models label data like humans?](https://swe.quest/articles/can-foundation-models-label-data-like-humans-963e130c732d79cb.md): Hugging Face · 2023-06-12 · Hard · 17 min read · Evaluation, LLMs, Model training
  Human preference labels from Scale AI and GPT-4 pairwise ratings on a 327-prompt blind test set produce the same Elo ordering of four open instruction-tuned models (Vicuna-13B, Koala-13B, OpenAssistant-12B, Dolly-12B), but the margins between models differ.
- [CyberSecEval 2 - A Comprehensive Evaluation Framework for Cybersecurity Risks and Capabilities of Large Language Models](https://swe.quest/articles/cyberseceval-2-a-comprehensive-evaluation-framework-for-cybersecurity-risks-and-b77206af9c9d754e.md): Hugging Face · 2024-05-24 · Easy · 5 min read · Evaluation, AI safety, LLMs, Application security
  CyberSecEval 2 is Meta's open-source benchmark suite measuring LLM cybersecurity risks across five areas: insecure code generation (mapped to CWE), prompt injection susceptibility, compliance with cyber-attack requests versus false refusals of benign prompts, code interpreter abuse, and automated CTF-style exploitation.
- [Introducing the Red-Teaming Resistance Leaderboard](https://swe.quest/articles/introducing-the-red-teaming-resistance-leaderboard-e6f29b275caeecf9.md): Hugging Face · 2024-02-23 · Easy · 6 min read · AI safety, Evaluation, LLMs
  The Red-Teaming Resistance leaderboard from Haize Labs and Hugging Face scores LLMs on how often they safely refuse realistic, human-written jailbreak prompts.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
