evaluating-with-leakage-gates
Skill này làm gì
Skill này kiểm thử mô hình khử nhận dạng hoặc NER lâm sàng theo các cổng phát hành tập trung vào việc lộ thông tin bệnh nhân, thay vì độ chính xác tổng thể. Dành cho các nhóm quyết định mô hình có an toàn để đưa ra sử dụng hay không.
Khi nào nên dùng
- ✓Khi bạn cần quyết định đưa ra hay không đưa ra cho một mô hình khử nhận dạng.
- ✓Khi bạn muốn chạy bộ đánh giá trên bộ kiểm thử tổng hợp trước khi phát hành.
- ✓Khi bạn cần ngưỡng recall cho định danh trực tiếp và quy tắc không có rò rỉ nghiêm trọng.
Liên kết skill
https://github.com/maziyarpanahi/openmed/blob/master/skills/evaluating-with-leakage-gates/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 chạy đánh giá rò rỉ trên mô hình khử nhận dạng mới của chúng tôi và cho tôi biết nó có đủ điều kiện phát hành không.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent chạy bộ đánh giá trên bộ kiểm thử tổng hợp, kiểm tra từng cổng phát hành, và báo cáo mô hình có thể phát hành hay nên giữ lại.
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.
Evaluating with Leakage Gates
OpenMed's release gates answer one question: did any PHI leak? A de-id model
with a beautiful F1 can still leak a single SSN — and that one leak is a HIPAA
breach. So openmed.eval gates on residual leakage and per-label recall
floors, not on aggregate F1. The candidate is either RELEASABLE or
QUARANTINED; there is no partial credit.
When to use this skill
- You have a candidate de-id or PII model and need a ship / no-ship decision.
- You want to run the benchmark harness over a synthetic golden suite.
- You need to enforce direct-identifier recall floors and
critical_leakage == 0. - You need calibration thresholds (
thresholds.json) before the gate will pass. - You want a signed, reproducible gate report for governance.
This is the flagship eval skill. For a pure NER scorecard see
benchmarking-clinical-ner; for CI wiring see gating-deid-leakage.
The gates (G1a–G8)
| Gate | Checks | Floor / rule |
|---|---|---|
| G1a | Direct & quasi identifiers (PERSON, EMAIL, PHONE, SSN, ID_NUM, DATE_OF_BIRTH, ...) | recall ≥ 0.990 (v1.6) / 0.995 (v2.0); strict-no-leak policies raise the floor |
| G1b | Structured secrets (API_KEY, ACCOUNT_NUMBER, CREDIT_CARD, IBAN) | recall ≥ 0.995 |
| G2 | Free-text names/locations/dates | recall ≥ 0.980 (v1.6) / 0.990 (v2.0) |
| G3 | Critical leakage (SSN, CREDIT_CARD, CVV, API_KEY, PIN, IBAN, ...) | count must be exactly 0 |
| G4 | Quantized recall delta vs fp parent | within INT8 / INT4 limits |
| G5 | Latency & RAM vs device tier budget | p50/p95/RAM under tier budget |
| G6 | p50/p95 latency documented | must be present and finite |
| G7 | Baseline regression | recall drop ≤ 0.002/label; leakage ≤ soft ceiling 0.005 and ≤ steward target; no leakage regression vs last-green |
| G8 | Span integrity | predicted spans validate (no overlaps/out-of-range) |
Constants live in openmed.eval.release_gates (G1A_V16_RECALL_FLOOR,
G1B_RECALL_FLOOR, G7_RECALL_DROP_LIMIT, RESIDUAL_LEAKAGE_SOFT_CEILING, ...).
Confirm them there rather than hardcoding — they move per milestone.
Quick start
Run a candidate benchmark over a synthetic golden suite, then gate it:
from openmed.eval import run_suite, ReleaseGate, RELEASABLE
# 1) Produce a candidate BenchmarkReport from a SYNTHETIC fixtures file.
# Each fixture carries gold PHI spans; no real patient text is committed.
report = run_suite(
"eval/golden/phi_synthetic.json", # user-supplied synthetic fixtures
suite="golden",
model_name="OpenMed/Privacy-PII-Detection",
device="cpu",
metadata={
"family": "PII",
"tier": "base",
"policy": "hipaa_safe_harbor",
# calibration artifacts are required for mask/replace policies (see below)
"thresholds_path": "eval/artifacts/thresholds.json",
"calibration_report_path": "eval/artifacts/calibration_report.json",
},
)
# 2) Gate it. The gate reads the last-green baseline store read-only and
# returns a signed GateReport.
gate = ReleaseGate(milestone="v1.6", policy="hipaa_safe_harbor")
decision = gate.evaluate(report)
print(decision.decision) # "RELEASABLE" or "QUARANTINED"
for check in decision.gate_results:
if not check.passed:
print(check.gate, "->", check.reason, check.details)
assert decision.decision == RELEASABLE, "do not ship a quarantined model"
CLI equivalent (fails closed, exit code 1 on quarantine):
python -m openmed.eval.release_gates \
--candidate eval/out/candidate_report.json \
--milestone v1.6 --policy hipaa_safe_harbor \
--output release-gate-report.json
Workflow
Build a synthetic golden suite. Fixtures are JSON with
textandgold_spans(offsets + labels). Usebuilding-gold-corpusto scaffold one. Committed gold must be synthetic; DUA corpora (i2b2/n2c2) are eval-only and never committed.Fit calibration thresholds for any policy that masks or replaces:
from openmed.eval import write_calibration_artifacts paths = write_calibration_artifacts( calibration_samples, # held-out score/target samples artifact_dir="eval/artifacts", model_id="OpenMed/Privacy-PII-Detection", suite="golden", target_leakage=0.0, # leakage-first: drive leakage to 0 ) # writes thresholds.json + calibration_report.json the gate looks for
Câu hỏi thường gặp
F1 tổng thể có phải là thước đo chính không?
Không. Các cổng tập trung vào rò rỉ còn lại và recall theo từng nhãn, vì một định danh bị lộ có thể là vi phạm nghiêm trọng.
Một mô hình có thể đạt nếu còn vài rò rỉ nghiêm trọng không?
Không. Rò rỉ nghiêm trọng phải bằng không, và kết quả là đạt hoặc giữ lại rõ ràng, không có điểm bán phần.
Nó có cần dữ liệu bệnh nhân thật không?
Không. Đánh giá chạy trên các bộ dữ liệu mẫu tổng hợp.
Chi tiết
Mô tả gốc của tác giả
Evaluate an OpenMed de-identification or clinical NER model against the leakage-first release gates G1a through G8, which gate releases on residual PHI leakage rather than on F1. Use when the user wants to run the OpenMed eval harness on a synthetic golden set, decide whether a de-id model is RELEASABLE or QUARANTINED, enforce direct-identifier recall floors, require zero critical leakage, fit calibration thresholds, or produce a signed gate report. Trigger on \"release gate\", \"leakage\", \"is this model safe to ship\", \"G1a\", \"G3\", \"quarantine\", \"recall floor\", or \"calibration thre
repo: maziyarpanahi/openmed
Độ phổ biến
- Sao GitHub
- 5.8k
- Vị trí xếp hạng
- #14695
- 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.