Running Openmed Ondevice logo

Running Openmed Ondevice

CommunityPopular
maziyarpanahi
running-openmed-ondevice

Run OpenMed models fully on-device with the MLX (Apple Silicon), CoreML (iOS/macOS), or ONNX/WebGPU (cross-platform/browser) backends, including convert-quantize-run workflows. Use when the user wants to deploy OpenMed at the edge, run NER/de-id on Apple Silicon, target iPhone/iPad/Mac, export to ONNX or WebGPU, quantize a clinical model to int8/4-bit, run with no network, or pick between MLX/CoreML/ONNX. Covers the mlx/coreml/onnx extras, the convert() functions and python -m convert CLIs, quantization, loading a local MLX artifact through analyze_text, OpenMedMLXLanguageModel/generate_text, and the on-device-only PHI guarantee (nothing leaves the host).

Overview

Publishermaziyarpanahi
Repositoryopenmed
Skill namerunning-openmed-ondevice
Stars
5.6K
Forks
708
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 Running Openmed Ondevice 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.
    https://github.com/maziyarpanahi/openmed/tree/master/skills/running-openmed-ondevice
  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/running-openmed-ondevice .claude/skills/running-openmed-ondevice
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Running Openmed Ondevice 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 Running Openmed Ondevice 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 Running Openmed Ondevice 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.

Running OpenMed on-device

OpenMed runs fully on-device by design. These three backends let you take it further at the edge: MLX (Apple Silicon acceleration), CoreML (iOS/macOS / Neural Engine), and ONNX / WebGPU (cross-platform and in-browser). The flow is the same: convert → (quantize) → run locally. Because inference is local, raw PHI never leaves the device — the strongest privacy posture OpenMed offers.

When to use this skill

When you need OpenMed where there is no server: an iOS/macOS app (CoreML), fast NER/de-id on an Apple Silicon Mac (MLX), or a portable/browser deployment (ONNX/WebGPU). For a hosted endpoint use serving-openmed-rest-api; for an agent tool use deploying-openmed-mcp; for corpora use batch-processing-clinical-text.

Pick a backend

BackendExtraBest forQuantization
MLXopenmed[mlx]Apple Silicon Macs; fastest local NER/de-id; on-device LLMs4-bit / 8-bit weights
CoreMLopenmed[coreml]iOS/iPadOS/macOS apps, Neural Engineint8 palettization
ONNX / WebGPUopenmed[onnx]cross-platform runtimes, browser (transformers.js)fp16 (WebGPU); int8 via ORT

Quick start — MLX (Apple Silicon)

bash
pip install "openmed[mlx]"

# Convert a HF token-classification model to an OpenMed MLX artifact, 8-bit:
python -m openmed.mlx.convert --model OpenMed/<some-ner-model> --output ./mlx_ner --quantize 8
python
import openmed

# Run NER/de-id through the normal API — pass the local artifact dir as model_name.
# The loader auto-detects the MLX backend from the artifact (or set backend explicitly).
result = openmed.analyze_text(
    "Patient received 75mg clopidogrel for NSTEMI.",
    model_name="./mlx_ner",          # local MLX artifact directory
    output_format="dict",
)

# Force MLX via config if you prefer to be explicit:
from openmed.core.config import OpenMedConfig
cfg = OpenMedConfig(backend="mlx")   # None=auto-detect, "mlx", or "hf"

convert() is also importable: openmed.mlx.convert.convert(model_id, output_dir, quantize_bits=8). The CLI accepts --quantize {4,8}, --quantize-group-size, --cache-dir, and an optional --eval-suite to certify quantized recall against the full-precision parent (recommended for clinical models — quantization can drop recall on rare entities).

On-device LLM generation (MLX)

python
from openmed.mlx.lm import generate_text, OpenMedMLXLanguageModel

text = generate_text(
    messages=[{"role": "user", "content": "Summarize: chest pain, troponin elevated."}],
    model_name="OpenMed/laneformer-2b-it-q4-mlx",   # resolves to a local MLX-LM artifact
    max_tokens=128,
)

llm = OpenMedMLXLanguageModel("OpenMed/laneformer-2b-it-q4-mlx")
out = llm.generate(prompt="...", max_tokens=64, temp=0.0)

Quick start — CoreML (iOS/macOS)

bash
pip install "openmed[coreml]"
python -m openmed.coreml.convert --model OpenMed/<some-ner-model> --output model.mlpackage --quantize int8
python
from openmed.coreml.convert import convert
convert(
    "OpenMed/<some-ner-model>",
    "model.mlpackage",
    compute_units="cpuAndNeuralEngine",   # "all" | "cpuAndNeuralEngine" | "cpuOnly"
    compute_precision="float16",          # float16 for Neural Engine, float32 for CPU
    quantize="int8",                      # emits an int8-palettized sibling .mlpackage
)

Bundle the .mlpackage in your Xcode app and run it with Core ML; the converter writes the id2label map so your app can decode token labels. Use float16 + cpuAndNeuralEngine for the Neural Engine; int8 shrinks the model for storage-constrained devices.

Quick start — ONNX / WebGPU

bash
pip install "openmed[onnx]"
python -m openmed.onnx.convert --model OpenMed/<some-ner-model> --output ./onnx_out
python
from openmed.onnx.convert import convert
res = convert("OpenMed/<some-ner-model>", "./onnx_out", include_webgpu=True, opset=18)
# Emits model.onnx (fp32) and model.webgpu.onnx (fp16) + an export manifest.

Run model.onnx with ONNX Runtime on any platform, or ship model.webgpu.onnx to the browser via transformers.js for in-page, zero-upload inference. Use --no-webgpu to skip the fp16 artifact.

Workflow

  1. Pick the backend for the target (table above).
  2. Convert the HF/OpenMed model with the matching convert() / python -m openmed.<backend>.convert.
  3. Quantize if size/latency demands it (MLX 4/8-bit, CoreML int8, WebGPU fp16). For clinical de-id/NER, certify recall — MLX's --eval-suite writes a recall-delta report so you don't silently lose rare entities.
  4. Run locally: MLX artifacts go straight through analyze_text / deidentify; CoreML/ONNX artifacts run in their native runtimes (Core ML, ONNX Runtime, transformers.js).
  5. Verify outputs against the full-precision model before shipping (evaluating-with-leakage-gates for de-id).

Hand-off to / from OpenMed

  • Same API surface: an MLX artifact path is a drop-in model_name for openmed.analyze_text / deidentify — downstream skills (building-patient-timelines, exporting-to-fhir) are unchanged.
  • From the catalog: start from a model chosen via choosing-openmed-models / loading-openmed-models, then convert it here.
  • Eval gate: pipe quantized de-id output into evaluating-with-leakage-gates before release.

Edge cases & gotchas

  • Quantization can hurt clinical recall. A dropped rare PHI entity is a breach. Always benchmark the quantized model vs. full precision (MLX --eval-suite/recall-delta; manual eval for CoreML/ONNX) and gate on leakage, not just F1.
  • MLX is Apple-Silicon only. On non-Apple hardware the MLX backend isn't available and OpenMed falls back to PyTorch; convert/quantize steps that need mlx will skip quantization with a warning.
  • CoreML compute units matter. float16 targets the Neural Engine but some ops fall back to CPU; validate latency on a real device, not just the simulator.
  • ONNX dynamic axes / opset. Keep opset>=18 and verify the model with onnx.checker (the converter does). token-classification only — these converters wrap AutoModelForTokenClassification.
  • On-device ≠ no responsibility. Local inference removes network exposure, but the model and any cached output still live on the device — encrypt at rest and keep raw PHI out of logs.
  • No license bundling. Convert your own permissively-licensed models; don't embed restricted terminologies in shipped artifacts.

Standards & references

Frequently asked questions

What does the Running Openmed Ondevice AI skill do?

Run OpenMed models fully on-device with the MLX (Apple Silicon), CoreML (iOS/macOS), or ONNX/WebGPU (cross-platform/browser) backends, including convert-quantize-run workflows. Use when the user wants to deploy OpenMed at the edge, run NER/de-id on Apple Silicon, target iPhone/iPad/Mac, export to ONNX or WebGPU, quantize a clinical model to int8/4-bit, run with no network, or pick between MLX/CoreML/ONNX. Covers the mlx/coreml/onnx extras, the convert() functions and python -m convert CLIs, quantization, loading a local MLX artifact through analyze_text, OpenMedMLXLanguageModel/generate_tex...

Why use Running Openmed Ondevice on TypingMind?

Because you install it once and use it with any model. Running Openmed Ondevice 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 Running Openmed Ondevice in TypingMind?

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

Which AI models can use Running Openmed Ondevice?

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 Running Openmed Ondevice?

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

Is the Running Openmed Ondevice 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 👇