MaziyarPanahi commited on
Commit
6a8fe80
·
verified ·
1 Parent(s): c1dd25e

Upload MLX packaging for OpenMed-PII-Italian-FastClinical-Small-82M-v1-mlx

Browse files
Files changed (4) hide show
  1. README.md +105 -0
  2. config.json +196 -0
  3. id2label.json +78 -0
  4. weights.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1
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-PII-Italian-FastClinical-Small-82M-v1 for OpenMed MLX
18
+
19
+ This repository contains a **private MLX packaging** of [`OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1) for Apple Silicon inference with [**OpenMed**](https://github.com/maziyarpanahi/openmed).
20
+
21
+ [OpenMed](https://github.com/maziyarpanahi/openmed) is the main product experience:
22
+
23
+ - Install the Python package with `pip install openmed`
24
+ - Enable Apple Silicon acceleration with `pip install "openmed[mlx]"`
25
+ - Run the same OpenMed API you already use, now backed by MLX on macOS
26
+ - For Apple apps, use **OpenMedKit** from the same GitHub repository with a CoreML bundle
27
+
28
+ This MLX repo is meant to pair with:
29
+
30
+ - OpenMed GitHub: [https://github.com/maziyarpanahi/openmed](https://github.com/maziyarpanahi/openmed)
31
+ - OpenMed website: [https://openmed.life](https://openmed.life)
32
+ - Source checkpoint: [`OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1)
33
+
34
+ ## Quick Start
35
+
36
+ ### Python
37
+
38
+ ```bash
39
+ pip install openmed
40
+ pip install "openmed[mlx]"
41
+ ```
42
+
43
+ ```python
44
+ from openmed import analyze_text
45
+ from openmed.core.config import OpenMedConfig
46
+
47
+ result = analyze_text(
48
+ "Patient John Doe, DOB 1990-05-15, SSN 123-45-6789",
49
+ model_name="OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1",
50
+ config=OpenMedConfig(backend="mlx"),
51
+ )
52
+
53
+ for entity in result.entities:
54
+ print(entity.label, entity.text, round(entity.confidence, 4))
55
+ ```
56
+
57
+ You can use the source model ID directly through OpenMed, or download this private MLX packaging from [`OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1-mlx`](https://huggingface.co/OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1-mlx) for a preconverted path.
58
+
59
+ ### Swift
60
+
61
+ Use Swift with **OpenMedKit**, not with MLX weight files directly.
62
+
63
+ 1. Open Xcode and go to **File > Add Package Dependencies...**
64
+ 2. Paste the OpenMed repository URL:
65
+ `https://github.com/maziyarpanahi/openmed`
66
+ 3. Choose the package product **OpenMedKit** from the repository.
67
+ 4. Add a compatible CoreML model bundle plus `id2label.json` to your app target.
68
+
69
+ After that, import OpenMedKit in Swift:
70
+
71
+ ```swift
72
+ import OpenMedKit
73
+ ```
74
+
75
+ Then load your bundled CoreML model and label map:
76
+
77
+ ```swift
78
+ import Foundation
79
+ import OpenMedKit
80
+
81
+ let modelFolder = Bundle.main.resourceURL!
82
+ let modelURL = modelFolder.appendingPathComponent("OpenMedPII.mlmodelc")
83
+ let labelsURL = modelFolder.appendingPathComponent("id2label.json")
84
+
85
+ let openmed = try OpenMed(
86
+ modelURL: modelURL,
87
+ id2labelURL: labelsURL
88
+ )
89
+ ```
90
+
91
+ This private MLX artifact remains the right choice for:
92
+
93
+ - Python services on Apple Silicon
94
+ - local MLX inference on macOS
95
+ - private preconverted packaging on the Hub
96
+
97
+ If a given architecture or environment cannot be exported cleanly as `safetensors`, OpenMed falls back to `weights.npz` so the model remains usable.
98
+
99
+ ## Credits
100
+
101
+ - Base checkpoint: [`OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1)
102
+ - OpenMed GitHub: [https://github.com/maziyarpanahi/openmed](https://github.com/maziyarpanahi/openmed)
103
+ - OpenMed website: [https://openmed.life](https://openmed.life)
104
+ - MLX packaging and runtime support: [**OpenMed**](https://github.com/maziyarpanahi/openmed)
105
+ - Swift runtime for Apple apps: **OpenMedKit** from the OpenMed repository
config.json ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "transformers_version": "5.5.0",
3
+ "architectures": [
4
+ "RobertaForTokenClassification"
5
+ ],
6
+ "output_hidden_states": false,
7
+ "return_dict": true,
8
+ "dtype": "float32",
9
+ "chunk_size_feed_forward": 0,
10
+ "is_encoder_decoder": false,
11
+ "id2label": {
12
+ "0": "O",
13
+ "1": "B-ACCOUNTNAME",
14
+ "2": "B-AGE",
15
+ "3": "B-AMOUNT",
16
+ "4": "B-BANKACCOUNT",
17
+ "5": "B-BIC",
18
+ "6": "B-BITCOINADDRESS",
19
+ "7": "B-BUILDINGNUMBER",
20
+ "8": "B-CITY",
21
+ "9": "B-COUNTY",
22
+ "10": "B-CREDITCARD",
23
+ "11": "B-CREDITCARDISSUER",
24
+ "12": "B-CURRENCY",
25
+ "13": "B-CURRENCYCODE",
26
+ "14": "B-CURRENCYNAME",
27
+ "15": "B-CURRENCYSYMBOL",
28
+ "16": "B-CVV",
29
+ "17": "B-DATE",
30
+ "18": "B-DATEOFBIRTH",
31
+ "19": "B-EMAIL",
32
+ "20": "B-ETHEREUMADDRESS",
33
+ "21": "B-EYECOLOR",
34
+ "22": "B-FIRSTNAME",
35
+ "23": "B-GENDER",
36
+ "24": "B-GPSCOORDINATES",
37
+ "25": "B-HEIGHT",
38
+ "26": "B-IBAN",
39
+ "27": "B-IMEI",
40
+ "28": "B-IPADDRESS",
41
+ "29": "B-JOBDEPARTMENT",
42
+ "30": "B-JOBTITLE",
43
+ "31": "B-LASTNAME",
44
+ "32": "B-LITECOINADDRESS",
45
+ "33": "B-MACADDRESS",
46
+ "34": "B-MASKEDNUMBER",
47
+ "35": "B-MIDDLENAME",
48
+ "36": "B-OCCUPATION",
49
+ "37": "B-ORDINALDIRECTION",
50
+ "38": "B-ORGANIZATION",
51
+ "39": "B-PASSWORD",
52
+ "40": "B-PHONE",
53
+ "41": "B-PIN",
54
+ "42": "B-PREFIX",
55
+ "43": "B-SECONDARYADDRESS",
56
+ "44": "B-SEX",
57
+ "45": "B-SSN",
58
+ "46": "B-STATE",
59
+ "47": "B-STREET",
60
+ "48": "B-TIME",
61
+ "49": "B-URL",
62
+ "50": "B-USERAGENT",
63
+ "51": "B-USERNAME",
64
+ "52": "B-VIN",
65
+ "53": "B-VRM",
66
+ "54": "B-ZIPCODE",
67
+ "55": "I-ACCOUNTNAME",
68
+ "56": "I-AGE",
69
+ "57": "I-AMOUNT",
70
+ "58": "I-CITY",
71
+ "59": "I-COUNTY",
72
+ "60": "I-CURRENCY",
73
+ "61": "I-CURRENCYNAME",
74
+ "62": "I-DATE",
75
+ "63": "I-DATEOFBIRTH",
76
+ "64": "I-EYECOLOR",
77
+ "65": "I-GENDER",
78
+ "66": "I-HEIGHT",
79
+ "67": "I-JOBTITLE",
80
+ "68": "I-ORGANIZATION",
81
+ "69": "I-PHONE",
82
+ "70": "I-SECONDARYADDRESS",
83
+ "71": "I-SSN",
84
+ "72": "I-STATE",
85
+ "73": "I-STREET",
86
+ "74": "I-TIME",
87
+ "75": "I-USERAGENT"
88
+ },
89
+ "label2id": {
90
+ "B-ACCOUNTNAME": 1,
91
+ "B-AGE": 2,
92
+ "B-AMOUNT": 3,
93
+ "B-BANKACCOUNT": 4,
94
+ "B-BIC": 5,
95
+ "B-BITCOINADDRESS": 6,
96
+ "B-BUILDINGNUMBER": 7,
97
+ "B-CITY": 8,
98
+ "B-COUNTY": 9,
99
+ "B-CREDITCARD": 10,
100
+ "B-CREDITCARDISSUER": 11,
101
+ "B-CURRENCY": 12,
102
+ "B-CURRENCYCODE": 13,
103
+ "B-CURRENCYNAME": 14,
104
+ "B-CURRENCYSYMBOL": 15,
105
+ "B-CVV": 16,
106
+ "B-DATE": 17,
107
+ "B-DATEOFBIRTH": 18,
108
+ "B-EMAIL": 19,
109
+ "B-ETHEREUMADDRESS": 20,
110
+ "B-EYECOLOR": 21,
111
+ "B-FIRSTNAME": 22,
112
+ "B-GENDER": 23,
113
+ "B-GPSCOORDINATES": 24,
114
+ "B-HEIGHT": 25,
115
+ "B-IBAN": 26,
116
+ "B-IMEI": 27,
117
+ "B-IPADDRESS": 28,
118
+ "B-JOBDEPARTMENT": 29,
119
+ "B-JOBTITLE": 30,
120
+ "B-LASTNAME": 31,
121
+ "B-LITECOINADDRESS": 32,
122
+ "B-MACADDRESS": 33,
123
+ "B-MASKEDNUMBER": 34,
124
+ "B-MIDDLENAME": 35,
125
+ "B-OCCUPATION": 36,
126
+ "B-ORDINALDIRECTION": 37,
127
+ "B-ORGANIZATION": 38,
128
+ "B-PASSWORD": 39,
129
+ "B-PHONE": 40,
130
+ "B-PIN": 41,
131
+ "B-PREFIX": 42,
132
+ "B-SECONDARYADDRESS": 43,
133
+ "B-SEX": 44,
134
+ "B-SSN": 45,
135
+ "B-STATE": 46,
136
+ "B-STREET": 47,
137
+ "B-TIME": 48,
138
+ "B-URL": 49,
139
+ "B-USERAGENT": 50,
140
+ "B-USERNAME": 51,
141
+ "B-VIN": 52,
142
+ "B-VRM": 53,
143
+ "B-ZIPCODE": 54,
144
+ "I-ACCOUNTNAME": 55,
145
+ "I-AGE": 56,
146
+ "I-AMOUNT": 57,
147
+ "I-CITY": 58,
148
+ "I-COUNTY": 59,
149
+ "I-CURRENCY": 60,
150
+ "I-CURRENCYNAME": 61,
151
+ "I-DATE": 62,
152
+ "I-DATEOFBIRTH": 63,
153
+ "I-EYECOLOR": 64,
154
+ "I-GENDER": 65,
155
+ "I-HEIGHT": 66,
156
+ "I-JOBTITLE": 67,
157
+ "I-ORGANIZATION": 68,
158
+ "I-PHONE": 69,
159
+ "I-SECONDARYADDRESS": 70,
160
+ "I-SSN": 71,
161
+ "I-STATE": 72,
162
+ "I-STREET": 73,
163
+ "I-TIME": 74,
164
+ "I-USERAGENT": 75,
165
+ "O": 0
166
+ },
167
+ "problem_type": null,
168
+ "vocab_size": 50265,
169
+ "hidden_size": 768,
170
+ "num_hidden_layers": 6,
171
+ "num_attention_heads": 12,
172
+ "intermediate_size": 3072,
173
+ "hidden_act": "gelu",
174
+ "hidden_dropout_prob": 0.1,
175
+ "attention_probs_dropout_prob": 0.1,
176
+ "max_position_embeddings": 514,
177
+ "type_vocab_size": 1,
178
+ "initializer_range": 0.02,
179
+ "layer_norm_eps": 1e-05,
180
+ "pad_token_id": 1,
181
+ "bos_token_id": 0,
182
+ "eos_token_id": 2,
183
+ "use_cache": true,
184
+ "classifier_dropout": null,
185
+ "is_decoder": false,
186
+ "add_cross_attention": false,
187
+ "tie_word_embeddings": true,
188
+ "_name_or_path": "OpenMed/OpenMed-PII-Italian-FastClinical-Small-82M-v1",
189
+ "model_type": "roberta",
190
+ "position_embedding_type": "absolute",
191
+ "output_attentions": false,
192
+ "_mlx_position_offset": 2,
193
+ "_mlx_model_type": "bert",
194
+ "num_labels": 76,
195
+ "_mlx_weights_format": "safetensors"
196
+ }
id2label.json ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "0": "O",
3
+ "1": "B-ACCOUNTNAME",
4
+ "2": "B-AGE",
5
+ "3": "B-AMOUNT",
6
+ "4": "B-BANKACCOUNT",
7
+ "5": "B-BIC",
8
+ "6": "B-BITCOINADDRESS",
9
+ "7": "B-BUILDINGNUMBER",
10
+ "8": "B-CITY",
11
+ "9": "B-COUNTY",
12
+ "10": "B-CREDITCARD",
13
+ "11": "B-CREDITCARDISSUER",
14
+ "12": "B-CURRENCY",
15
+ "13": "B-CURRENCYCODE",
16
+ "14": "B-CURRENCYNAME",
17
+ "15": "B-CURRENCYSYMBOL",
18
+ "16": "B-CVV",
19
+ "17": "B-DATE",
20
+ "18": "B-DATEOFBIRTH",
21
+ "19": "B-EMAIL",
22
+ "20": "B-ETHEREUMADDRESS",
23
+ "21": "B-EYECOLOR",
24
+ "22": "B-FIRSTNAME",
25
+ "23": "B-GENDER",
26
+ "24": "B-GPSCOORDINATES",
27
+ "25": "B-HEIGHT",
28
+ "26": "B-IBAN",
29
+ "27": "B-IMEI",
30
+ "28": "B-IPADDRESS",
31
+ "29": "B-JOBDEPARTMENT",
32
+ "30": "B-JOBTITLE",
33
+ "31": "B-LASTNAME",
34
+ "32": "B-LITECOINADDRESS",
35
+ "33": "B-MACADDRESS",
36
+ "34": "B-MASKEDNUMBER",
37
+ "35": "B-MIDDLENAME",
38
+ "36": "B-OCCUPATION",
39
+ "37": "B-ORDINALDIRECTION",
40
+ "38": "B-ORGANIZATION",
41
+ "39": "B-PASSWORD",
42
+ "40": "B-PHONE",
43
+ "41": "B-PIN",
44
+ "42": "B-PREFIX",
45
+ "43": "B-SECONDARYADDRESS",
46
+ "44": "B-SEX",
47
+ "45": "B-SSN",
48
+ "46": "B-STATE",
49
+ "47": "B-STREET",
50
+ "48": "B-TIME",
51
+ "49": "B-URL",
52
+ "50": "B-USERAGENT",
53
+ "51": "B-USERNAME",
54
+ "52": "B-VIN",
55
+ "53": "B-VRM",
56
+ "54": "B-ZIPCODE",
57
+ "55": "I-ACCOUNTNAME",
58
+ "56": "I-AGE",
59
+ "57": "I-AMOUNT",
60
+ "58": "I-CITY",
61
+ "59": "I-COUNTY",
62
+ "60": "I-CURRENCY",
63
+ "61": "I-CURRENCYNAME",
64
+ "62": "I-DATE",
65
+ "63": "I-DATEOFBIRTH",
66
+ "64": "I-EYECOLOR",
67
+ "65": "I-GENDER",
68
+ "66": "I-HEIGHT",
69
+ "67": "I-JOBTITLE",
70
+ "68": "I-ORGANIZATION",
71
+ "69": "I-PHONE",
72
+ "70": "I-SECONDARYADDRESS",
73
+ "71": "I-SSN",
74
+ "72": "I-STATE",
75
+ "73": "I-STREET",
76
+ "74": "I-TIME",
77
+ "75": "I-USERAGENT"
78
+ }
weights.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b9437a03dfdd367a9b0b3d72bb5b43a78b5d14042c7c260825f039eae8059c63
3
+ size 326355889