# Loading Openmed Models

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

- Repository: https://github.com/maziyarpanahi/openmed (5755 stars)
- Category: Engineering
- License: Apache-2.0
- Last updated: 2026-10-31
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add maziyarpanahi/openmed --skill loading-openmed-models -g -a claude-code -y`
Codex: `npx skills add maziyarpanahi/openmed --skill loading-openmed-models -g -a codex -y`
Cursor: `npx skills add maziyarpanahi/openmed --skill loading-openmed-models -g -a cursor -y`
Gemini CLI: `npx skills add maziyarpanahi/openmed --skill loading-openmed-models -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add maziyarpanahi/openmed`

## Description

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

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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

```bash
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.

```python
import openmed
from openmed import ModelLoader, OpenMedConfig

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

The rest: https://github.com/maziyarpanahi/openmed/blob/HEAD/skills/loading-openmed-models/SKILL.md
