الإنصاف: الحد من التحيز
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
بعد تحديد مصدر الانحياز
في بيانات التدريب، يمكننا اتّخاذ خطوات استباقية لمحاولة التخفيف من تأثيره. هناك استراتيجيتان رئيسيتان يستخدِمهما مهندسو تعلُّم الآلة عادةً لمعالجة الانحياز:
- زيادة بيانات التدريب
- ضبط دالة الخسارة بالنموذج.
زيادة بيانات التدريب
إذا كشف تدقيق بيانات التدريب عن مشكلات تتعلق بالبيانات المفقودة أو غير الصحيحة
أو المحرفة، فغالبًا ما تكون الطريقة الأسهل لمعالجة المشكلة هي جمع بيانات إضافية.
ومع أنّ زيادة بيانات التدريب قد تكون مثالية، إلا أنّ الجانب السلبي
لهذا النهج هو أنّه قد يكون غير عملي أيضًا، إما بسبب نقص
البيانات المتاحة أو بسبب قيود الموارد التي تعوق جمع البيانات. على سبيل المثال،
قد يكون جمع المزيد من البيانات مكلفًا جدًا أو يستغرق وقتًا طويلاً، أو قد لا يكون مجديًا بسبب
القيود القانونية أو المتعلقة بالخصوصية.
تعديل وظيفة التحسين في النموذج
في الحالات التي لا يكون فيها جمع بيانات تدريب إضافية مجديًا، يمكن تعديل كيفية احتساب الخسارة أثناء تدريب النموذج كأحد الحلول البديلة للتخفيف من الانحياز. وعادةً ما نستخدم دالة تحسين مثل
الخسارة اللوغاريتمية لفرض عقوبات على توقّعات النموذج المغلوطة. ومع ذلك، لا تأخذ خسارة السجلّ عضوية المجموعة الفرعية في الاعتبار. لذا، بدلاً من استخدام مقياس انخفاض القصور، يمكننا اختيار إحدى وظائف التحسين المصممة لمعاقبة الأخطاء بطريقة الوعي بالإنصاف ومكافحة أوجه الاختلال التي حدّدناها في بيانات التدريب.
توفر مكتبة معالجة النماذج من TensorFlow برامج خدمات لتطبيق طريقتين مختلفتين للحد من التحيز أثناء تدريب النموذج:
MinDiff:تهدف مقياس MinDiff إلى موازنة الأخطاء في شريحتَين مختلفتَين من البيانات (الطلاب الذكور/الإناث مقابل الطلاب غير الثنائية الجنس) من خلال إضافة عقوبة على الاختلافات في توزيعات التوقّعات للجماعتَين.
إقران لوجيت معادِل:
يهدف إقران لوجيت معقّد (CLP) إلى ضمان أنّ تغيير سمة حساسة لمثال معيّن لا يؤدي إلى تغيير توقّعات النموذج لهذا المثال. على سبيل المثال، إذا كانت مجموعة بيانات تدريب تحتوي على مثالين متطابقة في قيم الخصائص، إلا أن أحدهما يحتوي على قيمة gender
وهي male
والأخرى تحتوي على gender
بقيمة nonbinary
، فستضيف CLP عقوبة إذا كانت التوقعات لهذين المثالين مختلفين.
تعتمد الأساليب التي تختارها لضبط دالة التحسين
على حالات استخدام النموذج. في القسم التالي، سنلقي نظرة عن كثب على كيفية تقييم نموذج من حيث المساواة من خلال مراعاة حالات الاستخدام هذه.
تمرين: التحقّق من فهمك
أي من العبارات التالية صواب فيما يتعلق بأساليب تخفيف التحيز؟
يفرض كلّ من مقياسَي MinDiff وCLP عقوبات على الاختلافات في أداء النموذج
المرتبطة بالسمات الحسّاسة.
تهدف كلتا الطريقتَين إلى تخفيف الانحياز من خلال معاقبة أخطاء التنبؤ
الناتجة عن عدم التوازن في كيفية تمثيل السمات الحسّاسة
في بيانات التدريب.
يفرض مقياس MinDiff عقوبات على الاختلافات في التوزيع العام
للتوقّعات لشرائح مختلفة من البيانات، في حين يفرض مقياس CLP عقوبات على
التناقضات في التوقّعات لزوجَين فرديَّين من الأمثلة.
يعالج مقياس MinDiff الانحياز من خلال مواءمة توزيعات الدرجات لمجموعتَين فرعيتَين. يعالج CLP الانحياز من خلال التأكّد من عدم التعامل مع الأمثلة الفردية
بشكلٍ مختلف بسبب انتمائها إلى مجموعة فرعية فقط.
ستساعدك إضافة المزيد من الأمثلة إلى مجموعة بيانات التدريب دائمًا في
التصدي للتحيز في توقّعات النموذج.
إنّ إضافة المزيد من أمثلة التدريب هي استراتيجية فعّالة لمحاولة التخفيف من التحيز، ولكن يجب مراعاة تركيبة بيانات التدريب الجديدة. إذا كانت أمثلة التدريب الإضافية تعرِض عدم توازن مشابهًا
للبيانات الأصلية، من المحتمل ألا تساعد في تخفيف
الانحياز الحالي.
إذا كنت تحدّ من الانحياز من خلال إضافة المزيد من بيانات التدريب، يجب
عدم استخدام MinDiff أو CLP أثناء التدريب.
ويمكن أن تتم إضافة المزيد من بيانات التدريب وتطبيق أساليب، مثل MinDiff أو CLP. على سبيل المثال، قد يتمكّن مهندس تعلُّم الآلة
من جمع بيانات تدريب إضافية كافية لتقليل التباين
في الأداء بنسبة %30، ثم استخدام MinDiff لتقليل التباين
بنسبة %50 أخرى.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2024-11-10 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2024-11-10 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\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)"]]