Stay organized with collectionsSave and categorize content based on your preferences.
Once a source ofbiashas been identified in the training data, we can take proactive steps to
mitigate its effects. There are two main strategies that machine learning (ML)
engineers typically employ to remediate bias:
Augmenting the training data.
Adjusting the model's loss function.
Augmenting the training data
If an audit of the training data has uncovered issues with missing, incorrect,
or skewed data, the most straightforward way to address the problem is often
to collect additional data.
However, while augmenting the training data can be ideal, the downside of
this approach is that it can also be infeasible, either due to a lack of
available data or resource constraints that impede data collection. For example,
gathering more data might be too costly or time-consuming, or not viable due to
legal/privacy restrictions.
Adjusting the model's optimization function
In cases where collecting additional training data is not viable, another
approach for mitigating bias is to adjust how loss is calculated during model
training. We typically use an optimization function likelog lossto penalize incorrect model
predictions. However, log loss does not take subgroup membership into
consideration. So instead of using log loss, we can choose an optimization
function designed to penalize errors in a fairness-aware fashion that
counteracts the imbalances we've identified in our training data.
The TensorFlow Model Remediation Library provides utilities for applying two
different bias-mitigation techniques during model training:
MinDiff:
MinDiff aims to balance the errors for two different slices of data
(male/female students versus nonbinary students) by adding a penalty for
differences in the prediction distributions for the two groups.
Counterfactual Logit Pairing:
Counterfactual Logit Pairing (CLP) aims to ensure that changing a sensitive
attribute of a given example doesn't alter the model's prediction for that
example. For example, if a training dataset contains two examples whose
feature values are identical, except one has agendervalue ofmaleand
the other has agendervalue ofnonbinary, CLP will add a penalty if
the predictions for these two examples are different.
The techniques you choose for adjusting the optimization function are
dependent on the use cases for the model. In the next section, we'll take a
closer look at how to approach the task of evaluating a model for fairness
by considering these use cases.
Exercise: Check your understanding
Which of the following statements regarding bias-mitigation techniques are true?
Both MinDiff and CLP penalize discrepancies in model performance
tied to sensitive attributes
Both techniques aim to mitigate bias by penalizing prediction
errors resulting from imbalances in how sensitive attributes are
represented in training data.
MinDiff penalizes differences in the overall distribution of
predictions for different slices of data, whereas CLP penalizes
discrepancies in predictions for individual pairs of examples.
MinDiff addresses bias by aligning score distributions for two
subgroups. CLP tackles bias by ensuring that individual examples are
not treated differently solely because of their subgroup membership.
Adding more examples to the training dataset will always help
counteract bias in a model's predictions.
Adding more training examples is an effective strategy for
mitigating bias, but the composition of the new training data
matters. If the additional training examples exhibit similar
imbalances to the original data, they probably won't help mitigate
the existing bias.
If you are mitigating bias by adding more training data, you
shouldn't also apply MinDiff or CLP during training.
Augmenting training data and applying techniques like MinDiff or CLP
can be complementary. For example, an ML engineer might be able
to collect enough additional training data to reduce a discrepancy
in performance by 30%, and then use MinDiff to further reduce the
discrepancy by another 50%.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eMachine learning engineers use two primary strategies to mitigate bias in models: augmenting training data and adjusting the model's loss function.\u003c/p\u003e\n"],["\u003cp\u003eAugmenting training data involves collecting additional data to address missing, incorrect, or skewed data, but it can be infeasible due to data availability or resource constraints.\u003c/p\u003e\n"],["\u003cp\u003eAdjusting the model's loss function involves using fairness-aware optimization functions like MinDiff or Counterfactual Logit Pairing to penalize errors based on sensitive attributes and counteract imbalances in training data.\u003c/p\u003e\n"],["\u003cp\u003eMinDiff aims to balance errors between different data slices by penalizing differences in prediction distributions, while Counterfactual Logit Pairing penalizes discrepancies in predictions for similar examples with different sensitive attribute values.\u003c/p\u003e\n"],["\u003cp\u003eChoosing the right bias-mitigation technique depends on the specific use case of the model, and augmenting training data and adjusting the loss function can be used in conjunction for optimal bias reduction.\u003c/p\u003e\n"]]],[],null,["# Fairness: Mitigating bias\n\nOnce a source of [**bias**](/machine-learning/glossary#bias-ethicsfairness)\nhas been identified in the training data, we can take proactive steps to\nmitigate its effects. There are two main strategies that machine learning (ML)\nengineers typically employ to remediate bias:\n\n- Augmenting the training data.\n- Adjusting the model's loss function.\n\nAugmenting the training data\n----------------------------\n\nIf an audit of the training data has uncovered issues with missing, incorrect,\nor skewed data, the most straightforward way to address the problem is often\nto collect additional data.\n\nHowever, while augmenting the training data can be ideal, the downside of\nthis approach is that it can also be infeasible, either due to a lack of\navailable data or resource constraints that impede data collection. For example,\ngathering more data might be too costly or time-consuming, or not viable due to\nlegal/privacy restrictions.\n\nAdjusting the model's optimization function\n-------------------------------------------\n\nIn cases where collecting additional training data is not viable, another\napproach for mitigating bias is to adjust how loss is calculated during model\ntraining. We typically use an optimization function like\n[**log loss**](/machine-learning/glossary#log-loss) to penalize incorrect model\npredictions. However, log loss does not take subgroup membership into\nconsideration. So instead of using log loss, we can choose an optimization\nfunction designed to penalize errors in a fairness-aware fashion that\ncounteracts the imbalances we've identified in our training data.\n\nThe TensorFlow Model Remediation Library provides utilities for applying two\ndifferent bias-mitigation techniques during model training:\n\n- [**MinDiff**](https://www.tensorflow.org/responsible_ai/model_remediation/min_diff/guide/mindiff_overview):\n MinDiff aims to balance the errors for two different slices of data\n (male/female students versus nonbinary students) by adding a penalty for\n differences in the prediction distributions for the two groups.\n\n- [**Counterfactual Logit Pairing**](https://www.tensorflow.org/responsible_ai/model_remediation/counterfactual/guide/counterfactual_overview):\n Counterfactual Logit Pairing (CLP) aims to ensure that changing a sensitive\n attribute of a given example doesn't alter the model's prediction for that\n example. For example, if a training dataset contains two examples whose\n feature values are identical, except one has a `gender` value of `male` and\n the other has a `gender` value of `nonbinary`, CLP will add a penalty if\n the predictions for these two examples are different.\n\nThe techniques you choose for adjusting the optimization function are\ndependent on the use cases for the model. In the next section, we'll take a\ncloser look at how to approach the task of evaluating a model for fairness\nby considering these use cases.\n\n### Exercise: Check your understanding\n\nWhich of the following statements regarding bias-mitigation techniques are true? \nBoth MinDiff and CLP penalize discrepancies in model performance tied to sensitive attributes \nBoth techniques aim to mitigate bias by penalizing prediction errors resulting from imbalances in how sensitive attributes are represented in training data. \nMinDiff penalizes differences in the overall distribution of predictions for different slices of data, whereas CLP penalizes discrepancies in predictions for individual pairs of examples. \nMinDiff addresses bias by aligning score distributions for two subgroups. CLP tackles bias by ensuring that individual examples are not treated differently solely because of their subgroup membership. \nAdding more examples to the training dataset will always help counteract bias in a model's predictions. \nAdding more training examples is an effective strategy for mitigating bias, but the composition of the new training data matters. If the additional training examples exhibit similar imbalances to the original data, they probably won't help mitigate the existing bias. \nIf you are mitigating bias by adding more training data, you shouldn't also apply MinDiff or CLP during training. \nAugmenting training data and applying techniques like MinDiff or CLP can be complementary. For example, an ML engineer might be able to collect enough additional training data to reduce a discrepancy in performance by 30%, and then use MinDiff to further reduce the discrepancy by another 50%.\n| **Key terms:**\n|\n| - [Bias (ethics/fairness)](/machine-learning/glossary#bias-ethicsfairness)\n- [Log Loss](/machine-learning/glossary#log-loss) \n[Help Center](https://support.google.com/machinelearningeducation)"]]