Chuyển đến nội dung
Skillpedia
Học máy5.8k · #14675

benchmark-pii-recall

Skill này làm gì

Skill này đo mức độ một mô hình phát hiện PII tìm được định danh cá nhân trong văn bản kiểm thử tổng hợp, tập trung vào recall, tức là bỏ sót càng ít định danh càng tốt. Dành cho các nhóm so sánh mô hình hoặc cấu hình trước khi phát hành.

Khi nào nên dùng

  • ✓Khi bạn so sánh các mô hình PII, ngưỡng hoặc phiên bản lượng tử hóa trước khi chọn một cái.
  • ✓Khi một bản phát hành cần quy tắc recall tối thiểu cho các định danh trực tiếp.
  • ✓Khi bạn muốn một kiểm tra lặp lại được mà không lưu lại định danh thô nào.

Liên kết skill

https://github.com/maziyarpanahi/openmed/blob/master/skills/benchmark-pii-recall/SKILL.md

Sao 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

Hãy dùng skill này để giúp tôi: https://github.com/maziyarpanahi/openmed/blob/master/skills/benchmark-pii-recall/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“So sánh hai mô hình PII này trên văn bản kiểm thử tổng hợp và cho tôi biết mô hình nào đạt ngưỡng recall 99 phần trăm.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent tạo tài liệu kiểm thử tổng hợp với vị trí định danh chính xác, chạy mô hình, chấm các đoạn được phát hiện so với chúng, và báo cáo số lượng mà không lưu văn bản định danh.

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.

Benchmark PII recall

Measure PII recall before optimizing F1, size, or latency. A missed direct identifier is a privacy failure even when aggregate F1 improves.

Procedure

  1. Build synthetic fixtures with exact offsets and canonical PII labels.
  2. Include direct identifiers, boundary cases, languages/scripts, and the target device or quantization.
  3. Run extract_pii at the candidate threshold.
  4. Normalize prediction labels and score each document separately.
  5. Aggregate counts only; do not persist raw text or identifier surfaces.
  6. Fail the release when the recall floor or zero-critical-leak requirement is not met.

Runnable synthetic benchmark

Install the model runtime first with python -m pip install "openmed[hf]".

from openmed import extract_pii
from openmed.core.labels import normalize_label
from openmed.eval import compute_character_recall, compute_exact_span_f1

MODEL = "OpenMed/OpenMed-PII-SuperClinical-Small-44M-v1"
RECALL_FLOOR = 0.99
FIXTURES = [
    {
        "text": (
            "Call the synthetic clinic at 212-555-0198 or email "
            "demo.patient@example.test."
        ),
        "spans": [
            ("PHONE", "212-555-0198"),
            ("EMAIL", "demo.patient@example.test"),
        ],
    },
    {
        "text": (
            "The synthetic callback number is 415-555-0136 and the contact "
            "address is sample.user@example.test."
        ),
        "spans": [
            ("PHONE", "415-555-0136"),
            ("EMAIL", "sample.user@example.test"),
        ],
    },
]

true_positives = false_positives = false_negatives = 0
covered_graphemes = total_graphemes = 0

for fixture in FIXTURES:
    text = fixture["text"]
    gold = []
    for label, surface in fixture["spans"]:
        start = text.index(surface)
        gold.append(
            {"start": start, "end": start + len(surface), "label": label}
        )

    result = extract_pii(
        text,
        model_name=MODEL,
        confidence_threshold=0.5,
        lang="en",
    )
    predicted = [
        {
            "start": entity.start,
            "end": entity.end,
            "label": normalize_label(entity.label),
        }
        for entity in result.entities
        if entity.start is not None and entity.end is not None
    ]

    exact = compute_exact_span_f1(gold, predicted, source_text=text)
    recall = compute_character_recall(gold, predicted, source_text=text)
    true_positives += exact.true_positives
    false_positives += exact.false_positives
    false_negatives += exact.false_negatives
    covered_graphemes += int(recall.numerator)
    total_graphemes += int(recall.denominator)

exact_recall = true_positives / max(true_positives + false_negatives, 1)
grapheme_recall = covered_graphemes / max(total_graphemes, 1)
print(
    {
        "documents": len(FIXTURES),
        "exact_span_recall": exact_recall,
        "grapheme_recall": grapheme_recall,
        "false_positives": false_positives,
        "false_negatives": false_negatives,
    }
)
assert grapheme_recall >= RECALL_FLOOR, "PII recall floor not met"

Release gates

  • Require zero misses for critical direct identifiers even if aggregate recall passes.
  • Report per-label, language, script, section, and device slices.
  • Compare quantized and full-precision outputs; reject recall regressions.
  • Add hard negatives so over-redaction does not hide behind high recall.
  • Store fixture hashes, model identity, threshold, and aggregate counts only.
  • Keep DUA-gated corpora outside the repository and load them only from the user's approved location.

Repository example

Read the policy and release-evidence walkthrough for PHI-free leakage metrics and audit evidence.

Câu hỏi thường gặp

Vì sao tập trung vào recall?

Vì một định danh trực tiếp bị bỏ sót là lỗi về quyền riêng tư, ngay cả khi độ chính xác tổng thể trông ổn.

Nó có dùng dữ liệu bệnh nhân thật không?

Không. Bộ kiểm thử dùng dữ liệu tổng hợp với vị trí nhãn chính xác.

Nó có thể làm thất bại một bản phát hành không?

Có. Nó có thể làm thất bại bản phát hành nếu không đạt ngưỡng recall hoặc quy tắc không có rò rỉ nghiêm trọng.

Chi tiết

Mô tả gốc của tác giả

Benchmark an OpenMed PII model with synthetic gold spans and report label-aware exact-span and grapheme recall without emitting identifier surfaces. Use when an agent must compare a model, threshold, backend, or quantized artifact and enforce a recall floor before release.

repo: maziyarpanahi/openmed

Độ phổ biến

Sao GitHub
5.8k
Vị trí xếp hạng
#14675
Giấy phép
Apache-2.0
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự