MaziyarPanahi commited on
Commit
c63eaea
·
verified ·
1 Parent(s): daa98c4

Upload MLX packaging for OpenMed-NER-GenomeDetect-BioClinical-108M-mlx

Browse files
Files changed (7) hide show
  1. README.md +79 -0
  2. config.json +52 -0
  3. id2label.json +5 -0
  4. openmed-mlx.json +26 -0
  5. tokenizer.json +0 -0
  6. tokenizer_config.json +24 -0
  7. weights.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: OpenMed/OpenMed-NER-GenomeDetect-BioClinical-108M
4
+ pipeline_tag: token-classification
5
+ library_name: openmed
6
+ tags:
7
+ - openmed
8
+ - mlx
9
+ - apple-silicon
10
+ - token-classification
11
+ - pii
12
+ - de-identification
13
+ - medical
14
+ - clinical
15
+ ---
16
+
17
+ # OpenMed-NER-GenomeDetect-BioClinical-108M for OpenMed MLX
18
+
19
+ This repository contains an OpenMed MLX conversion of [`OpenMed/OpenMed-NER-GenomeDetect-BioClinical-108M`](https://huggingface.co/OpenMed/OpenMed-NER-GenomeDetect-BioClinical-108M) for Apple Silicon inference with [OpenMed](https://github.com/maziyarpanahi/openmed).
20
+
21
+ Artifact metadata:
22
+
23
+ - OpenMed MLX task: `token-classification`
24
+ - OpenMed MLX family: `bert`
25
+ - Weight format: `safetensors`
26
+ - Runtime API: `OpenMed MLX token-classification backend`
27
+
28
+ [OpenMed](https://github.com/maziyarpanahi/openmed) is the main product experience:
29
+
30
+ - Install the Python package with `pip install openmed`
31
+ - Enable Apple Silicon acceleration with `pip install "openmed[mlx]"`
32
+ - Load this MLX model directly from the Hub or from a local snapshot
33
+ - For Apple apps, use OpenMedKit from the same GitHub repository with a compatible CoreML bundle
34
+
35
+ This MLX repo is meant to pair with:
36
+
37
+ - OpenMed GitHub: [https://github.com/maziyarpanahi/openmed](https://github.com/maziyarpanahi/openmed)
38
+ - OpenMed website: [https://openmed.life](https://openmed.life)
39
+ - Source checkpoint: [`OpenMed/OpenMed-NER-GenomeDetect-BioClinical-108M`](https://huggingface.co/OpenMed/OpenMed-NER-GenomeDetect-BioClinical-108M)
40
+
41
+ ## Quick Start
42
+
43
+ ```bash
44
+ pip install openmed
45
+ pip install "openmed[mlx]"
46
+ ```
47
+
48
+ ```python
49
+ from openmed import analyze_text
50
+ from openmed.core.config import OpenMedConfig
51
+
52
+ result = analyze_text(
53
+ "Patient John Doe, DOB 1990-05-15, SSN 123-45-6789",
54
+ model_name="OpenMed/OpenMed-NER-GenomeDetect-BioClinical-108M",
55
+ config=OpenMedConfig(backend="mlx"),
56
+ )
57
+
58
+ for entity in result.entities:
59
+ print(entity.label, entity.text, round(entity.confidence, 4))
60
+ ```
61
+
62
+ ## Swift and Apple Apps
63
+
64
+ Use Swift with OpenMedKit, not with MLX weight files directly.
65
+
66
+ 1. Open Xcode and go to File > Add Package Dependencies.
67
+ 2. Paste the OpenMed repository URL: `https://github.com/maziyarpanahi/openmed`
68
+ 3. Choose the package product OpenMedKit from the repository.
69
+ 4. Add a compatible CoreML model bundle plus `id2label.json` to your app target.
70
+
71
+ This MLX model is for Python services on Apple Silicon, local MLX inference on macOS, and Hub-hosted model distribution. If a given environment cannot write `weights.safetensors`, OpenMed falls back to `weights.npz` so the model remains usable.
72
+
73
+ ## Credits
74
+
75
+ - Base checkpoint: [`OpenMed/OpenMed-NER-GenomeDetect-BioClinical-108M`](https://huggingface.co/OpenMed/OpenMed-NER-GenomeDetect-BioClinical-108M)
76
+ - OpenMed GitHub: [https://github.com/maziyarpanahi/openmed](https://github.com/maziyarpanahi/openmed)
77
+ - OpenMed website: [https://openmed.life](https://openmed.life)
78
+ - MLX conversion and runtime support: OpenMed
79
+ - Swift runtime for Apple apps: OpenMedKit from the OpenMed repository
config.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "transformers_version": "5.5.0",
3
+ "architectures": [
4
+ "BertForTokenClassification"
5
+ ],
6
+ "output_hidden_states": false,
7
+ "return_dict": true,
8
+ "dtype": "bfloat16",
9
+ "chunk_size_feed_forward": 0,
10
+ "is_encoder_decoder": false,
11
+ "id2label": {
12
+ "0": "O",
13
+ "1": "B-GENE/PROTEIN",
14
+ "2": "I-GENE/PROTEIN"
15
+ },
16
+ "label2id": {
17
+ "B-GENE/PROTEIN": 1,
18
+ "I-GENE/PROTEIN": 2,
19
+ "O": 0
20
+ },
21
+ "problem_type": null,
22
+ "vocab_size": 28996,
23
+ "hidden_size": 768,
24
+ "num_hidden_layers": 12,
25
+ "num_attention_heads": 12,
26
+ "intermediate_size": 3072,
27
+ "hidden_act": "gelu",
28
+ "hidden_dropout_prob": 0.2,
29
+ "attention_probs_dropout_prob": 0.2,
30
+ "max_position_embeddings": 512,
31
+ "type_vocab_size": 2,
32
+ "initializer_range": 0.02,
33
+ "layer_norm_eps": 1e-07,
34
+ "pad_token_id": 0,
35
+ "use_cache": true,
36
+ "classifier_dropout": 0.2,
37
+ "is_decoder": false,
38
+ "add_cross_attention": false,
39
+ "bos_token_id": null,
40
+ "eos_token_id": null,
41
+ "tie_word_embeddings": true,
42
+ "_name_or_path": "OpenMed/OpenMed-NER-GenomeDetect-BioClinical-108M",
43
+ "model_type": "bert",
44
+ "position_embedding_type": "absolute",
45
+ "output_attentions": false,
46
+ "_mlx_task": "token-classification",
47
+ "_mlx_family": "bert",
48
+ "_mlx_position_offset": 0,
49
+ "_mlx_model_type": "bert",
50
+ "num_labels": 3,
51
+ "_mlx_weights_format": "safetensors"
52
+ }
id2label.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "0": "O",
3
+ "1": "B-GENE/PROTEIN",
4
+ "2": "I-GENE/PROTEIN"
5
+ }
openmed-mlx.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": "openmed-mlx",
3
+ "format_version": 2,
4
+ "task": "token-classification",
5
+ "family": "bert",
6
+ "source_model_id": "OpenMed/OpenMed-NER-GenomeDetect-BioClinical-108M",
7
+ "config_path": "config.json",
8
+ "label_map_path": "id2label.json",
9
+ "preferred_weights": "weights.safetensors",
10
+ "fallback_weights": [
11
+ "weights.npz"
12
+ ],
13
+ "available_weights": [
14
+ "weights.safetensors"
15
+ ],
16
+ "weights_format": "safetensors",
17
+ "quantization": null,
18
+ "max_sequence_length": 512,
19
+ "tokenizer": {
20
+ "path": ".",
21
+ "files": [
22
+ "tokenizer.json",
23
+ "tokenizer_config.json"
24
+ ]
25
+ }
26
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "clean_up_tokenization_spaces": true,
4
+ "cls_token": "[CLS]",
5
+ "do_basic_tokenize": true,
6
+ "do_lower_case": true,
7
+ "is_local": false,
8
+ "mask_token": "[MASK]",
9
+ "max_length": 512,
10
+ "model_max_length": 1000000000000000019884624838656,
11
+ "never_split": null,
12
+ "pad_to_multiple_of": null,
13
+ "pad_token": "[PAD]",
14
+ "pad_token_type_id": 0,
15
+ "padding_side": "right",
16
+ "sep_token": "[SEP]",
17
+ "stride": 0,
18
+ "strip_accents": null,
19
+ "tokenize_chinese_chars": true,
20
+ "tokenizer_class": "BertTokenizer",
21
+ "truncation_side": "right",
22
+ "truncation_strategy": "longest_first",
23
+ "unk_token": "[UNK]"
24
+ }
weights.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b15584351645862897ed8bc605b0712c2abb8b6066addaec4ecabb52af173e41
3
+ size 430909062