MaziyarPanahi commited on
Commit
51f9a00
·
verified ·
1 Parent(s): d07ecc6

Upload MLX packaging for OpenMed-NER-ChemicalDetect-SuperClinical-434M-mlx

Browse files
Files changed (7) hide show
  1. README.md +79 -0
  2. config.json +61 -0
  3. id2label.json +5 -0
  4. openmed-mlx.json +26 -0
  5. tokenizer.json +0 -0
  6. tokenizer_config.json +20 -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-ChemicalDetect-SuperClinical-434M
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-ChemicalDetect-SuperClinical-434M for OpenMed MLX
18
+
19
+ This repository contains an OpenMed MLX conversion of [`OpenMed/OpenMed-NER-ChemicalDetect-SuperClinical-434M`](https://huggingface.co/OpenMed/OpenMed-NER-ChemicalDetect-SuperClinical-434M) 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: `deberta-v2`
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-ChemicalDetect-SuperClinical-434M`](https://huggingface.co/OpenMed/OpenMed-NER-ChemicalDetect-SuperClinical-434M)
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-ChemicalDetect-SuperClinical-434M",
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-ChemicalDetect-SuperClinical-434M`](https://huggingface.co/OpenMed/OpenMed-NER-ChemicalDetect-SuperClinical-434M)
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,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "transformers_version": "5.5.0",
3
+ "architectures": [
4
+ "DebertaV2ForTokenClassification"
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-CHEM",
14
+ "2": "I-CHEM"
15
+ },
16
+ "label2id": {
17
+ "B-CHEM": 1,
18
+ "I-CHEM": 2,
19
+ "O": 0
20
+ },
21
+ "problem_type": null,
22
+ "vocab_size": 128100,
23
+ "hidden_size": 1024,
24
+ "num_hidden_layers": 24,
25
+ "num_attention_heads": 16,
26
+ "intermediate_size": 4096,
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": 0,
32
+ "initializer_range": 0.02,
33
+ "layer_norm_eps": 1e-07,
34
+ "relative_attention": true,
35
+ "max_relative_positions": -1,
36
+ "pad_token_id": 0,
37
+ "bos_token_id": null,
38
+ "eos_token_id": null,
39
+ "position_biased_input": false,
40
+ "pos_att_type": [
41
+ "p2c",
42
+ "c2p"
43
+ ],
44
+ "pooler_dropout": 0,
45
+ "pooler_hidden_act": "gelu",
46
+ "legacy": true,
47
+ "tie_word_embeddings": true,
48
+ "pooler_hidden_size": 1024,
49
+ "_name_or_path": "OpenMed/OpenMed-NER-ChemicalDetect-SuperClinical-434M",
50
+ "model_type": "deberta-v2",
51
+ "norm_rel_ebd": "layer_norm",
52
+ "position_buckets": 256,
53
+ "share_att_key": true,
54
+ "output_attentions": false,
55
+ "_mlx_task": "token-classification",
56
+ "_mlx_family": "deberta-v2",
57
+ "_mlx_position_offset": 0,
58
+ "_mlx_model_type": "deberta-v2",
59
+ "num_labels": 3,
60
+ "_mlx_weights_format": "safetensors"
61
+ }
id2label.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "0": "O",
3
+ "1": "B-CHEM",
4
+ "2": "I-CHEM"
5
+ }
openmed-mlx.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": "openmed-mlx",
3
+ "format_version": 2,
4
+ "task": "token-classification",
5
+ "family": "deberta-v2",
6
+ "source_model_id": "OpenMed/OpenMed-NER-ChemicalDetect-SuperClinical-434M",
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,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": true,
3
+ "backend": "tokenizers",
4
+ "bos_token": "[CLS]",
5
+ "clean_up_tokenization_spaces": false,
6
+ "cls_token": "[CLS]",
7
+ "do_lower_case": false,
8
+ "eos_token": "[SEP]",
9
+ "is_local": false,
10
+ "mask_token": "[MASK]",
11
+ "model_max_length": 1000000000000000019884624838656,
12
+ "pad_token": "[PAD]",
13
+ "sep_token": "[SEP]",
14
+ "sp_model_kwargs": {},
15
+ "split_by_punct": false,
16
+ "tokenizer_class": "DebertaV2Tokenizer",
17
+ "unk_id": 3,
18
+ "unk_token": "[UNK]",
19
+ "vocab_type": "spm"
20
+ }
weights.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4957f9124afdd133e7d1a3b693e84243a7d43c4b33e90deaecce2bbbf24c52d0
3
+ size 1736107082