Table of Contents
Fetching ...

Improving Fairness in LLMs Through Testing-Time Adversaries

Isabela Pereira Gregio, Ian Pons, Anna Helena Reali Costa, Artur Jordão

TL;DR

This paper tackles bias in LLMs by proposing a training-free method that uses testing-time adversaries: it perturbs sensitive attributes to create $N$ variants, computes the consistency rate $CR_j$ across prompts $P_j$ as the fraction of variants whose outputs match the original, and outputs an adjusted prediction using the rule $\text{Adjusted} = \mathcal{F}(x, P_j)$ if $CR_j \ge t$, otherwise $1 - \mathcal{F}(x, P_j)$. The approach is model- and data-agnostic, requiring only forward passes and no fine-tuning. Empirical results on the COMPAS task with Llama3 8B show substantial fairness improvements (up to $27$ percentage points) while maintaining predictive performance, and a comparison against a fine-tuning baseline suggests advantages in robustness and computational cost. Overall, the method offers a practical path to fairer and more reliable LLM outputs in ethically challenging settings.

Abstract

Large Language Models (LLMs) push the bound-aries in natural language processing and generative AI, driving progress across various aspects of modern society. Unfortunately, the pervasive issue of bias in LLMs responses (i.e., predictions) poses a significant and open challenge, hindering their application in tasks involving ethical sensitivity and responsible decision-making. In this work, we propose a straightforward, user-friendly and practical method to mitigate such biases, enhancing the reliability and trustworthiness of LLMs. Our method creates multiple variations of a given sentence by modifying specific attributes and evaluates the corresponding prediction behavior compared to the original, unaltered, prediction/sentence. The idea behind this process is that critical ethical predictions often exhibit notable inconsistencies, indicating the presence of bias. Unlike previous approaches, our method relies solely on forward passes (i.e., testing-time adversaries), eliminating the need for training, fine-tuning, or prior knowledge of the training data distribution. Through extensive experiments on the popular Llama family, we demonstrate the effectiveness of our method in improving various fairness metrics, focusing on the reduction of disparities in how the model treats individuals from different racial groups. Specifically, using standard metrics, we improve the fairness in Llama3 in up to 27 percentage points. Overall, our approach significantly enhances fairness, equity, and reliability in LLM-generated results without parameter tuning or training data modifications, confirming its effectiveness in practical scenarios. We believe our work establishes an important step toward enabling the use of LLMs in tasks that require ethical considerations and responsible decision-making.

Improving Fairness in LLMs Through Testing-Time Adversaries

TL;DR

This paper tackles bias in LLMs by proposing a training-free method that uses testing-time adversaries: it perturbs sensitive attributes to create variants, computes the consistency rate across prompts as the fraction of variants whose outputs match the original, and outputs an adjusted prediction using the rule if , otherwise . The approach is model- and data-agnostic, requiring only forward passes and no fine-tuning. Empirical results on the COMPAS task with Llama3 8B show substantial fairness improvements (up to percentage points) while maintaining predictive performance, and a comparison against a fine-tuning baseline suggests advantages in robustness and computational cost. Overall, the method offers a practical path to fairer and more reliable LLM outputs in ethically challenging settings.

Abstract

Large Language Models (LLMs) push the bound-aries in natural language processing and generative AI, driving progress across various aspects of modern society. Unfortunately, the pervasive issue of bias in LLMs responses (i.e., predictions) poses a significant and open challenge, hindering their application in tasks involving ethical sensitivity and responsible decision-making. In this work, we propose a straightforward, user-friendly and practical method to mitigate such biases, enhancing the reliability and trustworthiness of LLMs. Our method creates multiple variations of a given sentence by modifying specific attributes and evaluates the corresponding prediction behavior compared to the original, unaltered, prediction/sentence. The idea behind this process is that critical ethical predictions often exhibit notable inconsistencies, indicating the presence of bias. Unlike previous approaches, our method relies solely on forward passes (i.e., testing-time adversaries), eliminating the need for training, fine-tuning, or prior knowledge of the training data distribution. Through extensive experiments on the popular Llama family, we demonstrate the effectiveness of our method in improving various fairness metrics, focusing on the reduction of disparities in how the model treats individuals from different racial groups. Specifically, using standard metrics, we improve the fairness in Llama3 in up to 27 percentage points. Overall, our approach significantly enhances fairness, equity, and reliability in LLM-generated results without parameter tuning or training data modifications, confirming its effectiveness in practical scenarios. We believe our work establishes an important step toward enabling the use of LLMs in tasks that require ethical considerations and responsible decision-making.
Paper Structure (17 sections, 3 equations, 6 figures, 1 table)

This paper contains 17 sections, 3 equations, 6 figures, 1 table.

Figures (6)

  • Figure 1: General idea behind the proposed method. Here, we illustrate the characteristics of an individual as the features of a sample (i.e., sentence) $x$. We generate a set of $N$ modified samples through feature perturbation and calculate the consistency rate by evaluating how many predictions ($F(x_i)$) match the original prediction ($F(x)$). Our method considers a result as biased (i.e., unfair or ethical sensitivity) if the consistency rate falls below a predetermined threshold.
  • Figure 2: Simplified organization of a prompt $P_j$. This case shows a bias by associating in all examples the African American race with an affirmative answer for criminal recidivism. Left-mostly. We merge the prompt with a sentence from the content sent to the model. Right-mostly. We send the same prompt along with the perturbed samples.
  • Figure 3: Fairness metrics calculated for each prompt using the Llama3 model without applying our bias reduction method. We call these values “original response”. Prompt $P_j$ means a prompt design.
  • Figure 4: Average difference fairness metrics for the original response and the adjusted response across the different prompts. The greater the bar, the greater the improvement by using the method.
  • Figure 5: Fairness metrics for original Llama 3 and it after applying our method. Here, we evaluate the proposed method considering different amount of perturbations ($N$) at the same threshold $t$ ($t=0.9$). The lower the value, the better the fairness.
  • ...and 1 more figures