Skills

Loading Openmed Models

Load OpenMed clinical/biomedical NER models from the Hugging Face Hub or a local path...

Install

npx skills add maziyarpanahi/openmed --skill loading-openmed-models -g -a claude-code -y
Repository
maziyarpanahi/openmed5.8k
Category
Engineering
Updated
4d ago
License
Apache-2.0
Context cost
Mediumabout 1,924 tokens
Runs scripts
No, instructions only

What it does

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).

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:

FormExampleNotes
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()
Read the whole SKILL.md on GitHub

More in Engineering