Agent Skillsmaziyarpanahi/openmed › auditing-subgroup-fairness

auditing-subgroup-fairness

GitHub

审计OpenMed NER或去标识化模型在人口统计学子群体(性别、年龄、种族)上的性能差异,检测特定群体的泄露风险与召回率不平等。

skills/auditing-subgroup-fairness/SKILL.md maziyarpanahi/openmed

Trigger Scenarios

fairness subgroup bias audit disparity equalized odds under-protected group per-group recall STANDING Together

Install

npx skills add maziyarpanahi/openmed --skill auditing-subgroup-fairness -g -y
More Options

Use without installing

npx skills use maziyarpanahi/openmed@auditing-subgroup-fairness

指定 Agent (Claude Code)

npx skills add maziyarpanahi/openmed --skill auditing-subgroup-fairness -a claude-code -g -y

安装 repo 全部 skill

npx skills add maziyarpanahi/openmed --all -g -y

预览 repo 内 skill

npx skills add maziyarpanahi/openmed --list

SKILL.md

Frontmatter
{
    "name": "auditing-subgroup-fairness",
    "license": "Apache-2.0",
    "metadata": {
        "pairs": "adjacent",
        "project": "OpenMed",
        "version": "1.0",
        "category": "evaluation-quality"
    },
    "description": "Audit an OpenMed NER or de-identification model for performance disparities across demographic subgroups (sex, age band, race\/ethnicity when available) using openmed.eval.fairness_report. Use when the user wants per-subgroup recall and leakage, wants to check whether de-identification under-protects a group, wants to surface a documentation gap where subgroup data is missing, or needs equalized-odds-style disparity numbers for a clinical model. Trigger on \"fairness\", \"subgroup\", \"bias audit\", \"disparity\", \"equalized odds\", \"under-protected group\", \"per-group recall\", or \"STANDING Together\" for an OpenMed model."
}

Auditing Subgroup Fairness

An aggregate pass can hide a group the model fails. For de-identification that failure has a name: under-protection — PHI that leaks more often for one demographic group than another. openmed.eval.fairness_report slices leakage and recall by gold-span group so disparities surface before deployment, not after a breach.

When to use this skill

  • You want per-subgroup recall and leakage for a de-id or NER model.
  • You suspect (or must rule out) that one group is under-protected.
  • You need disparity numbers for a clinical AI governance review.
  • You need to document which subgroups you couldn't evaluate (the data gap).

What it measures

For each surrogate group fairness_report returns:

  • leakage_rate — fraction of that group's gold PHI characters left exposed (the de-id harm metric).
  • recall — fraction of that group's gold spans detected.
  • leakage_disparitymax - min leakage across groups (the gap to close).
  • worst_group / worst_group_leakage — the most-failed group.

Group membership comes from a group tag in each gold span's metadata (keys group, demographic_group, or surrogate_group); ungrouped spans fall into unspecified.

Quick start

from openmed.eval import fairness_report

# Gold fixtures must tag spans with a surrogate group, e.g.
#   {"start": 4, "end": 12, "label": "PERSON", "metadata": {"group": "female"}}
fair = fairness_report(
    "OpenMed/Privacy-PII-Detection",
    "golden",                 # named suite, or pass a list of fixtures
    device="cpu",
)

print("leakage disparity:", fair.leakage_disparity)
print("worst group      :", fair.worst_group, fair.worst_group_leakage)
for group, m in sorted(fair.per_group.items()):
    print(f"  {group:14s} recall={m.recall:.3f}  leakage={m.leakage_rate:.4f}")

# Under-protection alarm: any group leaking more than the rest.
LEAKAGE_GAP_LIMIT = 0.0       # leakage-first: ideally zero leakage everywhere
assert fair.leakage_disparity <= LEAKAGE_GAP_LIMIT or fair.worst_group_leakage == 0

FairnessReport.to_dict() is JSON-ready and PHI-free — drop it straight into a model card.

Workflow

  1. Tag the gold corpus by group. Add a synthetic group to each PHI span's metadata (sex, age band, race/ethnicity surrogate). Use synthetic surrogates, not real protected attributes (see building-gold-corpus).
  2. Run fairness_report on the model + suite.
  3. Read leakage first, recall second. For de-id, a group with higher leakage is under-protected — that is the headline finding.
  4. Compute the disparity (leakage_disparity) and locate worst_group. Equalized-odds framing: equal true-positive (recall) and equal leakage across groups.
  5. Document the gap. If race/ethnicity surrogates are absent, report that the audit could not cover them — most clinical NLP studies omit race entirely, so silence is the default failure mode, not equity.
  6. Feed it forward. Put per-group numbers and the gap into the model card and the governance review.

Hand-off to / from OpenMed

  • From building-gold-corpus: supplies group-tagged synthetic fixtures.
  • From evaluating-with-leakage-gates: an aggregate RELEASABLE decision should be paired with this audit — overall pass, subgroup fail is exactly the trap this catches.
  • To authoring-model-cards: FairnessReport.to_dict() fills the quantitative-analysis / subgroup section.
  • Pairs with benchmarking-clinical-ner: same run, different slice (label vs group).

Edge cases & gotchas

  • Under-protection is the de-id harm; lead with leakage. A group with equal recall but higher leakage is still failed.
  • The race documentation gap is the norm. Most clinical NLP corpora don't record race/ethnicity, so most fairness audits silently can't measure it. Report the absence explicitly — don't let missing data read as parity.
  • unspecified is not a real group. A pile of spans in unspecified means your gold isn't tagged; fix the corpus before trusting the disparity.
  • Small groups give noisy rates. Report span counts (span_count, total_chars) alongside rates; a 1-of-2 leak isn't a 50% population rate.
  • Synthetic surrogates only. Never store real protected attributes in eval fixtures; use fabricated group labels for slicing.
  • Disparity ≈ 0 with high leakage everywhere is not "fair". Equal failure is still failure — check absolute leakage, not just the gap.

Standards & references

Version History

  • f213557 Current 2026-07-23 00:43

Same Skill Collection

skills/building-with-openmed/SKILL.md
skills/loading-openmed-models/SKILL.md
skills/annotating-variants/SKILL.md
skills/assembling-fhir-bundles/SKILL.md
skills/auditing-deid-leakage/SKILL.md
skills/auditing-deidentification-runs/SKILL.md
skills/auditing-part11-trails/SKILL.md
skills/auditing-safe-harbor-checklist/SKILL.md
skills/authoring-model-cards/SKILL.md
skills/batch-processing-clinical-text/SKILL.md
skills/benchmarking-clinical-ner/SKILL.md
skills/bridging-presidio-and-spacy/SKILL.md
skills/building-gold-corpus/SKILL.md
skills/building-patient-timelines/SKILL.md
skills/checking-hipaa-compliance/SKILL.md
skills/choosing-openmed-models/SKILL.md
skills/coding-hcc-risk-adjustment/SKILL.md
skills/coding-icd10/SKILL.md
skills/computing-ecqms/SKILL.md
skills/configuring-privacy-policies/SKILL.md
skills/defining-cohort-phenotypes/SKILL.md
skills/deidentifying-clinical-text/SKILL.md
skills/deidentifying-multilingual-text/SKILL.md
skills/deploying-openmed-mcp/SKILL.md
skills/detecting-pv-signals/SKILL.md
skills/enforcing-nophi-logging/SKILL.md
skills/etl-to-omop-cdm/SKILL.md
skills/evaluating-with-leakage-gates/SKILL.md
skills/exporting-bulk-fhir/SKILL.md
skills/exporting-to-fhir/SKILL.md
skills/extracting-clinical-entities/SKILL.md
skills/extracting-dicom-metadata/SKILL.md
skills/extracting-lab-tables/SKILL.md
skills/extracting-pii-entities/SKILL.md
skills/extracting-sdoh/SKILL.md
skills/fetching-fhir-resources/SKILL.md
skills/gating-deid-leakage/SKILL.md
skills/generating-synthea-data/SKILL.md
skills/generating-synthetic-surrogates/SKILL.md
skills/ingesting-clinical-documents/SKILL.md
skills/linking-umls-concepts/SKILL.md
skills/mapping-loinc/SKILL.md
skills/mapping-to-snomed/SKILL.md
skills/mining-pubmed-literature/SKILL.md
skills/normalizing-rxnorm/SKILL.md
skills/parsing-ccda-documents/SKILL.md
skills/parsing-hl7v2-messages/SKILL.md
skills/parsing-lab-values/SKILL.md
skills/parsing-trial-eligibility/SKILL.md

Metadata

Files
0
Version
f213557
Hash
07f38d82
Indexed
2026-07-23 00:43

ホーム - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-29 13:11
浙ICP备14020137号-1 $お客様$