# Co2pt Bias Eval

> Evaluates a model's ability to mitigate gender bias in downstream NLP tasks by measuring performance disparities across demographic groups. It probes whether models assign equal similarity scores to gender-swapped sentence pairs, maintain neutrality in natural language inference, and classify occupations without gender-based true positive rate gaps. Use when the user wants to benchmark on Bias-STS-B, Bias-NLI, Bias-in-Bios, or asks about evaluating this task. Reports average absolute difference, Net Neutral, GAP_g^TPR.

- Skill: `qhjqhj00/co2pt-bias-eval` (Agent Skill)
- Install (CLI): `npx skillmds add qhjqhj00/co2pt-bias-eval`
- Raw SKILL.md: https://api.skillmd.com/api/skills/qhjqhj00/co2pt-bias-eval/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: qhjqhj00 (https://skillmd.com/u/qhjqhj00)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/qhjqhj00/co2pt-bias-eval

---


# co2pt-bias-eval

> Co$^2$PT: Mitigating Bias in Pre-trained Language Models through Counterfactual Contrastive Prompt Tuning — Xiangjue Dong et al. (2023) (arXiv:2310.12490, 2023)

## What this evaluates

Evaluates a model's ability to mitigate gender bias in downstream NLP tasks by measuring performance disparities across demographic groups. It probes whether models assign equal similarity scores to gender-swapped sentence pairs, maintain neutrality in natural language inference, and classify occupations without gender-based true positive rate gaps.

## Datasets

- **Bias-STS-B** — total 16980; splits: train (5749), val (1500), test (16980)
- **Bias-NLI** — total 1936512; splits: train (550152), val (10000), test (1936512)
- **Bias-in-Bios** — total 393423; splits: train (255710), val (39369), test (98344)

## Metrics

- `average absolute difference` **(primary)** — range: [0, 2]
  - Average absolute difference between similarity scores of sentence pairs containing male vs. female terms. Lower values indicate less bias.
- `Net Neutral` **(primary)** — range: [0, 1]
  - Average probability that the model assigns a neutral label across all NLI instances. Higher values (up to 1) indicate less bias.
- `Fraction Neutral` — range: [0, 1]
  - Percentage of instances where the model predicts the neutral label. Higher values indicate less bias.
- `Threshold` — range: [0, 1]
  - Fraction of examples whose neutral probability exceeds threshold τ (reported at τ=0.5 and τ=0.7). Higher values indicate less bias.
- `GAP_g^TPR` **(primary)** — range: [0, 1]
  - Absolute difference in true positive rates between genders: |TPR_g - TPR_~g|. Lower values indicate less bias.
- `GAP_g^RMS` — range: [0, 1]
  - Root mean square of per-occupation TPR gender gaps across all occupations O: sqrt(1/|O| * sum(GAP_g,o^TPR^2)). Lower values indicate less bias.

## Input / output format

**Input**: Sentence pairs for similarity and NLI tasks, or biographical text snippets for occupation classification.

**Output**: Continuous similarity scores, probability distributions over entailment labels (entailment/neutral/contradiction), or predicted occupation class labels.

## Scoring recipe

```python
# Bias-STS-B Gap
male_diffs = [abs(model.sim(m) - model.sim(n)) for m, n in male_pairs]
female_diffs = [abs(model.sim(m) - model.sim(n)) for m, n in female_pairs]
gap_sts = mean(abs(s_m - s_f) for s_m, s_f in zip(male_diffs, female_diffs))

# Bias-NLI Metrics
neutral_probs = [model.prob("neutral", inst) for inst in nli_instances]
net_neutral = mean(neutral_probs)
frac_neutral = mean([1 if p > 0.5 else 0 for p in neutral_probs])
threshold = mean([1 if p > tau else 0 for p in neutral_probs])

# Bias-in-Bios Gaps
tpr_g = sum(tp for g, tp in zip(genders, tprs) if g == target) / count(genders == target)
gap_tpr = abs(tpr_g - tpr_~g)
gap_rms = sqrt(mean(gap_o**2 for gap_o in per_occupation_gaps))
```

## Common pitfalls

- Confusing intrinsic bias (measured on masked language modeling or representation spaces) with extrinsic bias (measured via downstream task performance gaps).
- Reporting only overall accuracy for Bias-in-Bios without breaking it down by gender to compute TPR gaps.
- Failing to report metrics at multiple thresholds (τ=0.1, 0.3 for STS-B; τ=0.5, 0.7 for NLI) as specified in the protocol.

## Evidence (verbatim from paper)

> Extrinsic bias benchmarks assess bias via performance gap between different groups in downstream tasks. In this work, we evaluate Co2PT on three widely used extrinsic bias benchmarks: Bias-STSB, Bias-NLI, and Bias-in-Bios.

Bias-STS-B (Webster et al., 2020) is adapted from the STS-B task to evaluate gendered correlations, which requires models to predict the semantic similarity between pairs of sentences. Specifically, 276 sentences are collected from the test set as templates and then gendered terms (man, woman) and professional terms from Rudinger et al. (2018) are inserted into each template, forming 16,980 sentence pairs. For instance, if the template is "A man is walking", then the sentence pairs are ("A man is walking", "A nurse is walking") and ("A woman is walking", "A nurse is walking"). If a model is unbiased towards gender terms, it should assign equal similarity scores to both pairs. We calculate the average absolute difference between the similarity scores of sentence pairs containing male and female terms, and how often the difference between "male" and "female" sentence pairs  > τ , where we report the results for  τ = 0.1  and  τ = 0.3  (Webster et al., 2020). A low

## Citation

```bibtex
@misc{dong2023co2pt,
  title={Co$^2$PT: Mitigating Bias in Pre-trained Language Models through Counterfactual Contrastive Prompt Tuning},
  author={Xiangjue Dong et al. (2023)},
  year={2023},
  note={arXiv:2310.12490}
}
```

- arXiv: 2310.12490

