Skip to content

Commit fc7afa7

Browse files
Merge pull request #231 from cvs-health/release-branch/v0.8.0
Minor release: `v0.8.0`
2 parents 6da82e9 + 4602dc3 commit fc7afa7

34 files changed

+4674
-2473
lines changed

.github/workflows/ci.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,20 @@ jobs:
4040
with:
4141
persist-credentials: false
4242

43+
- name: Free Disk Space (Ubuntu)
44+
if: matrix.os == 'ubuntu-latest'
45+
uses: jlumbroso/free-disk-space@main
46+
with:
47+
tool-cache: false
48+
android: true
49+
dotnet: true
50+
haskell: true
51+
large-packages: true
52+
docker-images: true
53+
swap-storage: true
54+
4355
- name: Set up Python
44-
uses: actions/setup-python@v5.6.0
56+
uses: actions/setup-python@v6.0.0
4557
with:
4658
python-version: ${{matrix.python-version}}
4759

@@ -65,7 +77,7 @@ jobs:
6577
persist-credentials: false
6678

6779
- name: Set up Python
68-
uses: actions/setup-python@v5.6.0
80+
uses: actions/setup-python@v6.0.0
6981
with:
7082
python-version: "3.12"
7183

@@ -117,4 +129,4 @@ jobs:
117129
uses: github/codeql-action/upload-sarif@v3
118130
with:
119131
sarif_file: semgrep.sarif
120-
if: always()
132+
if: always()

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,20 @@ results['metrics']
155155
# 'Sentiment Bias': 0.0009947145187601957}}}
156156
```
157157

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)
168+
counterfactual_generations = await ag.counterfactual(group_categories=["Gender", "Race/ethnicity"],)
169+
```
170+
171+
158172
## 📚 Example Notebooks
159173
Explore the following demo notebooks to see how to use LangFair for various bias and fairness evaluation metrics:
160174

@@ -164,6 +178,8 @@ Explore the following demo notebooks to see how to use LangFair for various bias
164178
- [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.
165179
- [Classification Fairness Evaluation](https://github.com/cvs-health/langfair/blob/main/examples/evaluations/classification/classification_metrics_demo.ipynb): A notebook demonstrating classification fairness metrics.
166180
- [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.
167183

168184

169185
## 🛠 Choosing Bias and Fairness Metrics for an LLM Use Case

data/counterfactual_templates.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)