LangBiTe: A Platform for Testing Bias in Large Language Models

Sergio Morales, Robert Clarisó, Jordi Cabot · OpenReview

Abstract

The integration of Large Language Models (LLMs) into various software applications raises concerns about their potential biases. Typically, those models are trained on a vast amount of data scrapped from forums, websites, social media and other internet sources, which may instill harmful and discriminating behavior into the model. To address this issue, we present LangBiTe, a testing platform to systematically assess the presence of biases within an LLM. LangBiTe enables development teams to tailor their test scenarios, and automatically generate and execute the test cases according to a set of user-defined ethical requirements. Each test consists of a prompt fed into the LLM and a corresponding test oracle that scrutinizes the LLM's response for the identification of biases. LangBite provides users with the bias evaluation of LLMs, and end-to-end traceability between the initial ethical requirements and the insights obtained.

Introduction

Large Language Models (LLMs) are increasingly integrated into critical software systems, yet they often inherit prejudices and discriminatory logic from their training data. As AI moves into regulated industries, developers face a "traceability gap"—the difficulty of proving a model adheres to specific ethical standards. Regulatory frameworks, such as the EU AI Act, are beginning to mandate safeguards against discrimination. LangBiTe addresses this need by providing a repeatable, scalable, and customizable framework to audit LLMs for hidden harms.

The LangBiTe Architecture

LangBiTe follows a four-stage sequential architecture designed to systematically uncover ethical biases.

The four-stage sequential architecture of LangBiTe: from requirement definition to bias reporting.
  1. Requirement Definition: Users define "Ethical Requirements" in JSON format, specifying concerns (e.g., sexism), sensitive communities, and tolerance levels.
  2. Test Generation: The system utilizes a Prompt Template Library to generate variants of "seed" prompts by injecting different sensitive groups into placeholders.
  3. Execution: Prompts are dispatched to target LLMs via connectors supporting major platforms like OpenAI and HuggingFace.
  4. Evaluation via Oracles: Logical rules, or "Test Oracles," check for consistency across responses. If a model treats one group differently than another for the same question, the oracle flags a failure. It can also utilize a second LLM to perform sentiment analysis or model-graded evaluation on complex responses.

Test Scenarios and Oracles

A core innovation of LangBiTe is its "bring-your-own-ethics" approach. Rather than hard-coding a single moral framework, the platform allows users to define their own requirements and oracles.

An example of a prompt template and its corresponding oracle for testing religious bias.

As shown in Figure 2, a template can be used to test for religious bias by swapping placeholders like {RELIGION1} and {RELIGION2}. The allEqualExpected oracle ensures the model provides a consistent, neutral answer regardless of the specific religions involved. This is particularly effective at catching "double standards," such as the "retaliation test" where a model might permit retaliation for one group but deny it for another.

Datasets and Benchmarking

The platform includes a curated library of over 300 prompt templates in English and Spanish, covering categories such as ageism, religion, racism, and sexism. In a benchmarking study of 16 different LLMs, LangBiTe revealed significant risks. Some models explicitly generated discriminatory statements or showed clear political favoritism, demonstrating that even highly-tuned models require rigorous auditing before deployment.

Limitations and Future Work

While LangBiTe provides a robust framework, it faces challenges such as the potential "meta-bias" of using a second LLM as a judge. Future work will focus on expanding linguistic support beyond English and Spanish and improving the sophistication of oracles to better handle nuanced, long-form responses where bias may be subtly hidden behind polite language.

Summary updated

Abstract

The integration of Large Language Models (LLMs) into various software applications raises concerns about their potential biases. Typically, those models are trained on a vast amount of data scrapped from forums, websites, social media and other internet sources, which may instill harmful and discriminating behavior into the model. To address this issue, we present LangBiTe, a testing platform to systematically assess the presence of biases within an LLM. LangBiTe enables development teams to tailor their test scenarios, and automatically generate and execute the test cases according to a set of user-defined ethical requirements. Each test consists of a prompt fed into the LLM and a corresponding test oracle that scrutinizes the LLM's response for the identification of biases. LangBite provides users with the bias evaluation of LLMs, and end-to-end traceability between the initial ethical requirements and the insights obtained.
BibTeX
@misc{morales2024langbite,
  author = {Sergio Morales and Robert Clarisó and Jordi Cabot},
  title = {{LangBiTe: A Platform for Testing Bias in Large Language Models}},
  year = {2024},
  eprint = {2404.18558},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.18558},
}
Figure