MaziyarPanahi commited on
Commit
f7ca401
·
verified ·
1 Parent(s): 36a26f2

Upload MLX packaging for OpenMed-NER-OncologyDetect-SnowMed-568M-mlx

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: OpenMed/OpenMed-NER-OncologyDetect-SnowMed-568M
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-OncologyDetect-SnowMed-568M for OpenMed MLX
18
+
19
+ This repository contains an OpenMed MLX conversion of [`OpenMed/OpenMed-NER-OncologyDetect-SnowMed-568M`](https://huggingface.co/OpenMed/OpenMed-NER-OncologyDetect-SnowMed-568M) 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-OncologyDetect-SnowMed-568M`](https://huggingface.co/OpenMed/OpenMed-NER-OncologyDetect-SnowMed-568M)
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-OncologyDetect-SnowMed-568M",
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-OncologyDetect-SnowMed-568M`](https://huggingface.co/OpenMed/OpenMed-NER-OncologyDetect-SnowMed-568M)
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,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "transformers_version": "5.5.0",
3
+ "architectures": [
4
+ "XLMRobertaForTokenClassification"
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": "B-Amino_acid",
13
+ "1": "B-Anatomical_system",
14
+ "2": "B-Cancer",
15
+ "3": "B-Cell",
16
+ "4": "B-Cellular_component",
17
+ "5": "B-Developing_anatomical_structure",
18
+ "6": "B-Gene_or_gene_product",
19
+ "7": "B-Immaterial_anatomical_entity",
20
+ "8": "B-Multi-tissue_structure",
21
+ "9": "B-Organ",
22
+ "10": "B-Organism",
23
+ "11": "B-Organism_subdivision",
24
+ "12": "B-Organism_substance",
25
+ "13": "B-Pathological_formation",
26
+ "14": "B-Simple_chemical",
27
+ "15": "B-Tissue",
28
+ "16": "I-Amino_acid",
29
+ "17": "I-Anatomical_system",
30
+ "18": "I-Cancer",
31
+ "19": "I-Cell",
32
+ "20": "I-Cellular_component",
33
+ "21": "I-Developing_anatomical_structure",
34
+ "22": "I-Gene_or_gene_product",
35
+ "23": "I-Immaterial_anatomical_entity",
36
+ "24": "I-Multi-tissue_structure",
37
+ "25": "I-Organ",
38
+ "26": "I-Organism",
39
+ "27": "I-Organism_subdivision",
40
+ "28": "I-Organism_substance",
41
+ "29": "I-Pathological_formation",
42
+ "30": "I-Simple_chemical",
43
+ "31": "I-Tissue",
44
+ "32": "O"
45
+ },
46
+ "label2id": {
47
+ "B-Amino_acid": 0,
48
+ "B-Anatomical_system": 1,
49
+ "B-Cancer": 2,
50
+ "B-Cell": 3,
51
+ "B-Cellular_component": 4,
52
+ "B-Developing_anatomical_structure": 5,
53
+ "B-Gene_or_gene_product": 6,
54
+ "B-Immaterial_anatomical_entity": 7,
55
+ "B-Multi-tissue_structure": 8,
56
+ "B-Organ": 9,
57
+ "B-Organism": 10,
58
+ "B-Organism_subdivision": 11,
59
+ "B-Organism_substance": 12,
60
+ "B-Pathological_formation": 13,
61
+ "B-Simple_chemical": 14,
62
+ "B-Tissue": 15,
63
+ "I-Amino_acid": 16,
64
+ "I-Anatomical_system": 17,
65
+ "I-Cancer": 18,
66
+ "I-Cell": 19,
67
+ "I-Cellular_component": 20,
68
+ "I-Developing_anatomical_structure": 21,
69
+ "I-Gene_or_gene_product": 22,
70
+ "I-Immaterial_anatomical_entity": 23,
71
+ "I-Multi-tissue_structure": 24,
72
+ "I-Organ": 25,
73
+ "I-Organism": 26,
74
+ "I-Organism_subdivision": 27,
75
+ "I-Organism_substance": 28,
76
+ "I-Pathological_formation": 29,
77
+ "I-Simple_chemical": 30,
78
+ "I-Tissue": 31,
79
+ "O": 32
80
+ },
81
+ "problem_type": null,
82
+ "vocab_size": 250002,
83
+ "hidden_size": 1024,
84
+ "num_hidden_layers": 24,
85
+ "num_attention_heads": 16,
86
+ "intermediate_size": 4096,
87
+ "hidden_act": "gelu",
88
+ "hidden_dropout_prob": 0.2,
89
+ "attention_probs_dropout_prob": 0.2,
90
+ "max_position_embeddings": 8194,
91
+ "type_vocab_size": 1,
92
+ "initializer_range": 0.02,
93
+ "layer_norm_eps": 1e-07,
94
+ "pad_token_id": 1,
95
+ "bos_token_id": 0,
96
+ "eos_token_id": 2,
97
+ "use_cache": true,
98
+ "classifier_dropout": 0.2,
99
+ "is_decoder": false,
100
+ "add_cross_attention": false,
101
+ "tie_word_embeddings": true,
102
+ "_name_or_path": "OpenMed/OpenMed-NER-OncologyDetect-SnowMed-568M",
103
+ "matryoshka_dimensions": [
104
+ 256
105
+ ],
106
+ "model_type": "xlm-roberta",
107
+ "output_past": true,
108
+ "position_embedding_type": "absolute",
109
+ "output_attentions": false,
110
+ "_mlx_task": "token-classification",
111
+ "_mlx_family": "bert",
112
+ "_mlx_position_offset": 2,
113
+ "_mlx_model_type": "bert",
114
+ "num_labels": 33,
115
+ "_mlx_weights_format": "safetensors"
116
+ }
id2label.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "0": "B-Amino_acid",
3
+ "1": "B-Anatomical_system",
4
+ "2": "B-Cancer",
5
+ "3": "B-Cell",
6
+ "4": "B-Cellular_component",
7
+ "5": "B-Developing_anatomical_structure",
8
+ "6": "B-Gene_or_gene_product",
9
+ "7": "B-Immaterial_anatomical_entity",
10
+ "8": "B-Multi-tissue_structure",
11
+ "9": "B-Organ",
12
+ "10": "B-Organism",
13
+ "11": "B-Organism_subdivision",
14
+ "12": "B-Organism_substance",
15
+ "13": "B-Pathological_formation",
16
+ "14": "B-Simple_chemical",
17
+ "15": "B-Tissue",
18
+ "16": "I-Amino_acid",
19
+ "17": "I-Anatomical_system",
20
+ "18": "I-Cancer",
21
+ "19": "I-Cell",
22
+ "20": "I-Cellular_component",
23
+ "21": "I-Developing_anatomical_structure",
24
+ "22": "I-Gene_or_gene_product",
25
+ "23": "I-Immaterial_anatomical_entity",
26
+ "24": "I-Multi-tissue_structure",
27
+ "25": "I-Organ",
28
+ "26": "I-Organism",
29
+ "27": "I-Organism_subdivision",
30
+ "28": "I-Organism_substance",
31
+ "29": "I-Pathological_formation",
32
+ "30": "I-Simple_chemical",
33
+ "31": "I-Tissue",
34
+ "32": "O"
35
+ }
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-OncologyDetect-SnowMed-568M",
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": 8194,
19
+ "tokenizer": {
20
+ "path": ".",
21
+ "files": [
22
+ "tokenizer.json",
23
+ "tokenizer_config.json"
24
+ ]
25
+ }
26
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ffb37461c391f096759f4a9bbbc329da0f36952f88bab061fcf84940c022e98
3
+ size 17082999
tokenizer_config.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": true,
3
+ "backend": "tokenizers",
4
+ "bos_token": "<s>",
5
+ "clean_up_tokenization_spaces": true,
6
+ "cls_token": "<s>",
7
+ "eos_token": "</s>",
8
+ "is_local": false,
9
+ "mask_token": "<mask>",
10
+ "max_length": 512,
11
+ "model_max_length": 8192,
12
+ "pad_to_multiple_of": null,
13
+ "pad_token": "<pad>",
14
+ "pad_token_type_id": 0,
15
+ "padding_side": "right",
16
+ "sep_token": "</s>",
17
+ "stride": 0,
18
+ "tokenizer_class": "XLMRobertaTokenizer",
19
+ "truncation_side": "right",
20
+ "truncation_strategy": "longest_first",
21
+ "unk_token": "<unk>"
22
+ }
weights.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:70a4754eb100383932d01464480d4fd365f350556feb0bc64338ef5500b57138
3
+ size 2266998427