MaziyarPanahi commited on
Commit
dd35d1b
·
verified ·
1 Parent(s): 483e5aa

Upload MLX packaging for OpenMed-NER-ProteinDetect-BioMed-109M-mlx

Browse files
Files changed (7) hide show
  1. README.md +79 -0
  2. config.json +68 -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-ProteinDetect-BioMed-109M
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-ProteinDetect-BioMed-109M for OpenMed MLX
18
+
19
+ This repository contains an OpenMed MLX conversion of [`OpenMed/OpenMed-NER-ProteinDetect-BioMed-109M`](https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-BioMed-109M) 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-ProteinDetect-BioMed-109M`](https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-BioMed-109M)
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-ProteinDetect-BioMed-109M",
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-ProteinDetect-BioMed-109M`](https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-BioMed-109M)
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,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": "B-protein",
13
+ "1": "B-protein_complex",
14
+ "2": "B-protein_enum",
15
+ "3": "B-protein_familiy_or_group",
16
+ "4": "B-protein_variant",
17
+ "5": "I-protein",
18
+ "6": "I-protein_complex",
19
+ "7": "I-protein_enum",
20
+ "8": "I-protein_familiy_or_group",
21
+ "9": "I-protein_variant",
22
+ "10": "O"
23
+ },
24
+ "label2id": {
25
+ "B-protein": 0,
26
+ "B-protein_complex": 1,
27
+ "B-protein_enum": 2,
28
+ "B-protein_familiy_or_group": 3,
29
+ "B-protein_variant": 4,
30
+ "I-protein": 5,
31
+ "I-protein_complex": 6,
32
+ "I-protein_enum": 7,
33
+ "I-protein_familiy_or_group": 8,
34
+ "I-protein_variant": 9,
35
+ "O": 10
36
+ },
37
+ "problem_type": null,
38
+ "vocab_size": 30522,
39
+ "hidden_size": 768,
40
+ "num_hidden_layers": 12,
41
+ "num_attention_heads": 12,
42
+ "intermediate_size": 3072,
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-ProteinDetect-BioMed-109M",
59
+ "model_type": "bert",
60
+ "position_embedding_type": "absolute",
61
+ "output_attentions": false,
62
+ "_mlx_task": "token-classification",
63
+ "_mlx_family": "bert",
64
+ "_mlx_position_offset": 0,
65
+ "_mlx_model_type": "bert",
66
+ "num_labels": 11,
67
+ "_mlx_weights_format": "safetensors"
68
+ }
id2label.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "0": "B-protein",
3
+ "1": "B-protein_complex",
4
+ "2": "B-protein_enum",
5
+ "3": "B-protein_familiy_or_group",
6
+ "4": "B-protein_variant",
7
+ "5": "I-protein",
8
+ "6": "I-protein_complex",
9
+ "7": "I-protein_enum",
10
+ "8": "I-protein_familiy_or_group",
11
+ "9": "I-protein_variant",
12
+ "10": "O"
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-ProteinDetect-BioMed-109M",
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:64a8942b3ca375e810dd4e7e31ca5b7e7fa9baa3e948cf0f70ec537d8f421dd2
3
+ size 435621544