Refresh README for current MLX and OpenMedKit instructions
Browse files
README.md
CHANGED
|
@@ -16,90 +16,109 @@ tags:
|
|
| 16 |
|
| 17 |
# OpenMed-PII-Italian-FastClinical-Small-82M-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-Italian-FastClinical-Small-82M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-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-Italian-FastClinical-Small-82M-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 |
-
2. Paste the OpenMed repository URL:
|
| 65 |
-
`https://github.com/maziyarpanahi/openmed`
|
| 66 |
-
3. Choose the package product **OpenMedKit** from the repository.
|
| 67 |
-
4. Add a compatible CoreML model bundle plus `id2label.json` to your app target.
|
| 68 |
|
| 69 |
-
|
|
|
|
|
|
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
```
|
| 74 |
|
| 75 |
-
|
|
|
|
|
|
|
| 76 |
|
| 77 |
```swift
|
| 78 |
-
import Foundation
|
| 79 |
import OpenMedKit
|
| 80 |
|
| 81 |
-
let
|
| 82 |
-
|
| 83 |
-
|
|
|
|
| 84 |
|
| 85 |
let openmed = try OpenMed(
|
| 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-Italian-FastClinical-Small-82M-v1 for OpenMed MLX
|
| 18 |
|
| 19 |
+
This repository contains an MLX packaging of [`OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1) for Apple Silicon inference with [OpenMed](https://github.com/maziyarpanahi/openmed).
|
| 20 |
|
| 21 |
+
## At a Glance
|
| 22 |
|
| 23 |
+
- **Source checkpoint:** [`OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1)
|
| 24 |
+
- **Model family:** `roberta` (`RobertaForTokenClassification`)
|
| 25 |
+
- **Primary language hint:** Italian (`it`)
|
| 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:** supported today in OpenMedKit on Apple Silicon macOS and real iPhone/iPad hardware
|
| 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 Italian clinical note here>"
|
| 42 |
+
result = extract_pii(
|
| 43 |
+
text,
|
| 44 |
model_name="OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1",
|
| 45 |
+
lang="it",
|
| 46 |
+
use_smart_merging=True,
|
| 47 |
)
|
| 48 |
|
| 49 |
for entity in result.entities:
|
| 50 |
print(entity.label, entity.text, round(entity.confidence, 4))
|
| 51 |
```
|
| 52 |
|
| 53 |
+
On Apple Silicon, OpenMed auto-selects MLX when `openmed[mlx]` is installed. On other systems it falls back to the Hugging Face / PyTorch backend.
|
| 54 |
+
|
| 55 |
+
## Use This Preconverted MLX Repo Directly
|
| 56 |
|
| 57 |
+
If you want to use this MLX snapshot explicitly, download it locally and point OpenMed at the directory:
|
| 58 |
|
| 59 |
+
```bash
|
| 60 |
+
pip install "openmed[mlx]"
|
| 61 |
+
hf download OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1-mlx --local-dir ./OpenMed-PII-Italian-FastClinical-Small-82M-v1-mlx
|
| 62 |
+
```
|
| 63 |
|
| 64 |
+
If this repo is still private in your environment, authenticate first with `hf auth login` or set `HF_TOKEN`.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
+
```python
|
| 67 |
+
from openmed import extract_pii
|
| 68 |
+
from openmed.core import OpenMedConfig
|
| 69 |
|
| 70 |
+
text = "<your Italian clinical note here>"
|
| 71 |
+
result = extract_pii(
|
| 72 |
+
text,
|
| 73 |
+
model_name="./OpenMed-PII-Italian-FastClinical-Small-82M-v1-mlx",
|
| 74 |
+
config=OpenMedConfig(backend="mlx"),
|
| 75 |
+
lang="it",
|
| 76 |
+
use_smart_merging=True,
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
print(result.entities)
|
| 80 |
```
|
| 81 |
|
| 82 |
+
## Swift Quick Start with OpenMedKit
|
| 83 |
+
|
| 84 |
+
OpenMedKit can download and run this MLX repo directly.
|
| 85 |
|
| 86 |
```swift
|
|
|
|
| 87 |
import OpenMedKit
|
| 88 |
|
| 89 |
+
let modelDirectory = try await OpenMedModelStore.downloadMLXModel(
|
| 90 |
+
repoID: "OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1-mlx",
|
| 91 |
+
authToken: "<hugging-face-token-while-private>"
|
| 92 |
+
)
|
| 93 |
|
| 94 |
let openmed = try OpenMed(
|
| 95 |
+
backend: .mlx(modelDirectoryURL: modelDirectory)
|
| 96 |
+
)
|
| 97 |
+
|
| 98 |
+
let entities = try openmed.extractPII(
|
| 99 |
+
"<your Italian clinical note here>"
|
| 100 |
)
|
| 101 |
```
|
| 102 |
|
| 103 |
+
Notes:
|
| 104 |
+
|
| 105 |
+
- Swift MLX targets Apple Silicon macOS and physical iPhone/iPad hardware.
|
| 106 |
+
- iOS Simulator is not a Swift MLX target.
|
| 107 |
+
- If you already have a bundled `.mlmodelc` or `.mlpackage`, use the CoreML backend in OpenMedKit instead.
|
| 108 |
+
|
| 109 |
+
## Artifact Notes
|
| 110 |
|
| 111 |
+
This repo uses the current legacy-compatible MLX layout:
|
|
|
|
|
|
|
| 112 |
|
| 113 |
+
- `config.json`
|
| 114 |
+
- `id2label.json`
|
| 115 |
+
- MLX weight files (`weights.safetensors` and/or `weights.npz`)
|
| 116 |
|
| 117 |
+
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.
|
| 118 |
|
| 119 |
+
## Links
|
| 120 |
+
|
| 121 |
+
- Source checkpoint: [`OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1)
|
| 122 |
- OpenMed GitHub: [https://github.com/maziyarpanahi/openmed](https://github.com/maziyarpanahi/openmed)
|
| 123 |
+
- MLX backend docs: [https://openmed.life/docs/mlx-backend/](https://openmed.life/docs/mlx-backend/)
|
| 124 |
+
- OpenMedKit docs: [https://openmed.life/docs/swift-openmedkit/](https://openmed.life/docs/swift-openmedkit/)
|
|
|