loading-openmed-models
Skill5.4k starsChanged 4 months agoApache-2.0View on GitHub
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).
- Installs packages
Trending
Quiet since September.about the whole repository
Who's talking about maziyarpanahi/openmed
- @yug1224.com“医療テキストの解析や個人情報の匿名化を端末内で完結できるヘルスケアAIツールっぽい 機密データを扱う医療関連の開発現場でかなり使えそう yug1224 starred maziyarpanahi/openmed…”Bluesky · Jun 11, 2026 · 3 likes
- @qdrddr.bsky.social“Local #PII #HIPAA data #anonymizer based on #OpenMed and runs on #Nvidia and Apple #MLX - entirely …”Bluesky · Jul 10, 2026 · 2 likes
- @technews4869.bsky.social“github.com/maziyarpanahi/o... GitHub - maziyarpanahi/openmed: Local-first healthcare AI: clinical NER & …”Bluesky · Jun 22, 2026 · 1 likes
- @dailygithubtrends.bsky.social“今日のGitHubトレンド maziyarpanahi/openmed デバイス上で完結して動作するヘルスケアAIの提供を目的としています。 …”Bluesky · Jun 11, 2026 · 1 likes
- sudosubin/agents.nix“agent-skills.github.maziyarpanahi.openmed: init at 2.5.0”GitHub · Sep 29, 2026
The biggest 5 of 33 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 33
Talked about on GitHub and Bluesky (33 times).
On GitHub · 28
- Sep 29, 2026agent-skills.github.maziyarpanahi.openmed: init at 2.5.0 — sudosubin/agents.nix0 reactions
- Sep 22, 2026build(deps): update openmed requirement from >=1.5.2 to >=2.5.0 in /healthadvocate — simongonzalezdc/healthadvocate0 reactions · 1 comment
- Sep 8, 2026build(deps): update openmed requirement from >=1.5.2 to >=2.3.0 in /healthadvocate — simongonzalezdc/healthadvocate0 reactions · 1 comment
- Sep 1, 2026chore(deps): update openmed requirement from <2,>=1.9.1 to >=1.9.1,<3 — seiba-ai/seiba-risk-scanner0 reactions
- Aug 29, 2026[Argus] CVE-2026-47117: OpenMed 1.5.2 미만 버전의 PII 모델 로딩을 통한 원격 코드 실행 — LEEKIYOON-SEC/Argus-DEV0 reactions
23 more on GitHub
- Aug 25, 2026build(deps): update openmed requirement from >=1.5.2 to >=2.2.0 in /healthadvocate — simongonzalezdc/healthadvocate0 reactions · 1 comment
- Aug 18, 2026build(deps): update openmed requirement from >=1.5.2 to >=2.1.0 in /healthadvocate — simongonzalezdc/healthadvocate0 reactions · 1 comment
- Aug 4, 2026build(deps): update openmed requirement from >=1.5.2 to >=2.0.0 in /healthadvocate — simongonzalezdc/healthadvocate0 reactions · 1 comment
- Jul 30, 2026Bump openmed from 0.6.4 to 1.5.2 — Liberate-Labs/openmed_modal_hosting0 reactions
- Jul 21, 2026build(deps): update openmed requirement from >=1.5.2 to >=1.9.1 in /healthadvocate — simongonzalezdc/healthadvocate0 reactions · 1 comment
- Jul 14, 2026build(deps): update openmed requirement from >=1.5.2 to >=1.9.0 in /healthadvocate — simongonzalezdc/healthadvocate0 reactions · 1 comment
- Jul 14, 2026build(deps): update openmed requirement from >=1.5.2 to >=1.8.1 in /healthadvocate — simongonzalezdc/healthadvocate0 reactions · 1 comment
- Jul 11, 2026cron: curadoria 11/07/2026 - DynamiCare, PhysAssistBench, OpenMed, MedAgentGym, AIME 2026 — fabianofilho/awesome-medical-ai0 reactions
- Jul 7, 2026build(deps): update openmed requirement from >=1.5.2 to >=1.7.0 in /healthadvocate — simongonzalezdc/healthadvocate0 reactions · 1 comment
- Jun 23, 2026build(deps): update openmed requirement from >=1.5.2 to >=1.6.0 in /healthadvocate — simongonzalezdc/healthadvocate0 reactions · 1 comment
- Jun 19, 2026Add affected range to GHSA-m3v4-v5gx-7wf5 (openmed) — github/advisory-database0 reactions · 1 comment
- Jun 13, 2026feat: add openmed template — Phala-Network/phala-cloud0 reactions · 1 comment
- Jun 12, 2026Add OpenMed to healthcare AI section — alvinreal/awesome-opensource-ai0 reactions
- Jun 9, 2026build(deps): update openmed requirement from >=1.5.2 to >=1.5.5 in /healthadvocate — simongonzalezdc/healthadvocate0 reactions · 1 comment
- Jun 9, 2026Healthcare Vitals Toolkit — OpenMed Integration Proposal — nvdigitalsolutions/mcp-ai-wpoos0 reactions
- Jun 9, 2026[jules] Port OpenMed quality gates: quality_gates.dart (threshold config) — iberi22/OrionHealth0 reactions · 3 comments
- Jun 9, 2026[jules] Port OpenMed locale validators: i18n_validators.dart (CPF, DNI, CURP) — iberi22/OrionHealth0 reactions · 3 comments
- Jun 8, 2026[jules] Expand PromptScrubber with PiiDetector integration — iberi22/OrionHealth0 reactions · 3 comments
- Jun 8, 2026[jules] Port OpenMed text processor to Dart: text_processor.dart — iberi22/OrionHealth0 reactions · 3 comments
- Jun 8, 2026[jules] Port OpenMed PII detector to Dart: pii_detector.dart (30+ patterns) — iberi22/OrionHealth0 reactions · 2 comments
- Jun 8, 2026[jules] Port OpenMed EntitySpan to Dart: pii_entity.dart — iberi22/OrionHealth0 reactions · 2 comments
- Jun 8, 2026[jules] Port OpenMed labels.py to Dart: pii_labels.dart — iberi22/OrionHealth0 reactions · 2 comments
- May 29, 2026build(deps): update openmed requirement from >=1.4.0 to >=1.5.2 in /healthadvocate — simongonzalezdc/healthadvocate0 reactions · 1 comment
On Bluesky · 5
- Jun 11, 2026医療テキストの解析や個人情報の匿名化を端末内で完結できるヘルスケアAIツールっぽい 機密データを扱う医療関連の開発現場でかなり使えそう yug1224 starred maziyarpanahi/openmed… — @yug1224.com3 likes and reposts
- Jul 10, 2026Local #PII #HIPAA data #anonymizer based on #OpenMed and runs on #Nvidia and Apple #MLX - entirely #offline. #OpenSource Apache 2.0… — @qdrddr.bsky.social2 likes and reposts
- Jun 22, 2026github.com/maziyarpanahi/o... GitHub - maziyarpanahi/openmed: Local-first healthcare AI: clinical NER & HIPAA PII de-identific... — @technews4869.bsky.social1 likes and repost
- Jun 11, 2026今日のGitHubトレンド maziyarpanahi/openmed デバイス上で完結して動作するヘルスケアAIの提供を目的としています。 クラウドにデータを送らずに、臨床テキストからのエンティティ抽出や個人情報の匿名化をローカル環境で実現します。… — @dailygithubtrends.bsky.social1 likes and repost
- Jul 16, 2026Did you have a look to OpenMed ? It gives a similar toolkit unified in a python / Swift API specialised in health use cases.… — @aminesaboni.bsky.social0 likes and reposts · 2 replies
In this repository74 other files it gives its agents.
- AGENTS.mdAGENTS.md
- annotating-variantsSkill
- ask-openmedSkill
- assembling-fhir-bundlesSkill
- auditing-deidentification-runsSkill
- auditing-deid-leakageSkill
- auditing-part11-trailsSkill
- auditing-safe-harbor-checklistSkill
- auditing-subgroup-fairnessSkill
- authoring-model-cardsSkill
- batch-processing-clinical-textSkill
- benchmarking-clinical-nerSkill
- benchmark-pii-recallSkill
- bridging-presidio-and-spacySkill
- building-gold-corpusSkill
- building-patient-timelinesSkill
- building-with-openmedSkill
- checking-hipaa-complianceSkill
- choosing-openmed-modelsSkill
- coding-hcc-risk-adjustmentSkill
- coding-icd10Skill
- computing-ecqmsSkill
- configuring-privacy-policiesSkill
- defining-cohort-phenotypesSkill
- deidentify-a-datasetSkill
- deidentifying-clinical-textSkill
- deidentifying-multilingual-textSkill
- deploying-openmed-mcpSkill
- detecting-pv-signalsSkill
- enforcing-nophi-loggingSkill
- etl-to-omop-cdmSkill
- evaluating-with-leakage-gatesSkill
- exporting-bulk-fhirSkill
- exporting-to-fhirSkill
- extract-clinical-entities-to-fhirSkill
- extracting-clinical-entitiesSkill
- extracting-dicom-metadataSkill
- extracting-lab-tablesSkill
- extracting-pii-entitiesSkill
- extracting-sdohSkill
- fetching-fhir-resourcesSkill
- gating-deid-leakageSkill
- generating-synthea-dataSkill
- generating-synthetic-surrogatesSkill
- ingesting-clinical-documentsSkill
- linking-umls-conceptsSkill
- mapping-loincSkill
- mapping-to-snomedSkill
- mining-pubmed-literatureSkill
- normalizing-rxnormSkill
- parsing-ccda-documentsSkill
- parsing-hl7v2-messagesSkill
- parsing-lab-valuesSkill
- parsing-trial-eligibilitySkill
- pick-a-pii-modelSkill
- pseudonymizing-for-gdprSkill
- querying-openfda-labelsSkill
- querying-terminology-serviceSkill
- reconciling-problem-listsSkill
- reidentifying-textSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 83
When you want the raw model/tokenizer (e.g.
- Distinctive: line 198
Local path vs registry key collision: if a bare name happens to exist as a directory, the local path wins.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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 downloadThe 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
- First run (online): the model is fetched from the Hub into
cache_dir. - 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_OFFLINE=1Or vendor the model and pass a local path — that path is loaded with
local_files_only=True and never contacts the Hub:
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:
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 inferredget_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:
loader.unload_model("disease_detection_superclinical") # drop one model
loader.unload_all_models() # drop everything
loader.loaded_models() # inspect what's cachedHand-off to / from OpenMed
- From
choosing-openmed-models: that skill yields a model key or HF id; feed it straight intoModelLoader.load_model(...)or asmodel_name=. - To
extracting-clinical-entities: pass your reusedloader=intoopenmed.analyze_text(...)so a long batch loads weights exactly once. - To de-identification:
openmed.extract_pii(..., loader=loader)andopenmed.deidentify(..., loader=loader)accept the same loader — share one loader across NER and PHI steps in a pipeline.
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 openmedalone is not enough to download models — add the[hf]extra (or havetransformers+huggingface_hubinstalled).ModelLoaderraisesImportErrorwith 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=Trueis required after you overwrite files in a local model directory; otherwise the in-memory cache is served.- Private repos need
hf_token(orHF_TOKEN) andHF_HUB_OFFLINEunset for the first download. - No PHI in the cache path or logs. Cache model weights, never patient text.
cache_dirshould 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
- Hugging Face Hub caching & offline mode: https://huggingface.co/docs/huggingface_hub/guides/manage-cache and https://huggingface.co/docs/transformers/installation#offline-mode
- OpenMed model org on the Hub: https://huggingface.co/OpenMed
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

