BiasFilter: An Inference-Time Debiasing Framework for Large Language Models

Xiaoqing Cheng, Ruizhe Chen, Hongying Zan, Yuxiang Jia, Min Peng

TL;DR

This paper introduces BiasFilter, a novel framework that effectively debiases large language models (LLMs) during inference without requiring retraining. By dynamically filtering biased outputs at the token level, BiasFilter significantly reduces social biases across various LLMs while maintaining generation quality, offering a practical solution for fairer AI.

What Problem Does This Paper Address?

Large Language Models (LLMs) have become incredibly powerful, but they often inherit and amplify social biases present in their training data. These biases can manifest as unfair, prejudiced, or stereotypical outputs, reinforcing harmful societal stereotypes and leading to real-world consequences. Existing debiasing methods often require extensive computational resources, human annotation, or model retraining, making them impractical for many applications, especially for API-based LLMs or open-ended generation tasks where real-time intervention is crucial. The challenge is to develop a method that can effectively mitigate bias during the generation process itself, without compromising the model's inherent capabilities or requiring significant overhead.

Methods

BiasFilter is an inference-time, model-agnostic debiasing framework. Its core innovation lies in its ability to intervene during the text generation process. Here's how it works:

  • Dynamic Filtering: Instead of retraining the LLM, BiasFilter periodically evaluates intermediate generated outputs at fixed token intervals.
  • Candidate Management: It maintains an active set of candidate continuations for the text being generated.
  • Fairness Reward Model: A key component is a custom-trained implicit reward model. This model is trained on a newly constructed "fairness preference dataset" to assess the fairness of generated text segments.
  • Filtering Mechanism: If a candidate continuation is flagged as biased by the reward model, it is discarded. Only continuations that pass the fairness check are allowed to proceed and be further extended.
  • Model Agnosticism: BiasFilter can be seamlessly integrated with both open-source LLMs and API-based services, as it doesn't modify the base model's parameters.

Datasets

  • Fairness Preference Dataset: A new dataset was constructed for training the fairness reward model. This involved:
  • Response Sampling: Using prompts from the HolisticBias dataset and sampling responses from five different LLMs (Llama-2, Meta-Llama-3, Mistral-7B, GPT-3.5-Turbo, GPT-4).
  • Multi-step Annotation: Using GPT-4 and human annotators to score bias levels and create preference pairs (preferred vs. less preferred responses).
  • Evaluation Datasets:
    • CEB (Compositional Evaluation Benchmark): Used for evaluating bias in continuation and conversation tasks across age, gender, race, and religion.
  • FairMT (Fairness in Multi-Turn Dialogue): Used for evaluating bias in multi-turn conversational scenarios across six bias attributes and six task types.

Key Insights and Ideas

  • Inference-Time Intervention is Key: The paper strongly advocates for inference-time debiasing as a practical and scalable solution, especially for API-based models where fine-tuning is not an option.
  • Custom Reward Model Outperforms General LLMs: The authors found that their specifically trained fairness reward model was more reliable for debiasing than using general-purpose LLMs (like GPT-4) as judges, highlighting the importance of tailored evaluation.
  • Balancing Bias Mitigation and Generation Quality: A crucial insight is that BiasFilter not only reduces bias but, in some cases, even improves generation quality metrics like fluency and diversity, suggesting that debiasing can sometimes lead to more coherent outputs.
  • Model Agnosticism is a Major Advantage: The ability to apply the same debiasing framework across a wide range of LLMs, including proprietary ones, is a significant practical benefit.

Key Results

  • Significant Bias Reduction: BiasFilter consistently outperformed six competitive baselines in mitigating social biases across various LLMs and datasets (CEB and FairMT). For instance, on the CEB dataset, BiasFilter achieved the lowest Bias Scores in most settings.
  • Improved Regard Scores: The method not only reduced bias but also improved "Regard scores" (measuring social favorability), indicating enhanced fairness and positive representation.
  • Scalability: The framework demonstrated scalability across a broad range of models, including open-source LLMs and black-box APIs like GPT-3.5-Turbo and GPT-40.
  • Efficiency Trade-off: While introducing some latency, BiasFilter offers a favorable trade-off, providing superior debiasing effects without compromising generation quality. The optimal segment length for evaluation was found to be around 128 tokens.

Limitations and Future Work

  • Reward Model Training Cost: BiasFilter requires training a dedicated reward model, which incurs an initial cost.
  • Inference Latency: The inference-time filtering process adds some latency to text generation.
  • Scope of Bias: The current dataset and evaluation focus on social bias in text generation, not toxicity.
  • Future Work: The authors plan to expand their fairness preference dataset to include toxicity and a broader spectrum of task types. They aim to construct a large-scale dataset covering both social bias and toxicity for more comprehensive debiasing.

Summary updated

BibTeX
@inproceedings{cheng2025biasfilter,
  author = {Xiaoqing Cheng and Ruizhe Chen and Hongying Zan and Yuxiang Jia and Min Peng},
  title = {{BiasFilter: An Inference-Time Debiasing Framework for Large Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
}
Figure