Loading Openmed Models logo

Loading Openmed Models

CommunityPopular
maziyarpanahi
loading-openmed-models

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

Overview

Publishermaziyarpanahi
Repositoryopenmed
Skill nameloading-openmed-models
Stars
5.3K
Forks
677
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by maziyarpanahi on GitHub. Read the source before you install it.

Installation

Install the Loading Openmed Models AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/maziyarpanahi/openmed.git /tmp/openmed
mkdir -p .claude/skills
cp -r /tmp/openmed/skills/loading-openmed-models .claude/skills/loading-openmed-models
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Loading Openmed Models in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Loading Openmed Models on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Loading Openmed Models is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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:

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.

python
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):

python
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:

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

python
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:

bash
export HF_HUB_OFFLINE=1
export TRANSFORMERS_OFFLINE=1

Or vendor the model and pass a local path — that path is loaded with local_files_only=True and never contacts the Hub:

python
result = openmed.analyze_text(note, model_name="/models/openmed-disease-ner")

To pre-warm a cache for offline use, run one inference (or load_model) once with network access, then disable it.

Check a model's maximum sequence length

Useful before chunking long documents:

python
from openmed import get_model_max_length, ModelLoader

loader = ModelLoader()
max_len = get_model_max_length("disease_detection_superclinical", loader=loader)
print(max_len)   # e.g. 512 — None if it can't be inferred

get_model_max_length(model_name, *, config=None, loader=None) delegates to loader.get_max_sequence_length(model_name). Pass the same loader you use for inference so the tokenizer is loaded only once.

Free memory when done

The loader holds models in RAM until released:

python
loader.unload_model("disease_detection_superclinical")  # drop one model
loader.unload_all_models()                               # drop everything
loader.loaded_models()                                   # inspect what's cached

Hand-off to / from OpenMed

  • From choosing-openmed-models: that skill yields a model key or HF id; feed it straight into ModelLoader.load_model(...) or as model_name=.
  • To extracting-clinical-entities: pass your reused loader= into openmed.analyze_text(...) so a long batch loads weights exactly once.
  • To de-identification: openmed.extract_pii(..., loader=loader) and openmed.deidentify(..., loader=loader) accept the same loader — share one loader across NER and PHI steps in a pipeline.
python
loader = ModelLoader(OpenMedConfig(cache_dir="/data/openmed-cache"))
phi   = openmed.deidentify(note, method="mask", loader=loader)
ner   = openmed.analyze_text(phi.deidentified_text, loader=loader)

Edge cases & gotchas

  • pip install openmed alone is not enough to download models — add the [hf] extra (or have transformers + huggingface_hub installed). ModelLoader raises ImportError with an install hint if transformers is missing.
  • Local path vs registry key collision: if a bare name happens to exist as a directory, the local path wins. Use an absolute path to be explicit.
  • force_reload=True is required after you overwrite files in a local model directory; otherwise the in-memory cache is served.
  • Private repos need hf_token (or HF_TOKEN) and HF_HUB_OFFLINE unset for the first download.
  • No PHI in the cache path or logs. Cache model weights, never patient text. cache_dir should not live inside a PHI data directory.
  • Permissive licensing only. OpenMed models are Apache-2.0. Do not stage UMLS/SNOMED/CPT/MIMIC/i2b2/n2c2 assets in the cache — those stay out-of-process under the user's own license.

Standards & references

Frequently asked questions

What does the Loading Openmed Models AI skill do?

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

Why use Loading Openmed Models on TypingMind?

Because you install it once and use it with any model. Loading Openmed Models is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Loading Openmed Models in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/maziyarpanahi/openmed/tree/master/skills/loading-openmed-models. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Loading Openmed Models?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Loading Openmed Models?

As many as you like. As long as a model supports skills, you can use Loading Openmed Models with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Loading Openmed Models AI skill free?

Yes. It is published on GitHub by maziyarpanahi under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇