auditing-subgroup-fairness
它能做什么
这项技能检查临床语言模型在某些人口群体上的表现是否比其他群体更差,例如在识别个人信息方面。适合在模型用于真实患者之前审查其公平性的团队。
适用场景
- ✓当你需要去标识化或 NER 模型按群体统计的召回率和泄露率的时候。
- ✓当你怀疑某个患者群体暴露的个人信息比另一个群体多的时候。
- ✓当临床 AI 治理审查需要有记录的差异数据的时候。
技能链接
https://github.com/maziyarpanahi/openmed/blob/master/skills/auditing-subgroup-fairness/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查我们的去标识化模型对某些年龄段漏掉的个人信息是否比其他年龄段多,并展示这种差距。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会按人口统计标签对金标准测试片段进行分组,计算每个群体的召回率和泄露率,并报告最大差异以及表现最差的群体。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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_disparity —
max - minleakage 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
- Tag the gold corpus by group. Add a synthetic
groupto each PHI span'smetadata(sex, age band, race/ethnicity surrogate). Use synthetic surrogates, not real protected attributes (seebuilding-gold-corpus). - Run
fairness_reporton the model + suite. - Read leakage first, recall second. For de-id, a group with higher leakage is under-protected — that is the headline finding.
- Compute the disparity (
leakage_disparity) and locateworst_group. Equalized-odds framing: equal true-positive (recall) and equal leakage across groups. - 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.
- 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 aggregateRELEASABLEdecision 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.
unspecifiedis not a real group. A pile of spans inunspecifiedmeans 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 — chec
常见问题
如果我的数据没有群体标签呢?
没有标签的片段会归入未指定群体,报告会显示这一数据缺口。
这里的泄露是什么意思?
指去标识化之后,某个群体仍然暴露的个人信息所占的比例。
它会修复模型吗?
不会。它只衡量差异,以便在部署前加以解决。
详情
作者的原始描述
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 \"STANDIN
repo: maziyarpanahi/openmed
热度
- GitHub 星标
- 5.8k
- 排名
- #14672
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
annotating-variants
5.8k帮你的智能体预测基因变异的作用,把 HGVS 名称转换为基因组位置,并使用免费的公共注释工具添加人群频率。
ask-openmed
5.8k帮你的智能体为临床文本请求选择合适的 OpenMed 工作流程,并在可能涉及患者数据时,先进行隐私检查。
assembling-fhir-bundles
5.8k把多份 FHIR 健康记录打包成一个事务 Bundle,可直接发送给 EHR 系统,并正确链接其中的内部引用。
auditing-deid-leakage
5.8k扫描已去标识化的临床文本,查找残留的标识符,例如社会安全号、银行卡号、电子邮件地址和日期,若仍有残留则阻止发布。