MaziyarPanahi commited on
Commit
64865df
·
verified ·
1 Parent(s): e50a835

Upload MLX packaging for OpenMed-NER-DNADetect-MultiMed-335M-mlx

Browse files
Files changed (7) hide show
  1. README.md +79 -0
  2. config.json +69 -0
  3. id2label.json +13 -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-DNADetect-MultiMed-335M
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-DNADetect-MultiMed-335M for OpenMed MLX
18
+
19
+ This repository contains an OpenMed MLX conversion of [`OpenMed/OpenMed-NER-DNADetect-MultiMed-335M`](https://huggingface.co/OpenMed/OpenMed-NER-DNADetect-MultiMed-335M) 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-DNADetect-MultiMed-335M`](https://huggingface.co/OpenMed/OpenMed-NER-DNADetect-MultiMed-335M)
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-DNADetect-MultiMed-335M",
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-DNADetect-MultiMed-335M`](https://huggingface.co/OpenMed/OpenMed-NER-DNADetect-MultiMed-335M)
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,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-DNA",
14
+ "2": "B-RNA",
15
+ "3": "B-cell_line",
16
+ "4": "B-cell_type",
17
+ "5": "B-protein",
18
+ "6": "I-DNA",
19
+ "7": "I-RNA",
20
+ "8": "I-cell_line",
21
+ "9": "I-cell_type",
22
+ "10": "I-protein"
23
+ },
24
+ "label2id": {
25
+ "B-DNA": 1,
26
+ "B-RNA": 2,
27
+ "B-cell_line": 3,
28
+ "B-cell_type": 4,
29
+ "B-protein": 5,
30
+ "I-DNA": 6,
31
+ "I-RNA": 7,
32
+ "I-cell_line": 8,
33
+ "I-cell_type": 9,
34
+ "I-protein": 10,
35
+ "O": 0
36
+ },
37
+ "problem_type": null,
38
+ "vocab_size": 30522,
39
+ "hidden_size": 1024,
40
+ "num_hidden_layers": 24,
41
+ "num_attention_heads": 16,
42
+ "intermediate_size": 4096,
43
+ "hidden_act": "gelu",
44
+ "hidden_dropout_prob": 0.2,
45
+ "attention_probs_dropout_prob": 0.2,
46
+ "max_position_embeddings": 512,
47
+ "type_vocab_size": 2,
48
+ "initializer_range": 0.02,
49
+ "layer_norm_eps": 1e-07,
50
+ "pad_token_id": 0,
51
+ "use_cache": true,
52
+ "classifier_dropout": 0.2,
53
+ "is_decoder": false,
54
+ "add_cross_attention": false,
55
+ "bos_token_id": null,
56
+ "eos_token_id": null,
57
+ "tie_word_embeddings": true,
58
+ "_name_or_path": "OpenMed/OpenMed-NER-DNADetect-MultiMed-335M",
59
+ "gradient_checkpointing": false,
60
+ "model_type": "bert",
61
+ "position_embedding_type": "absolute",
62
+ "output_attentions": false,
63
+ "_mlx_task": "token-classification",
64
+ "_mlx_family": "bert",
65
+ "_mlx_position_offset": 0,
66
+ "_mlx_model_type": "bert",
67
+ "num_labels": 11,
68
+ "_mlx_weights_format": "safetensors"
69
+ }
id2label.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "0": "O",
3
+ "1": "B-DNA",
4
+ "2": "B-RNA",
5
+ "3": "B-cell_line",
6
+ "4": "B-cell_type",
7
+ "5": "B-protein",
8
+ "6": "I-DNA",
9
+ "7": "I-RNA",
10
+ "8": "I-cell_line",
11
+ "9": "I-cell_type",
12
+ "10": "I-protein"
13
+ }
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-DNADetect-MultiMed-335M",
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": 512,
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:cdbf4498a4feb064f72366af9f5f09e7b7bb4fc73b6c8d6d36af8743b98a517a
3
+ size 1336456765