OpenMed: Run Medical AI Locally – Your Data Never Leaves Your Device
Are you concerned about patient data leaking when processed through cloud APIs? Do you need a professional, free, and fully on‑premise clinical text analysis tool? If yes, OpenMed might be exactly what you’re looking for.
OpenMed is a local‑first medical AI framework. It extracts clinical entities (diseases, drugs, anatomy) from free text and detects / de‑identifies personal sensitive information (PII) – all on your own hardware, server, or mobile phone. Your data never leaves your network.

The logo combines Persian turquoise elements with a symbol of medical knowledge.
Why Do We Need Local Medical AI?
Traditional cloud APIs for analysing medical notes, extracting keywords, or anonymising records come with several hard‑to‑ignore problems:
-
Privacy risks – Patient names, IDs, diagnoses must be sent to third‑party servers. -
High compliance costs – Regulations like HIPAA and GDPR demand strict data localisation and auditing. -
Ongoing fees – Pay‑per‑call models become expensive over time. -
Vendor lock‑in – Migrating to another platform requires rewriting code. -
No offline use – Disconnected or air‑gapped networks cannot use cloud APIs.
OpenMed reverses all these pain points.
| Feature | OpenMed (local) | Cloud Medical APIs |
|---|---|---|
| Runs on your device / server | ✅ | ❌ |
| Patient data leaves your network | Never | Always |
| Cost | Free & open source | Pay per call |
| Specialised medical models | 1,000+ | Limited |
| Languages supported | 12+ | Varies |
| Offline / air‑gapped ready | ✅ | ❌ |
| Apple Silicon acceleration | ✅ (MLX) | N/A |
| Native iOS / macOS app | ✅ (OpenMedKit) | ❌ |
| Vendor lock‑in | None – Apache 2.0 | Yes |
In short: OpenMed gives you commercial‑grade medical NLP on your own hardware, with full data control.
What Can OpenMed Do?
1. Clinical Entity Recognition
From a piece of clinical text, OpenMed automatically identifies disease names, drug names, anatomical sites, genes, and more.
Example:
“Patient started on imatinib for chronic myeloid leukemia.”
Using the disease detection model, you get:
-
Disease: chronic myeloid leukemia (confidence 0.98) -
Drug: imatinib (confidence 0.95)
All inference happens on your computer – no internet required.
2. PII Detection and De‑identification
Medical notes are full of personal information: names, dates of birth, social security numbers, addresses, phone numbers, medical record numbers. OpenMed provides a complete PII pipeline:
-
Extract – Identify all PII entities and their types (NAME, DATE, SSN, etc.) -
De‑identify – Multiple methods: masking ( [NAME]), fake data replacement (format‑preserving), cryptographic hashing, date shifting.
Example:
from openmed import extract_pii, deidentify
text = "Patient: John Doe, DOB: 01/15/1970, SSN: 123-45-6789"
# Extract PII
result = extract_pii(text, model_name="pii_superclinical_large", use_smart_merging=True)
for e in result.entities:
print(e.label, e.text)
# Masking
print(deidentify(text, method="mask"))
# Output: Patient: [NAME], DOB: [DATE], SSN: [SSN]
The fake replacement method (Faker‑based) generates realistic, format‑preserving synthetic data – e.g., Brazilian CPF, Dutch BSN, French NIR, Italian Codice Fiscale, Spanish NIE, Indian Aadhaar, German Steuer‑ID, US NPI.
Below is a real‑time PII redaction demo on a synthetic discharge summary:

3. Multilingual Support
OpenMed’s PII models cover 12 languages: English, French, German, Italian, Spanish, Dutch, Portuguese, Hindi, Telugu, Arabic, Japanese, Turkish. That’s 247 PII checkpoints in total.
Call it like this:
from openmed import extract_pii
portuguese = extract_pii("Paciente: Pedro Almeida, CPF: 123.456.789-09, telefone: +351 912 345 678", lang="pt")
dutch = extract_pii("Patiënt: Eva de Vries, BSN: 123456782, telefoon: +31 6 12345678", lang="nl")
japanese = extract_pii("患者 佐藤 花子、電話 +81 90 1234 5678、マイナンバー 1234 5678 9012.", lang="ja")
No need to switch models – just set the lang parameter.
How Does It Work Under the Hood?
The diagram below shows the processing flow:
flowchart LR
A["Clinical text"] --> B["OpenMed<br/>(100% local)"]
B --> C["Medical entities"]
B --> D["Detected PII"]
B --> E["De‑identified text"]
style B fill:#0D6E6E,stroke:#0A5656,stroke-width:2px,color:#ffffff
style C fill:#D6EBEB,stroke:#0D6E6E,color:#0E1116
style D fill:#F7DCD8,stroke:#C5453A,color:#0E1116
style E fill:#F5E27A,stroke:#A9A088,color:#0E1116
You input raw clinical text, OpenMed loads pre‑trained models locally, and returns three things: medical entities, PII entities, and a de‑identified version.
All models come from a registry of 1,000+ curated biomedical and clinical Transformers – many outperform proprietary alternatives on specific tasks.
30‑Second Quick Start
Installation is straightforward. Choose the command that matches your hardware:
# Core + Hugging Face runtime (Linux, macOS, Windows; CPU or CUDA)
pip install "openmed[hf]"
# Add REST service
pip install "openmed[hf,service]"
# Apple Silicon acceleration (MLX)
pip install "openmed[mlx]"
Once installed, use it in Python:
from openmed import analyze_text
result = analyze_text(
"Patient presents with chronic myeloid leukemia and Type 2 diabetes.",
model_name="disease_detection_superclinical",
)
for entity in result.entities:
print(f"{entity.label:<12} {entity.text:<28} {entity.confidence:.2f}")
Output:
DISEASE chronic myeloid leukemia 0.98
DISEASE Type 2 diabetes 0.97
No API keys, no network calls – everything runs locally.
What Models Are Available?
OpenMed maintains a registry of specialised medical NER models. Here are a few representative ones:
| Model Name | Specialty | Entity Types | Size |
|---|---|---|---|
disease_detection_superclinical |
Diseases & conditions | DISEASE, CONDITION, DIAGNOSIS | 434M |
pharma_detection_superclinical |
Drugs & medications | DRUG, MEDICATION, TREATMENT | 434M |
pii_superclinical_large |
PII & de‑identification | NAME, DATE, SSN, PHONE, EMAIL, ADDRESS | 434M |
anatomy_detection_electramed |
Anatomy & body parts | ANATOMY, ORGAN, BODY_PART | 109M |
gene_detection_genecorpus |
Genes & proteins | GENE, PROTEIN | 109M |
Choose the model that fits your task. For zero‑shot extraction (open entity types), OpenMed experimentally supports GLiNER‑based models.
OpenMed also includes three “Privacy Filter” models based on the OpenAI Privacy Filter architecture:
-
OpenAI original: openai/privacy-filter -
Nemotron fine‑tune: OpenMed/privacy-filter-nemotron -
Multilingual: OpenMed/privacy-filter-multilingual
All share the same code (sparse MoE Transformer + local attention + RoPE + YaRN + tiktoken tokenizer), only training data differs. On Apple Silicon, you can use MLX 8‑bit quantised versions for faster inference.
Run on iPhone and Mac – Locally, Offline
Yes. OpenMed provides OpenMedKit – a Swift package that lets you call PII detection and clinical entity extraction directly from iOS, iPadOS, and macOS apps. Everything runs on the device, no network required.
Add this to your Xcode project dependencies:
dependencies: [
.package(url: "https://github.com/maziyarpanahi/openmed.git", from: "1.5.5"),
]
Then use the same model names as in Python. OpenMedKit automatically selects the best backend: MLX acceleration on Apple Silicon, CoreML fallback on older devices or simulators.
This means you can build an offline‑capable medical records analysis app – patient data never leaves the phone.
REST API and Batch Processing
Beyond Python function calls, OpenMed provides a FastAPI REST service, suitable for microservice deployment.
Start the service:
pip install "openmed[hf,service]"
uvicorn openmed.service.app:app --host 0.0.0.0 --port 8080
Or with Docker:
docker build -t openmed:1.5.5 .
docker run --rm -p 8080:8080 -e OPENMED_PROFILE=prod openmed:1.5.5
Endpoints:
-
GET /health -
POST /analyze– generic NER -
POST /pii/extract– PII only -
POST /pii/deidentify– de‑identification
Example call:
curl -X POST http://127.0.0.1:8080/pii/extract \
-H "Content-Type: application/json" \
-d '{"text":"Paciente: Maria Garcia, DNI: 12345678Z","lang":"es"}'
For large document batches, use BatchProcessor:
from openmed import BatchProcessor
processor = BatchProcessor(
model_name="disease_detection_superclinical",
group_entities=True,
)
results = processor.process_texts(["text1", "text2", ...])
How to Use OpenMed in Offline / Air‑Gapped Environments
OpenMed fully supports offline operation. Just download the model files to a local directory in advance, then point model_id to that directory.
Example:
from openmed import analyze_text, OpenMedConfig
result = analyze_text(
"Patient presents with chronic myeloid leukemia.",
model_id="./models/OpenMed-NER-DiseaseDetect-SuperClinical-434M",
config=OpenMedConfig(device="cpu"),
)
OpenMed will load from the local path and never attempt to connect to Hugging Face Hub. This is ideal for hospital intranets, secure labs, or any air‑gapped environment.
Frequently Asked Questions (FAQ)
Q: What are the hardware requirements?
A: Any computer with Python 3.10+ (Windows, macOS, Linux). CPU inference is slower but works. NVIDIA GPU (CUDA) or Apple Silicon (MLX) is recommended for speed. At least 8 GB RAM is advisable.
Q: Is it really free? Can I use it commercially?
A: Yes. OpenMed is licensed under Apache 2.0. You can use, modify, and distribute it freely, even in commercial products, without paying any fees.
Q: How accurate are the models?
A: According to the arXiv paper (2508.01630), several OpenMed models achieve state‑of‑the‑art or comparable results to commercial alternatives on biomedical NER benchmarks.
Q: Can I train my own models?
A: OpenMed currently provides pre‑trained models and inference. For fine‑tuning, you can use Hugging Face transformers to load the base models and train on your own data. Community tooling for fine‑tuning is planned.
Q: What regional ID formats are supported for fake replacement?
A: The Faker‑based replacement supports multiple localised identifiers: Brazilian CPF/CNPJ, Dutch BSN, French NIR, Italian Codice Fiscale, Spanish NIE, Indian Aadhaar, German Steuer‑ID, US NPI, and more. You can also add custom providers.
Q: How does “smart merging” work? Can it merge entities incorrectly?
A: Smart merging reassembles token‑level BIO labels that were fragmented by the tokeniser – for example, keeping “01/15/1970” as one date entity instead of splitting into “01”, “/”, “15”, etc. You can disable it with use_smart_merging=False.
Q: Can I run OpenMed in a Jupyter Notebook?
A: Absolutely. The Python API is fully compatible with Jupyter.
Q: Is there a graphical user interface?
A: The official distribution provides the Python library and REST API. GUIs can be built by developers using OpenMedKit (iOS/macOS) or tools like Streamlit for web demos.
A Real‑World Use Case
Imagine you work in a regional medical centre. Every day you process tens of thousands of discharge summaries from various departments. These texts contain diagnoses, medications, lab results, and also private patient information. You need to:
-
Extract diseases and drugs for epidemiological studies. -
Remove all PII and share anonymised data with partner institutions. -
Comply with HIPAA and never let data leave the hospital intranet.
With OpenMed, write a batch script on your hospital Linux server (with NVIDIA GPU):
from openmed import analyze_text, deidentify
for record in discharge_summaries:
# Extract disease entities
ner_result = analyze_text(record.text, model_name="disease_detection_superclinical")
diseases = [e.text for e in ner_result.entities]
# De‑identify
anonymized = deidentify(record.text, method="replace")
# Save results to local database
save_result(record.id, diseases, anonymized)
No internet connection required – all model files are already downloaded to your internal storage. You can safely export the anonymised texts for research partners.
Community and Contributions
OpenMed is an active open‑source project. You can find the complete code on GitHub, submit issues, or help with translations. The project already provides READMEs in many languages (Chinese, Spanish, French, German, Italian, Portuguese, Dutch, Arabic, Hindi, Telugu, Japanese, Turkish, Persian). Contributions are welcome.
If OpenMed helps your work or research, please cite the paper:
@misc{panahi2025openmedneropensourcedomainadapted,
title={OpenMed NER: Open-Source, Domain-Adapted State-of-the-Art Transformers for Biomedical NER Across 12 Public Datasets},
author={Maziyar Panahi},
year={2025},
eprint={2508.01630},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2508.01630},
}
Star History
OpenMed continues to gain popularity on GitHub. If you find the project useful, a star helps others discover it.
Summary
OpenMed provides a truly local‑first, privacy‑safe, free, and professional AI infrastructure for healthcare IT. Whether you are a hospital IT administrator, medical software developer, data scientist, or researcher in clinical NLP, you can get powerful text analysis capabilities with just a few lines of code.
-
Core advantages – Data never leaves your hardware, no vendor lock‑in, zero cost. -
Feature complete – Entity extraction + PII detection + multilingual support + anonymisation + REST API + mobile SDK. -
Ecosystem friendly – Runs on CPU, CUDA, Apple MLX, CoreML – from Python to Swift seamlessly.
Install from PyPI and run your first example in under five minutes. For detailed guides, visit openmed.life/docs.
The guardian of OpenMed – a fluffy Persian cat as Avicenna (Ibn Sina), protecting your medical data privacy.

