MaziyarPanahi's picture
Refresh README for current MLX and OpenMedKit instructions
ed98e83 verified
---
license: apache-2.0
base_model: OpenMed/OpenMed-PII-BioClinicalBERT-Base-110M-v1
pipeline_tag: token-classification
library_name: openmed
tags:
- openmed
- mlx
- apple-silicon
- token-classification
- pii
- de-identification
- medical
- clinical
---
# OpenMed-PII-BioClinicalBERT-Base-110M-v1 for OpenMed MLX
This repository contains an MLX packaging of [`OpenMed/OpenMed-PII-BioClinicalBERT-Base-110M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-BioClinicalBERT-Base-110M-v1) for Apple Silicon inference with [OpenMed](https://github.com/maziyarpanahi/openmed).
## At a Glance
- **Source checkpoint:** [`OpenMed/OpenMed-PII-BioClinicalBERT-Base-110M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-BioClinicalBERT-Base-110M-v1)
- **Model family:** `bert` (`BertForTokenClassification`)
- **Primary language hint:** English (`en`)
- **Artifact layout:** legacy-compatible MLX (`config.json`, `id2label.json`, MLX weight files)
- **Python MLX:** supported through `openmed[mlx]` on Apple Silicon Macs
- **Swift MLX:** supported today in OpenMedKit on Apple Silicon macOS and real iPhone/iPad hardware
## Python Quick Start
Use the standard OpenMed API if you want OpenMed to choose the right runtime automatically:
```bash
pip install "openmed[mlx]"
```
```python
from openmed import extract_pii
text = "<your clinical note here>"
result = extract_pii(
text,
model_name="OpenMed/OpenMed-PII-BioClinicalBERT-Base-110M-v1",
use_smart_merging=True,
)
for entity in result.entities:
print(entity.label, entity.text, round(entity.confidence, 4))
```
On Apple Silicon, OpenMed auto-selects MLX when `openmed[mlx]` is installed. On other systems it falls back to the Hugging Face / PyTorch backend.
## Use This Preconverted MLX Repo Directly
If you want to use this MLX snapshot explicitly, download it locally and point OpenMed at the directory:
```bash
pip install "openmed[mlx]"
hf download OpenMed/OpenMed-PII-BioClinicalBERT-Base-110M-v1-mlx --local-dir ./OpenMed-PII-BioClinicalBERT-Base-110M-v1-mlx
```
If this repo is still private in your environment, authenticate first with `hf auth login` or set `HF_TOKEN`.
```python
from openmed import extract_pii
from openmed.core import OpenMedConfig
text = "<your clinical note here>"
result = extract_pii(
text,
model_name="./OpenMed-PII-BioClinicalBERT-Base-110M-v1-mlx",
config=OpenMedConfig(backend="mlx"),
use_smart_merging=True,
)
print(result.entities)
```
## Swift Quick Start with OpenMedKit
OpenMedKit can download and run this MLX repo directly.
```swift
import OpenMedKit
let modelDirectory = try await OpenMedModelStore.downloadMLXModel(
repoID: "OpenMed/OpenMed-PII-BioClinicalBERT-Base-110M-v1-mlx",
authToken: "<hugging-face-token-while-private>"
)
let openmed = try OpenMed(
backend: .mlx(modelDirectoryURL: modelDirectory)
)
let entities = try openmed.extractPII(
"<your clinical note here>"
)
```
Notes:
- Swift MLX targets Apple Silicon macOS and physical iPhone/iPad hardware.
- iOS Simulator is not a Swift MLX target.
- If you already have a bundled `.mlmodelc` or `.mlpackage`, use the CoreML backend in OpenMedKit instead.
## Artifact Notes
This repo uses the current legacy-compatible MLX layout:
- `config.json`
- `id2label.json`
- MLX weight files (`weights.safetensors` and/or `weights.npz`)
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.
## Links
- Source checkpoint: [`OpenMed/OpenMed-PII-BioClinicalBERT-Base-110M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-BioClinicalBERT-Base-110M-v1)
- OpenMed GitHub: [https://github.com/maziyarpanahi/openmed](https://github.com/maziyarpanahi/openmed)
- MLX backend docs: [https://openmed.life/docs/mlx-backend/](https://openmed.life/docs/mlx-backend/)
- OpenMedKit docs: [https://openmed.life/docs/swift-openmedkit/](https://openmed.life/docs/swift-openmedkit/)