You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,6 +155,20 @@ results['metrics']
155
155
# 'Sentiment Bias': 0.0009947145187601957}}}
156
156
```
157
157
158
+
##### Bias and Fairness Red-Teaming
159
+
To assess worst-case toxicity and counterfactual generations for a given use case, LangFair also offers off-the-shelf red-teaming evaluations. The following code can be used:
160
+
```python
161
+
from langfair.generator import AdversarialGenerator
162
+
ag = AdversarialGenerator(langchain_llm=llm)
163
+
164
+
# Generate responses to adversarial prompts (toxicity)
165
+
toxicity_generations =await ag.toxicity()
166
+
167
+
# Generate responses to adversarial prompts (counterfactual fairness)
Explore the following demo notebooks to see how to use LangFair for various bias and fairness evaluation metrics:
160
174
@@ -164,6 +178,8 @@ Explore the following demo notebooks to see how to use LangFair for various bias
164
178
-[AutoEval for Text Generation / Summarization (Toxicity, Stereotypes, Counterfactual)](https://github.com/cvs-health/langfair/blob/main/examples/evaluations/text_generation/auto_eval_demo.ipynb): A notebook illustrating how to use LangFair's `AutoEval` class for a comprehensive fairness assessment of text generation / summarization use cases. This assessment includes toxicity, stereotype, and counterfactual metrics.
165
179
-[Classification Fairness Evaluation](https://github.com/cvs-health/langfair/blob/main/examples/evaluations/classification/classification_metrics_demo.ipynb): A notebook demonstrating classification fairness metrics.
166
180
-[Recommendation Fairness Evaluation](https://github.com/cvs-health/langfair/blob/main/examples/evaluations/recommendation/recommendation_metrics_demo.ipynb): A notebook demonstrating recommendation fairness metrics.
181
+
-[Adversarial Toxicity Evaluation](https://github.com/cvs-health/langfair/blob/main/examples/adversarial/adversarial_toxicity.ipynb): A notebook demonstrating red-teaming using adversarial toxicity prompts.
182
+
-[Adversarial Counterfactual Fairness Evaluation](https://github.com/cvs-health/langfair/blob/main/examples/adversarial/adversarial_counterfactual.ipynb): A notebook demonstrating red-teaming using adversarial counterfactual fairness prompts.
167
183
168
184
169
185
## 🛠 Choosing Bias and Fairness Metrics for an LLM Use Case
0 commit comments