MaziyarPanahi commited on
Commit
deb93e8
·
verified ·
1 Parent(s): d8ac5d1

Refresh README for current MLX and OpenMedKit instructions

Browse files
Files changed (1) hide show
  1. README.md +53 -53
README.md CHANGED
@@ -16,90 +16,90 @@ tags:
16
 
17
  # OpenMed-PII-SuperClinical-Base-184M-v1 for OpenMed MLX
18
 
19
- This repository contains a **private 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
- [OpenMed](https://github.com/maziyarpanahi/openmed) is the main product experience:
22
 
23
- - Install the Python package with `pip install openmed`
24
- - Enable Apple Silicon acceleration with `pip install "openmed[mlx]"`
25
- - Run the same OpenMed API you already use, now backed by MLX on macOS
26
- - For Apple apps, use **OpenMedKit** from the same GitHub repository with a CoreML bundle
 
 
27
 
28
- This MLX repo is meant to pair with:
29
 
30
- - OpenMed GitHub: [https://github.com/maziyarpanahi/openmed](https://github.com/maziyarpanahi/openmed)
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 analyze_text
45
- from openmed.core.config import OpenMedConfig
46
 
47
- result = analyze_text(
48
- "Patient John Doe, DOB 1990-05-15, SSN 123-45-6789",
 
49
  model_name="OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1",
50
- config=OpenMedConfig(backend="mlx"),
51
  )
52
 
53
  for entity in result.entities:
54
  print(entity.label, entity.text, round(entity.confidence, 4))
55
  ```
56
 
57
- You can use the source model ID directly through OpenMed, or download this private MLX packaging from [`OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1-mlx`](https://huggingface.co/OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1-mlx) for a preconverted path.
58
 
59
- ### Swift
60
 
61
- Use Swift with **OpenMedKit**, not with MLX weight files directly.
62
 
63
- 1. Open Xcode and go to **File > Add Package Dependencies...**
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
- After that, import OpenMedKit in Swift:
70
 
71
- ```swift
72
- import OpenMedKit
 
 
 
 
 
 
 
 
 
 
 
73
  ```
74
 
75
- Then load your bundled CoreML model and label map:
76
 
77
- ```swift
78
- import Foundation
79
- import OpenMedKit
80
 
81
- let modelFolder = Bundle.main.resourceURL!
82
- let modelURL = modelFolder.appendingPathComponent("OpenMedPII.mlmodelc")
83
- let labelsURL = modelFolder.appendingPathComponent("id2label.json")
84
 
85
- let openmed = try OpenMed(
86
- modelURL: modelURL,
87
- id2labelURL: labelsURL
88
- )
89
- ```
90
 
91
- This private MLX artifact remains the right choice for:
92
 
93
- - Python services on Apple Silicon
94
- - local MLX inference on macOS
95
- - private preconverted packaging on the Hub
96
 
97
- If a given architecture or environment cannot be exported cleanly as `safetensors`, OpenMed falls back to `weights.npz` so the model remains usable.
 
 
98
 
99
- ## Credits
100
 
101
- - Base checkpoint: [`OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-SuperClinical-Base-184M-v1)
 
 
102
  - OpenMed GitHub: [https://github.com/maziyarpanahi/openmed](https://github.com/maziyarpanahi/openmed)
103
- - OpenMed website: [https://openmed.life](https://openmed.life)
104
- - MLX packaging and runtime support: [**OpenMed**](https://github.com/maziyarpanahi/openmed)
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/)