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

benchmarking-clinical-ner

Skill này làm gì

Skill này chấm một mô hình nhận dạng thực thể có tên trong lâm sàng hoặc y sinh dựa trên một kho dữ liệu do con người chú thích bằng tay. Dành cho các nhóm cần con số thực thể trung thực và giải thích cho các lỗi.

Khi nào nên dùng

  • ✓Khi bạn muốn có bảng điểm cấp thực thể cho mô hình NER trên dữ liệu đã chú thích vàng của chính bạn.
  • ✓Khi bạn cần kết quả khớp nghiêm ngặt và khớp một phần đặt cạnh nhau.
  • ✓Khi bạn cần biết mô hình bỏ sót hoặc nhầm lẫn những nhãn nào nhiều nhất.

Liên kết skill

https://github.com/maziyarpanahi/openmed/blob/master/skills/benchmarking-clinical-ner/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/benchmarking-clinical-ner/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

“Hãy chấm mô hình NER lâm sàng của chúng tôi trên bộ kiểm thử đã chú thích và cho thấy precision, recall và F1 cho từng nhãn.”

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

Cách hoạt động

Agent khớp các đoạn được dự đoán với đoạn vàng theo quy tắc nghiêm ngặt và nới lỏng, tính các chỉ số cấp thực thể, rồi tạo bảng phân tích theo nhãn kèm ví dụ 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.

Benchmarking Clinical NER

This skill produces an honest entity-level scorecard for an OpenMed NER model: precision / recall / F1 plus a per-label error breakdown. It scores spans, not tokens, because clinical entities are multi-token ("type 2 diabetes mellitus") and token-level accuracy hides boundary errors. Reported numbers are entity-level in the seqeval tradition (CoNLL-2000 / SemEval-2013 families).

When to use this skill

  • You have a gold-annotated clinical corpus and an OpenMed NER model to score.
  • You want strict (exact-boundary) and partial (relaxed-overlap) span F1.
  • You need per-label numbers, not one aggregate — DRUG recall ≠ DISEASE recall.
  • You need to explain the errors: what was missed, what was spurious, what was mislabeled.

For PHI de-id specifically, gate on leakage with evaluating-with-leakage-gates instead of (or in addition to) F1.

Match modes

Mode Counts a hit when… Use for
Strict / exact predicted span boundaries and label match gold exactly release scoring, boundary-sensitive tasks
Partial / relaxed predicted span overlaps gold with the right label recall-oriented triage, tokenizer-mismatch tolerance

OpenMed exposes both: compute_exact_span_f1 (strict) and compute_relaxed_span_f1 (partial), with the full bundle in compute_metrics_bundle.

Quick start

Run a model over a user-supplied gold fixtures file and print a scorecard:

from openmed.eval import run_suite, error_report

# Fixtures: JSON list of {"id", "text", "gold_spans": [{start, end, label}, ...]}
report = run_suite(
    "eval/gold/clinical_ner.json",        # YOUR gold corpus, not bundled
    suite="golden",
    model_name="OpenMed/Disease-Detection",
    device="cpu",
)

m = report.metrics
print("exact F1 :", m["exact_span_f1"]["f1"])      # strict
print("relaxed F1:", m["relaxed_span_f1"]["f1"])    # partial
print("recall by label:", m["recall_slices"]["by_label"])

# Per-label confusion matrix + capped, no-PHI error examples.
errors = error_report(
    "OpenMed/Disease-Detection",
    "eval/gold/clinical_ner.json",
    suite_name="clinical_ner",
    example_cap=5,
)
print(errors.to_markdown())                 # confusion matrix + FN/FP tables
errors.write_json("eval/out/error_analysis.json")

Need just the metrics on spans you already have? Call the metric functions directly:

from openmed.eval import compute_exact_span_f1, compute_relaxed_span_f1

strict = compute_exact_span_f1(gold_spans, predicted_spans)
partial = compute_relaxed_span_f1(gold_spans, predicted_spans)

Workflow

  1. Align the corpus to OpenMed fixtures. Convert CoNLL/BIO or BRAT standoff into the fixture shape: text + gold_spans of {start, end, label} character offsets. (CoNLL → offsets; BRAT .ann is already character offsets.)
  2. Normalize labels to OpenMed's canonical set so DRUG/MEDICATION variants don't count as label confusion. Mislabeled-but-overlapping spans show up in the confusion matrix, not as misses.
  3. Run run_suite / run_benchmark to get a BenchmarkReport.
  4. Read both F1s. A large strict↓ / relaxed↑ gap means boundary errors, not detection failures — often tokenizer or whitespace issues.
  5. Run error_report for the per-label confusion matrix and capped examples. MISSED = false negatives (recall problem); SPURIOUS = false positives (precision problem); off-diagonal = label confusion.
  6. Triage per label. Fix the worst-recall label first; in clinical NER a few labels usually dominate the error budget.

Hand-off to / from OpenMed

  • From extracting-clinical-entities (openmed.analyze_text): the model and predictions you score here come from the NER pipeline.
  • To evaluating-with-leakage-gates: for de-id models, F1 is necessary but not sufficient — pass the same fixtures through the release gates.
  • To authoring-model-cards: drop error_report confusion matrices and per-label F1 straight into the model card's quantitative-analysis section.
  • Pairs with building-gold-corpus (supplies the fixtures) and auditing-subgroup-fairness (slices the same run by demographic group).

Edge cases & gotchas

  • Token F1 lies; report span F1. Always use the span metrics (compute_exact_span_f1 / compute_relaxed_span_f1), not token accuracy.
  • Overlapping/nested gold spans need a documented matching rule. OpenMed's m
Câu hỏi thường gặp

Nó có chấm điểm theo từ thay vì thực thể không?

Không. Nó chấm các đoạn thực thể trọn vẹn, vì các thuật ngữ lâm sàng nhiều từ có thể che giấu lỗi ranh giới ở cấp từ.

Tôi có cần kho vàng riêng không?

Có. Bạn cung cấp kho dữ liệu đã chú thích, skill không tự mang dữ liệu.

Khác nhau giữa nghiêm ngặt và một phần là gì?

Nghiêm ngặt đòi hỏi ranh giới chính xác và nhãn đúng, còn một phần tính khi có bất kỳ phần chồng lấn nào với nhãn đúng.

Chi tiết

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

Score an OpenMed clinical or biomedical NER model against a user-supplied gold corpus with entity-level precision, recall, and F1, then break errors down per label. Use when the user wants a seqeval-style scorecard, strict vs partial (relaxed) span matching, a per-label confusion matrix, false-negative / false-positive examples, or to debug why a model misses entities. Trigger on \"evaluate NER\", \"entity-level F1\", \"seqeval\", \"precision recall F1\", \"confusion matrix\", \"error analysis\", \"strict vs partial match\", or \"score against gold\" in an OpenMed context. The gold corpus is u

repo: maziyarpanahi/openmed

Độ phổ biến

Sao GitHub
5.8k
Vị trí xếp hạng
#14676
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ự