B ias F ilter: An Inference-Time Debiasing Framework for Large Language Models (2025)

Abstract: Mitigating social bias in large language models (LLMs) has become an increasingly important research objective. However, existing debiasing methods often incur high human and computational costs, exhibit limited effectiveness, and struggle to scale to larger models and open-ended generation tasks. To address these limitations, this paper proposes BiasFilter, a model-agnostic, inference-time debiasing framework that integrates seamlessly with both open-source and API-based LLMs. Instead of relying on retraining with balanced data or modifying model parameters, BiasFilter enforces fairness by filtering generation outputs in real time. Specifically, it periodically evaluates intermediate outputs every few tokens, maintains an active set of candidate continuations, and incrementally completes generation by discarding low-reward segments based on a fairness reward signal. To support this process, we construct a fairness preference dataset and train an implicit reward model to assess token-level fairness in generated responses. Extensive experiments demonstrate that BiasFilter effectively mitigates social bias across a range of LLMs while preserving overall generation quality.

## introduction with the rapid advancement of large language models (llms), the scope of natural language generation (nlg) tasks has expanded significantly @xcite @xcite , enabling a broad range of applications across diverse domains. however, recent studies have revealed that llms often exhibit social biases toward certain demographic groups @xcite @xcite @xcite . such biased outputs can distort representations of marginalized communities, reinforce societal stereotypes, and undermine fairness @xcite , ultimately leading to serious real-world consequences. these findings underscore the urgent need for practical and effective debiasing methods. existing approaches to mitigating social bias in llms can be broadly categorized into prompt-tuning-based and fine-tuning-based methods. prompt-tuning-based methods @xcite @xcite @xcite aim to steer model outputs by designing fairness-oriented prompts or incorporating explicit reasoning instructions. while offering lightweight guidance, they often lack fine-grained control, particularly in multiturn dialogues or long-form outputs @xcite . in contrast, finetuning-based methods employ techniques such as feature subspace manipulation @xcite , contrastive representation learning @xcite , and reinforcement learning @xcite . although these methods achieve stronger debiasing performance, they require significant data and computational resources @xcite , limiting their practicality for llms and apis. in this paper, we propose biasfilter, an inference-time debiasing framework designed to ensure fairness in llms' open-ended generation tasks while significantly reducing the overhead associated with fine-tuning. as illustrated in figure 1 , biasfilter can be seamlessly integrated with existing llms or api-based services, enabling real-time evaluation of content fairness and filtering biased outputs to prevent bias accumulation throughout the generation process. to enable this functionality, we first construct a fairness preference dataset and train an implicit reward model that provides fairness scores for generated content. during inference, biasfilter maintains an active set of candidate generations and periodically evaluates the model's outputs at fixed token intervals. generations that fail the fairness check are discarded, while those that meet the fairness criteria continue to be extended. we conduct comprehensive experiments on seven open-source large language models (llama, mistral, and qwen) and two black-box models (gpt-3.5-turbo and gpt-4o), using two widely adopted generative benchmarks: ceb @xcite and fairmt @xcite . these datasets cover both single-turn and multi-turn scenarios across conversational and continuation tasks. experimental results show that biasfilter substantially mitigates social biases related to age, gender, race, and religion, consistently outperforming six competitive baselines. moreover, biasfilter preserves-and in some cases even improves-the fluency and diversity of generated content. further analysis confirms that biasfilter is both modelagnostic and efficient, striking a strong balance between debiasing effectiveness and computational cost. our main contributions are: ## conclusion in this work, we present biasfilter, a novel inference-time debiasing framework that effectively reduces social bias in large language models without requiring additional fine-tuning. biasfil-ter is model-agnostic and seamlessly integrates with both open-source and black-box llms. extensive experiments across diverse benchmarks and model families demonstrate that biasfilter consistently outperforms competitive baselines in mitigating bias across continuation and multi-turn dialogue tasks, while maintaining-or even enhancing-language fluency and diversity. these results highlight the practicality and generalizability of bi-asfilter as a lightweight, plug-and-play solution for fair text generation.