extracting-clinical-entities
यह क्या करती है
यह स्किल क्लिनिकल या बायोमेडिकल टेक्स्ट में बीमारियाँ, दवाएँ, शरीर रचना और जीन जैसे चिकित्सा शब्द ढूँढती है, और बताती है कि हर एक कहाँ आता है। यह उन सभी के लिए है जो क्लिनिकल टेक्स्ट पाइपलाइन बना रहे हैं और संरचित एंटिटी नतीजे चाहते हैं।
कब इस्तेमाल करें
- ✓जब आपको नोट्स से बीमारियाँ या दवाओं जैसे दूसरे चिकित्सा शब्द निकालने हों।
- ✓जब आपको हर निकाले गए शब्द की सटीक अक्षर-स्थिति और विश्वास चाहिए।
- ✓जब आप नतीजे संरचित डेटा, हाइलाइट किए गए दृश्य या CSV में चाहते हैं।
Skill का लिंक
https://github.com/maziyarpanahi/openmed/blob/master/skills/extracting-clinical-entities/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“इस क्लिनिकल नोट से बीमारियाँ और दवाएँ निकालिए, और हर एक की स्थिति और विश्वास भी बताइए।”
हर हफ़्ते 5 नई skills, 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
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
annotating-variants
5.8kआपके एजेंट को मुफ़्त सार्वजनिक एनोटेटर से जेनेटिक वेरिएंट का असर बताने, HGVS नामों को जीनोम पोज़िशन में बदलने और जनसंख्या आवृत्ति जोड़ने में मदद करती है।
ask-openmed
5.8kआपके एजेंट को क्लिनिकल टेक्स्ट अनुरोध के लिए सही OpenMed वर्कफ़्लो चुनने में मदद करती है, जहाँ मरीज़ का डेटा हो सकता है वहाँ पहले गोपनीयता जाँच से शुरू करके।
assembling-fhir-bundles
5.8kकई FHIR स्वास्थ्य रिकॉर्ड को एक ट्रांज़ैक्शन Bundle में पैक करती है, जो EHR को भेजने के लिए तैयार हो और आंतरिक संदर्भ सही जुड़े हों।
auditing-deid-leakage
5.8kडी-आइडेंटिफ़ाइड क्लिनिकल टेक्स्ट में बचे पहचानकर्ता जैसे SSN, कार्ड नंबर, ईमेल और तारीखें खोजती है, और कुछ बचा हो तो रिलीज़ रोक देती है।
मिलती-जुलती skills
gitcrawl
394kयह आपके एजेंट को GitHub issues और pull requests के सेव आर्काइव में खोजने, मिलते-जुलते मामलों को समूह में रखने और लाइव स्थिति जांचने देती है।
slacrawl
394kयह आपके एजेंट को स्थानीय Slack आर्काइव में संदेश खोजने और गिनने, उसकी ताज़गी जांचने और ज़रूरत पड़ने पर उसे ताज़ा करने देती है।
goplaces
394kयह आपके एजेंट को Google Places से जगहें खोजने, उनका विवरण और समीक्षाएं पाने, और जगह के नाम हल करने में मदद करती है, स्क्रिप्ट के लिए JSON आउटपुट के साथ।