extracting-clinical-entities
하는 일
이 스킬은 임상 또는 생의학 텍스트에서 질환, 약물, 해부학 용어, 유전자 같은 의학 용어를 찾고, 각각이 어디에 나오는지 보고합니다. 구조화된 개체 결과가 필요한 임상 텍스트 파이프라인을 만드는 사람을 위한 스킬입니다.
사용하는 경우
- ✓노트에서 질환이나 약물 같은 의학 용어를 뽑아내야 할 때.
- ✓추출된 용어마다 정확한 문자 위치와 신뢰도가 필요할 때.
- ✓결과를 구조화된 데이터, 강조 표시된 화면, CSV로 얻고 싶을 때.
스킬 링크
https://github.com/maziyarpanahi/openmed/blob/master/skills/extracting-clinical-entities/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“이 임상 노트에서 질환과 약물을 뽑아 주세요. 각 항목의 위치와 신뢰도도 함께 보여 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 기기에서 임상 토큰 분류 모델을 실행하고, 각 개체를 라벨, 텍스트, 위치, 신뢰도와 함께 돌려주며, 요청한 형식으로 출력을 만듭니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Extracting Clinical Entities
openmed.analyze_text runs a token-classification model over medical text and
returns structured entities with character offsets and confidence scores. It runs
on-device after a one-time model download.
When to use
- Pull diseases, medications, anatomy, genes, proteins, etc. out of clinical text.
- You need exact character spans (start/end) plus confidence per entity.
- You want output as objects, JSON, an HTML highlight view, or CSV.
- You are building the "extract entities" stage of a clinical NLP pipeline.
To choose a model, see choosing-openmed-models. To load it once and reuse it,
see loading-openmed-models. In a PHI workflow, de-identify first (see
deidentifying-clinical-text), then run NER on the redacted text.
Install
pip install "openmed[hf]"
Quick start
import openmed
note = (
"Patient prescribed 500 mg metformin for type 2 diabetes mellitus. "
"Reports intermittent chest pain; ruled out myocardial infarction."
)
result = openmed.analyze_text(
note,
model_name="disease_detection_superclinical", # registry key, HF id, or local path
output_format="dict", # dict | json | html | csv
confidence_threshold=0.5,
)
for ent in result.entities:
print(f"{ent.label:12} {ent.text!r:40} {ent.confidence:.2f} [{ent.start}:{ent.end}]")
With output_format="dict" you get a PredictionResult. The fields you use most:
result.text # the original input text
result.entities # list of entity objects
result.model_name # which model produced these
ent.text # the surface string
ent.label # entity type, e.g. "DISEASE"
ent.confidence # model score in [0, 1] (NOTE: .confidence, not .score)
ent.start / ent.end # character offsets into result.text
Output formats
analyze_text(...) returns different types depending on output_format:
output_format |
Return type | Use for |
|---|---|---|
"dict" (default) |
PredictionResult object |
Programmatic access via .entities. |
"json" |
str (JSON) |
Logging, APIs, writing to disk. |
"html" |
str (HTML) |
A highlighted preview of the note. |
"csv" |
str (CSV) |
Spreadsheet / quick review. |
import openmed
note = "Started atorvastatin 40 mg; history of myocardial infarction."
json_str = openmed.analyze_text(note, output_format="json")
html_str = openmed.analyze_text(note, output_format="html") # render in a browser
csv_str = openmed.analyze_text(note, output_format="csv")
Key parameters
openmed.analyze_text(
text,
model_name="disease_detection_superclinical",
output_format="dict",
confidence_threshold=0.5, # drop entities below this score; None keeps all
aggregation_strategy="simple", # HF subword aggregation; None for raw tokens
group_entities=False, # merge adjacent same-label spans into one
include_confidence=True, # include scores in formatted output
sentence_detection=True, # pySBD sentence splitting (better long-doc spans)
sentence_language="en",
loader=None, # pass a reused ModelLoader (see loading skill)
)
confidence_threshold— the most useful knob. Use the model'srecommended_confidence(fromget_model_info) as a starting point.group_entities=True— merges"type","2","diabetes"fragments into a single"type 2 diabetes"span. Turn on for cleaner output.sentence_detection=True(default) — splits long notes into sentences before inference for more accurate offsets and to respect model max length. Requires pySBD; if unavailable it silently falls back to whole-text inference.
Save results to JSONL
One line per note keeps offsets and labels for downstream grounding or eval:
import json
import openmed
notes = [
"Type 2 diabetes managed with metformin.",
"Acute myocardial infarction; started aspirin and atorvastatin.",
]
with open("entities.jsonl", "w", encoding="utf-8") as fh:
for i, note in enumerate(notes):
result = openmed.analyze_text(note, output_format="dict")
fh.write(json.dumps({
"doc_id": i,
"text": result.text,
"model": result.model_name,
"entities": [
{"label": e.label, "text": e.text,
"start": e.start, "end": e.end,
"confidence"
자주 묻는 질문
노트가 제 컴퓨터 밖으로 나가나요?
아니요. 모델은 한 번 내려받은 후 기기에서 실행됩니다.
환자 이름을 먼저 지워야 하나요?
노트에 식별자가 있으면 그렇습니다. 개체 추출을 실행하기 전에 비식별화할 것을 권장합니다.
신뢰도로 걸러 낼 수 있나요?
네. 신뢰도 임계값을 설정한 다음 결과를 묶거나 저장할 수 있습니다.
상세 정보
작성자의 원본 설명
Run clinical and biomedical named-entity recognition on medical text with OpenMed's analyze_text. Use when the user wants to extract diseases, drugs, anatomy, genes, or other biomedical entities from notes; needs NER output as dict/json/html/csv; wants to filter by confidence, group entities, toggle sentence detection, or save spans to JSONL; or wants the openmed analyze CLI. Pairs with loading-openmed-models and choosing-openmed-models, and runs after deidentifying-clinical-text in a privacy-first pipeline.
repo: maziyarpanahi/openmed
인기도
- GitHub 스타
- 5.8k
- 순위
- #14699
- 라이선스
- 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, 카드 번호, 이메일, 날짜 같은 식별자를 검사하고, 남은 것이 있으면 공개를 막도록 돕습니다.
비슷한 스킬
gitcrawl
394k에이전트가 저장된 GitHub 이슈와 풀 리퀘스트 보관본을 검색하고, 중복 항목을 묶고, GitHub에서 현재 상태를 확인하도록 돕습니다.
slacrawl
394k에이전트가 로컬 Slack 보관본에서 메시지를 검색하고 개수를 세며, 보관본이 얼마나 최신인지 확인하고 필요할 때 새로 고치도록 돕습니다.
goplaces
394k에이전트가 Google Places로 장소를 검색하고, 세부 정보와 리뷰를 가져오고, 장소 이름을 확인하며, 스크립트용 JSON을 출력하도록 돕습니다.