मुख्य सामग्री पर जाएँ
Skillpedia
मशीन लर्निंग5.8k · #14710

loading-openmed-models

यह क्या करती है

यह स्किल दिखाती है कि OpenMed क्लिनिकल मॉडल कैसे लोड करें, एक बार डाउनलोड करें, कुशलता से दोबारा इस्तेमाल करें और ऑफ़लाइन चलाएँ। यह उन डेवलपर्स के लिए है जो कई विश्लेषण चलाते हैं और मॉडल बार-बार लोड करने से बचना चाहते हैं।

कब इस्तेमाल करें

  • ✓जब आप कई NER कॉल चलाएँगे और मॉडल केवल एक बार लोड करना चाहेंगे।
  • ✓जब आपको नियंत्रित करना हो कि मॉडल कहाँ कैश हों, या CPU या GPU पर चलें।
  • ✓जब बंद या ऑफ़लाइन वातावरण में एक बार डाउनलोड के बाद मॉडल चलाने हों।

Skill का लिंक

https://github.com/maziyarpanahi/openmed/blob/master/skills/loading-openmed-models/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/maziyarpanahi/openmed/blob/master/skills/loading-openmed-models/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“OpenMed क्लिनिकल मॉडल एक बार लोड कीजिए, उसे मेरे प्रोजेक्ट फ़ोल्डर में कैश कीजिए, और हमारे सुरक्षित सर्वर पर ऑफ़लाइन चलाइए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट मॉडल नाम का रूप चुनता है, जैसे रजिस्ट्री कुंजी या स्थानीय डायरेक्टरी, मॉडल को एक बार कैश में डाउनलोड करता है, और लोड किए गए मॉडल को कॉल के बीच दोबारा इस्तेमाल करता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Loading OpenMed Models

OpenMed models download once from the Hugging Face Hub into a local cache, then run fully on-device — no network, no telemetry. This skill covers how to load a model, reuse it across many calls without reloading weights, point at a local copy, and run offline.

When to use

  • You are about to run NER repeatedly and want to load the model once.
  • You need to control where weights are cached (cache_dir) or force CPU/GPU.
  • You must run offline in a locked-down or air-gapped environment.
  • You are choosing between a registry key, a full HF id, or a local directory.

For which model to load, see choosing-openmed-models. To actually run it, see extracting-clinical-entities.

Install

pip install "openmed[hf]"   # adds Hugging Face transformers + hub download

The three ways to name a model

analyze_text, extract_pii, load_model, and ModelLoader.load_model all accept the same model_name in three forms:

Form Example Notes
Registry key "disease_detection_superclinical" Short, resolved via the bundled registry.
Full HF id "OpenMed/OpenMed-NER-DiseaseDetect-BigMed-278M" Anything org/name; downloaded from the Hub.
Local path "/models/my-openmed-ner" An existing directory; loaded with local_files_only=True.

A bare name without / is prefixed with the default org (OpenMed). An existing local path is detected automatically and never hits the network.

Quick start: load and reuse a loader

The single most important pattern — build one ModelLoader, pass it everywhere. The loader caches models, tokenizers, and pipelines in memory, so the second call is instant.

import openmed
from openmed import ModelLoader, OpenMedConfig

# One loader, reused across calls. Weights load on the first call only.
loader = ModelLoader()

notes = [
    "Patient prescribed 500 mg metformin for type 2 diabetes.",
    "History of myocardial infarction; started on atorvastatin.",
]

for note in notes:
    result = openmed.analyze_text(
        note,
        model_name="disease_detection_superclinical",
        loader=loader,          # <-- reuse; no reload on subsequent calls
        output_format="dict",
    )
    print(result.entities)

Without loader=, each analyze_text call constructs a fresh ModelLoader. The underlying Hugging Face cache still prevents re-downloads, but you pay to re-instantiate the pipeline — avoid that in loops and services.

Load weights directly

When you want the raw model/tokenizer (e.g. to inspect config or build a custom pipeline):

from openmed import load_model

bundle = load_model("disease_detection_superclinical")
model     = bundle["model"]
tokenizer = bundle["tokenizer"]
config    = bundle["config"]

load_model(model_name, config=None, **kwargs) is a thin convenience wrapper that builds a ModelLoader and calls loader.load_model(...). For reuse, prefer constructing the loader yourself:

loader = ModelLoader()
bundle = loader.load_model("disease_detection_superclinical")
# Second call returns the cached bundle (no reload):
bundle2 = loader.load_model("disease_detection_superclinical")
# Force a fresh load if you replaced files on disk:
fresh = loader.load_model("disease_detection_superclinical", force_reload=True)

Configure the cache, device, and org

OpenMedConfig is a dataclass. Pass it to ModelLoader(config=...).

from openmed import ModelLoader, OpenMedConfig

config = OpenMedConfig(
    cache_dir="/data/openmed-cache",   # default: ~/.cache/openmed
    device="cpu",                       # None = auto-detect
    default_org="OpenMed",              # prepended to bare model names
    hf_token=None,                      # or set env HF_TOKEN for private repos
)
loader = ModelLoader(config)

Relevant OpenMedConfig fields: cache_dir, device, default_org, hf_token, timeout (default 300s), backend (None auto / "hf" / "mlx"), log_level. hf_token falls back to the HF_TOKEN environment variable.

First-run download, then fully offline

  1. First run (online): the model is fetched from the Hub into cache_dir.
  2. Every run after: transformers serves from cache with no network call.

To guarantee no network access (air-gapped, CI, PHI environments), set the standard Hugging Face offline switch before importing:

export HF_HUB_OFFLINE=1
export TRANSFORMERS_O
अक्सर पूछे जाने वाले सवाल

क्या रनटाइम पर मॉडल को इंटरनेट चाहिए?

नहीं। एक बार डाउनलोड के बाद मॉडल पूरी तरह डिवाइस पर चलते हैं।

कौन-से मॉडल नाम फ़ॉर्मैट स्वीकार होते हैं?

रजिस्ट्री कुंजी, पूरा Hugging Face ID, या स्थानीय डायरेक्टरी पाथ।

क्या अतिरिक्त इंस्टॉल चाहिए?

हाँ। Hugging Face एक्स्ट्रा मॉडल डाउनलोड सपोर्ट देता है।

जानकारी

लेखक का मूल विवरण

Load OpenMed clinical/biomedical NER models from the Hugging Face Hub or a local path and reuse them efficiently across calls. Use when the user wants to load an OpenMed model, control the model cache, run fully offline after a one-time download, reuse a ModelLoader to avoid reloading, set a cache_dir or device, or pick between a registry key, a full Hugging Face id, and a local directory. Pairs with choosing-openmed-models (pick the model) and extracting-clinical-entities (run it).

repo: maziyarpanahi/openmed

लोकप्रियता

GitHub स्टार
5.8k
रैंकिंग में स्थान
#14710
लाइसेंस
Apache-2.0
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस 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