auditing-subgroup-fairness
Skill này làm gì
Skill này kiểm tra xem một mô hình ngôn ngữ lâm sàng có hoạt động kém hơn ở một số nhóm nhân khẩu học so với nhóm khác hay không, như khi tìm thông tin cá nhân. Dành cho các nhóm rà soát tính công bằng của mô hình trước khi dùng trên bệnh nhân thật.
Khi nào nên dùng
- ✓Khi bạn muốn có các số liệu recall và rò rỉ theo nhóm cho một mô hình khử nhận dạng hoặc NER.
- ✓Khi bạn nghi ngờ một nhóm bệnh nhân có nhiều thông tin cá nhân bị lộ hơn nhóm khác.
- ✓Khi một đợt rà soát quản trị AI lâm sàng cần các con số chênh lệch có tài liệu.
Liên kết skill
https://github.com/maziyarpanahi/openmed/blob/master/skills/auditing-subgroup-fairness/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy kiểm tra xem mô hình khử nhận dạng của chúng tôi có bỏ sót nhiều thông tin cá nhân hơn ở một số nhóm tuổi không, và cho tôi thấy khoảng cách đó.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent nhóm các đoạn kiểm thử chuẩn theo thẻ nhân khẩu học, đo recall và rò rỉ cho từng nhóm, rồi báo cáo chênh lệch lớn nhất và nhóm có kết quả kém nhất.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Nếu dữ liệu của tôi không có nhãn nhóm thì sao?
Các đoạn không có nhãn sẽ rơi vào một nhóm không xác định, và báo cáo cho thấy khoảng trống dữ liệu đó.
Rò rỉ ở đây nghĩa là gì?
Đó là tỷ lệ thông tin cá nhân của một nhóm vẫn bị lộ sau khi khử nhận dạng.
Nó có sửa mô hình không?
Không. Nó đo các chênh lệch để có thể xử lý trước khi triển khai.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 5.8k
- Vị trí xếp hạng
- #14672
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
annotating-variants
5.8kGiúp agent dự đoán tác động của biến thể di truyền, đổi tên HGVS sang vị trí bộ gen và gắn tần suất quần thể bằng công cụ chú giải miễn phí.
ask-openmed
5.8kGiúp agent chọn đúng quy trình OpenMed cho yêu cầu về văn bản lâm sàng, luôn kiểm tra quyền riêng tư trước khi có thể có dữ liệu bệnh nhân.
assembling-fhir-bundles
5.8kGói nhiều bản ghi y tế FHIR thành một Bundle giao dịch để gửi tới EHR, với các tham chiếu nội bộ được liên kết đúng.
auditing-deid-leakage
5.8kQuét văn bản lâm sàng đã khử nhận dạng để tìm định danh còn sót như SSN, số thẻ, email và ngày tháng, và chặn phát hành nếu còn sót.
Skill tương tự
pytorch-patterns
280kGiúp agent của bạn dùng PyTorch cho các mô hình học máy. Áp dụng thực hành tốt nhất để huấn luyện mô hình hiệu quả và đảm bảo kết quả có thể lặp lại.
evm-token-decimals
280kGiúp agent tránh lỗi về số thập phân khi làm việc với các mạng blockchain khác nhau. Đảm bảo giá trị token chính xác trong giao dịch và phép tính.
ito-inference
280kGiúp agent kiểm tra xem các mô hình AI đã sẵn sàng để dùng chưa. Kết nối yêu cầu tài nguyên tính toán với dịch vụ mô hình đã sẵn sàng.