Refresh README for current MLX and OpenMedKit instructions
Browse files
README.md
CHANGED
|
@@ -16,90 +16,90 @@ tags:
|
|
| 16 |
|
| 17 |
# OpenMed-PII-SuperClinical-Base-184M-v1 for OpenMed MLX
|
| 18 |
|
| 19 |
-
This repository contains
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
-
-
|
| 24 |
-
-
|
| 25 |
-
-
|
| 26 |
-
-
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
| 31 |
-
- OpenMed website: [https://openmed.life](https://openmed.life)
|
| 32 |
-
- Source checkpoint: [`OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1)
|
| 33 |
-
|
| 34 |
-
## Quick Start
|
| 35 |
-
|
| 36 |
-
### Python
|
| 37 |
|
| 38 |
```bash
|
| 39 |
-
pip install openmed
|
| 40 |
pip install "openmed[mlx]"
|
| 41 |
```
|
| 42 |
|
| 43 |
```python
|
| 44 |
-
from openmed import
|
| 45 |
-
from openmed.core.config import OpenMedConfig
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
|
|
|
| 49 |
model_name="OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1",
|
| 50 |
-
|
| 51 |
)
|
| 52 |
|
| 53 |
for entity in result.entities:
|
| 54 |
print(entity.label, entity.text, round(entity.confidence, 4))
|
| 55 |
```
|
| 56 |
|
| 57 |
-
|
| 58 |
|
| 59 |
-
##
|
| 60 |
|
| 61 |
-
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
4. Add a compatible CoreML model bundle plus `id2label.json` to your app target.
|
| 68 |
|
| 69 |
-
|
| 70 |
|
| 71 |
-
```
|
| 72 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
```
|
| 74 |
|
| 75 |
-
|
| 76 |
|
| 77 |
-
```
|
| 78 |
-
import Foundation
|
| 79 |
-
import OpenMedKit
|
| 80 |
|
| 81 |
-
|
| 82 |
-
let modelURL = modelFolder.appendingPathComponent("OpenMedPII.mlmodelc")
|
| 83 |
-
let labelsURL = modelFolder.appendingPathComponent("id2label.json")
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
)
|
| 89 |
-
```
|
| 90 |
|
| 91 |
-
|
| 92 |
|
| 93 |
-
|
| 94 |
-
- local MLX inference on macOS
|
| 95 |
-
- private preconverted packaging on the Hub
|
| 96 |
|
| 97 |
-
|
|
|
|
|
|
|
| 98 |
|
| 99 |
-
|
| 100 |
|
| 101 |
-
|
|
|
|
|
|
|
| 102 |
- OpenMed GitHub: [https://github.com/maziyarpanahi/openmed](https://github.com/maziyarpanahi/openmed)
|
| 103 |
-
-
|
| 104 |
-
-
|
| 105 |
-
- Swift runtime for Apple apps: **OpenMedKit** from the OpenMed repository
|
|
|
|
| 16 |
|
| 17 |
# OpenMed-PII-SuperClinical-Base-184M-v1 for OpenMed MLX
|
| 18 |
|
| 19 |
+
This repository contains an MLX packaging of [`OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1) for Apple Silicon inference with [OpenMed](https://github.com/maziyarpanahi/openmed).
|
| 20 |
|
| 21 |
+
## At a Glance
|
| 22 |
|
| 23 |
+
- **Source checkpoint:** [`OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1)
|
| 24 |
+
- **Model family:** `deberta-v2` (`DebertaV2ForTokenClassification`)
|
| 25 |
+
- **Primary language hint:** English (`en`)
|
| 26 |
+
- **Artifact layout:** legacy-compatible MLX (`config.json`, `id2label.json`, MLX weight files)
|
| 27 |
+
- **Python MLX:** supported through `openmed[mlx]` on Apple Silicon Macs
|
| 28 |
+
- **Swift MLX:** not yet in the current OpenMedKit Swift MLX v1 rollout for `deberta-v2` models
|
| 29 |
|
| 30 |
+
## Python Quick Start
|
| 31 |
|
| 32 |
+
Use the standard OpenMed API if you want OpenMed to choose the right runtime automatically:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
```bash
|
|
|
|
| 35 |
pip install "openmed[mlx]"
|
| 36 |
```
|
| 37 |
|
| 38 |
```python
|
| 39 |
+
from openmed import extract_pii
|
|
|
|
| 40 |
|
| 41 |
+
text = "<your clinical note here>"
|
| 42 |
+
result = extract_pii(
|
| 43 |
+
text,
|
| 44 |
model_name="OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1",
|
| 45 |
+
use_smart_merging=True,
|
| 46 |
)
|
| 47 |
|
| 48 |
for entity in result.entities:
|
| 49 |
print(entity.label, entity.text, round(entity.confidence, 4))
|
| 50 |
```
|
| 51 |
|
| 52 |
+
On Apple Silicon, OpenMed auto-selects MLX when `openmed[mlx]` is installed. On other systems it falls back to the Hugging Face / PyTorch backend.
|
| 53 |
|
| 54 |
+
## Use This Preconverted MLX Repo Directly
|
| 55 |
|
| 56 |
+
If you want to use this MLX snapshot explicitly, download it locally and point OpenMed at the directory:
|
| 57 |
|
| 58 |
+
```bash
|
| 59 |
+
pip install "openmed[mlx]"
|
| 60 |
+
hf download OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1-mlx --local-dir ./OpenMed-PII-SuperClinical-Base-184M-v1-mlx
|
| 61 |
+
```
|
|
|
|
| 62 |
|
| 63 |
+
If this repo is still private in your environment, authenticate first with `hf auth login` or set `HF_TOKEN`.
|
| 64 |
|
| 65 |
+
```python
|
| 66 |
+
from openmed import extract_pii
|
| 67 |
+
from openmed.core import OpenMedConfig
|
| 68 |
+
|
| 69 |
+
text = "<your clinical note here>"
|
| 70 |
+
result = extract_pii(
|
| 71 |
+
text,
|
| 72 |
+
model_name="./OpenMed-PII-SuperClinical-Base-184M-v1-mlx",
|
| 73 |
+
config=OpenMedConfig(backend="mlx"),
|
| 74 |
+
use_smart_merging=True,
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
print(result.entities)
|
| 78 |
```
|
| 79 |
|
| 80 |
+
## Swift Status
|
| 81 |
|
| 82 |
+
This repo is based on `deberta-v2`. Python MLX supports this family today, but the current public Swift MLX rollout in OpenMedKit is intentionally limited to `bert`, `distilbert`, `roberta`, `xlm-roberta`, and `electra`.
|
|
|
|
|
|
|
| 83 |
|
| 84 |
+
If you are building an Apple app today, the recommended paths for this model are:
|
|
|
|
|
|
|
| 85 |
|
| 86 |
+
- **Python MLX** for evaluation or local workflows on Apple Silicon
|
| 87 |
+
- **CoreML in OpenMedKit** if you already have a compatible bundled Apple export
|
| 88 |
+
- Track the current Swift support matrix in the [OpenMedKit docs](https://openmed.life/docs/swift-openmedkit/)
|
|
|
|
|
|
|
| 89 |
|
| 90 |
+
## Artifact Notes
|
| 91 |
|
| 92 |
+
This repo uses the current legacy-compatible MLX layout:
|
|
|
|
|
|
|
| 93 |
|
| 94 |
+
- `config.json`
|
| 95 |
+
- `id2label.json`
|
| 96 |
+
- MLX weight files (`weights.safetensors` and/or `weights.npz`)
|
| 97 |
|
| 98 |
+
Tokenizer assets are not bundled in this repo layout. OpenMed and OpenMedKit keep backward compatibility by falling back to the source tokenizer reference in `config.json` when needed.
|
| 99 |
|
| 100 |
+
## Links
|
| 101 |
+
|
| 102 |
+
- Source checkpoint: [`OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1)
|
| 103 |
- OpenMed GitHub: [https://github.com/maziyarpanahi/openmed](https://github.com/maziyarpanahi/openmed)
|
| 104 |
+
- MLX backend docs: [https://openmed.life/docs/mlx-backend/](https://openmed.life/docs/mlx-backend/)
|
| 105 |
+
- OpenMedKit docs: [https://openmed.life/docs/swift-openmedkit/](https://openmed.life/docs/swift-openmedkit/)
|
|
|