benchmarking-clinical-ner
하는 일
이 스킬은 사람이 직접 주석을 단 코퍼스를 기준으로 임상 또는 생의학 개체명 인식 모델을 채점합니다. 정직한 개체 단위 수치와 오류 설명이 필요한 팀을 위한 스킬입니다.
사용하는 경우
- ✓직접 주석을 단 자체 데이터로 NER 모델의 개체 단위 성적표를 얻고 싶을 때.
- ✓엄격한 일치와 부분 일치 결과를 나란히 보고 싶을 때.
- ✓모델이 어떤 라벨을 가장 많이 놓치거나 혼동하는지 알아야 할 때.
스킬 링크
https://github.com/maziyarpanahi/openmed/blob/master/skills/benchmarking-clinical-ner/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“임상 NER 모델을 우리가 주석을 단 테스트 세트로 채점하고, 라벨별 정밀도, 재현율, F1을 보여 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 예측된 구간을 엄격하거나 느슨한 규칙으로 정답 구간과 맞춰 보고, 개체 단위 지표를 계산한 뒤, 오류 예시와 함께 라벨별 분석을 만듭니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
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
- Align the corpus to OpenMed fixtures. Convert CoNLL/BIO or BRAT
standoff into the fixture shape:
text+gold_spansof{start, end, label}character offsets. (CoNLL → offsets; BRAT.annis already character offsets.) - 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.
- Run
run_suite/run_benchmarkto get aBenchmarkReport. - Read both F1s. A large strict↓ / relaxed↑ gap means boundary errors, not detection failures — often tokenizer or whitespace issues.
- Run
error_reportfor the per-label confusion matrix and capped examples.MISSED= false negatives (recall problem);SPURIOUS= false positives (precision problem); off-diagonal = label confusion. - 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: droperror_reportconfusion matrices and per-label F1 straight into the model card's quantitative-analysis section. - Pairs with
building-gold-corpus(supplies the fixtures) andauditing-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
자주 묻는 질문
단어 단위로 채점하나요?
아니요. 전체 개체 구간을 채점합니다. 여러 단어로 된 임상 용어는 단어 수준에서 경계 오류를 가릴 수 있기 때문입니다.
자체 정답 코퍼스가 필요한가요?
네. 주석이 달린 코퍼스는 사용자가 제공해야 하며, 스킬이 데이터를 따로 가져오지는 않습니다.
엄격한 기준과 부분 기준의 차이는 무엇인가요?
엄격한 기준은 정확한 경계와 올바른 라벨을 요구하고, 부분 기준은 올바른 라벨과 겹치기만 하면 인정합니다.
상세 정보
작성자의 원본 설명
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
인기도
- GitHub 스타
- 5.8k
- 순위
- #14676
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
annotating-variants
5.8k에이전트가 유전 변이의 효과를 예측하고, HGVS 이름을 게놈 위치로 바꾸고, 무료 공개 주석 도구를 사용해 인구 빈도를 붙이도록 돕습니다.
ask-openmed
5.8k에이전트가 임상 텍스트 요청에 맞는 OpenMed 워크플로를 고르도록 돕되, 환자 데이터가 있을 수 있으면 먼저 개인 정보 확인을 거치게 합니다.
assembling-fhir-bundles
5.8k여러 FHIR 건강 기록을 EHR로 보낼 수 있도록 하나의 트랜잭션 Bundle로 묶고, 내부 참조를 올바르게 연결하도록 에이전트를 돕습니다.
auditing-deid-leakage
5.8k비식별화된 임상 텍스트에 남은 SSN, 카드 번호, 이메일, 날짜 같은 식별자를 검사하고, 남은 것이 있으면 공개를 막도록 돕습니다.