MaziyarPanahi commited on
Commit
58c00a5
·
verified ·
1 Parent(s): 2b7699a

Upload MLX packaging for OpenMed-PII-SuperMedical-Base-125M-v1-mlx

Browse files
Files changed (4) hide show
  1. README.md +105 -0
  2. config.json +256 -0
  3. id2label.json +108 -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-SuperMedical-Base-125M-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-SuperMedical-Base-125M-v1 for OpenMed MLX
18
+
19
+ This repository contains a **private MLX packaging** of [`OpenMed/OpenMed-PII-SuperMedical-Base-125M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-SuperMedical-Base-125M-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-SuperMedical-Base-125M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-SuperMedical-Base-125M-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-SuperMedical-Base-125M-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-SuperMedical-Base-125M-v1-mlx`](https://huggingface.co/OpenMed/OpenMed-PII-SuperMedical-Base-125M-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-SuperMedical-Base-125M-v1`](https://huggingface.co/OpenMed/OpenMed-PII-SuperMedical-Base-125M-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,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-account_number",
14
+ "2": "B-age",
15
+ "3": "B-api_key",
16
+ "4": "B-bank_routing_number",
17
+ "5": "B-biometric_identifier",
18
+ "6": "B-blood_type",
19
+ "7": "B-certificate_license_number",
20
+ "8": "B-city",
21
+ "9": "B-company_name",
22
+ "10": "B-coordinate",
23
+ "11": "B-country",
24
+ "12": "B-county",
25
+ "13": "B-credit_debit_card",
26
+ "14": "B-customer_id",
27
+ "15": "B-cvv",
28
+ "16": "B-date",
29
+ "17": "B-date_of_birth",
30
+ "18": "B-date_time",
31
+ "19": "B-device_identifier",
32
+ "20": "B-education_level",
33
+ "21": "B-email",
34
+ "22": "B-employee_id",
35
+ "23": "B-employment_status",
36
+ "24": "B-fax_number",
37
+ "25": "B-first_name",
38
+ "26": "B-gender",
39
+ "27": "B-health_plan_beneficiary_number",
40
+ "28": "B-http_cookie",
41
+ "29": "B-ipv4",
42
+ "30": "B-ipv6",
43
+ "31": "B-language",
44
+ "32": "B-last_name",
45
+ "33": "B-license_plate",
46
+ "34": "B-mac_address",
47
+ "35": "B-medical_record_number",
48
+ "36": "B-occupation",
49
+ "37": "B-password",
50
+ "38": "B-phone_number",
51
+ "39": "B-pin",
52
+ "40": "B-political_view",
53
+ "41": "B-postcode",
54
+ "42": "B-race_ethnicity",
55
+ "43": "B-religious_belief",
56
+ "44": "B-sexuality",
57
+ "45": "B-ssn",
58
+ "46": "B-state",
59
+ "47": "B-street_address",
60
+ "48": "B-swift_bic",
61
+ "49": "B-tax_id",
62
+ "50": "B-time",
63
+ "51": "B-unique_id",
64
+ "52": "B-url",
65
+ "53": "B-user_name",
66
+ "54": "B-vehicle_identifier",
67
+ "55": "I-account_number",
68
+ "56": "I-api_key",
69
+ "57": "I-biometric_identifier",
70
+ "58": "I-blood_type",
71
+ "59": "I-certificate_license_number",
72
+ "60": "I-city",
73
+ "61": "I-company_name",
74
+ "62": "I-coordinate",
75
+ "63": "I-country",
76
+ "64": "I-county",
77
+ "65": "I-credit_debit_card",
78
+ "66": "I-customer_id",
79
+ "67": "I-date",
80
+ "68": "I-date_of_birth",
81
+ "69": "I-date_time",
82
+ "70": "I-device_identifier",
83
+ "71": "I-education_level",
84
+ "72": "I-email",
85
+ "73": "I-employee_id",
86
+ "74": "I-employment_status",
87
+ "75": "I-fax_number",
88
+ "76": "I-first_name",
89
+ "77": "I-gender",
90
+ "78": "I-health_plan_beneficiary_number",
91
+ "79": "I-http_cookie",
92
+ "80": "I-ipv4",
93
+ "81": "I-ipv6",
94
+ "82": "I-language",
95
+ "83": "I-last_name",
96
+ "84": "I-license_plate",
97
+ "85": "I-mac_address",
98
+ "86": "I-medical_record_number",
99
+ "87": "I-occupation",
100
+ "88": "I-password",
101
+ "89": "I-phone_number",
102
+ "90": "I-pin",
103
+ "91": "I-political_view",
104
+ "92": "I-postcode",
105
+ "93": "I-race_ethnicity",
106
+ "94": "I-religious_belief",
107
+ "95": "I-sexuality",
108
+ "96": "I-ssn",
109
+ "97": "I-state",
110
+ "98": "I-street_address",
111
+ "99": "I-swift_bic",
112
+ "100": "I-tax_id",
113
+ "101": "I-time",
114
+ "102": "I-unique_id",
115
+ "103": "I-url",
116
+ "104": "I-user_name",
117
+ "105": "I-vehicle_identifier"
118
+ },
119
+ "label2id": {
120
+ "B-account_number": 1,
121
+ "B-age": 2,
122
+ "B-api_key": 3,
123
+ "B-bank_routing_number": 4,
124
+ "B-biometric_identifier": 5,
125
+ "B-blood_type": 6,
126
+ "B-certificate_license_number": 7,
127
+ "B-city": 8,
128
+ "B-company_name": 9,
129
+ "B-coordinate": 10,
130
+ "B-country": 11,
131
+ "B-county": 12,
132
+ "B-credit_debit_card": 13,
133
+ "B-customer_id": 14,
134
+ "B-cvv": 15,
135
+ "B-date": 16,
136
+ "B-date_of_birth": 17,
137
+ "B-date_time": 18,
138
+ "B-device_identifier": 19,
139
+ "B-education_level": 20,
140
+ "B-email": 21,
141
+ "B-employee_id": 22,
142
+ "B-employment_status": 23,
143
+ "B-fax_number": 24,
144
+ "B-first_name": 25,
145
+ "B-gender": 26,
146
+ "B-health_plan_beneficiary_number": 27,
147
+ "B-http_cookie": 28,
148
+ "B-ipv4": 29,
149
+ "B-ipv6": 30,
150
+ "B-language": 31,
151
+ "B-last_name": 32,
152
+ "B-license_plate": 33,
153
+ "B-mac_address": 34,
154
+ "B-medical_record_number": 35,
155
+ "B-occupation": 36,
156
+ "B-password": 37,
157
+ "B-phone_number": 38,
158
+ "B-pin": 39,
159
+ "B-political_view": 40,
160
+ "B-postcode": 41,
161
+ "B-race_ethnicity": 42,
162
+ "B-religious_belief": 43,
163
+ "B-sexuality": 44,
164
+ "B-ssn": 45,
165
+ "B-state": 46,
166
+ "B-street_address": 47,
167
+ "B-swift_bic": 48,
168
+ "B-tax_id": 49,
169
+ "B-time": 50,
170
+ "B-unique_id": 51,
171
+ "B-url": 52,
172
+ "B-user_name": 53,
173
+ "B-vehicle_identifier": 54,
174
+ "I-account_number": 55,
175
+ "I-api_key": 56,
176
+ "I-biometric_identifier": 57,
177
+ "I-blood_type": 58,
178
+ "I-certificate_license_number": 59,
179
+ "I-city": 60,
180
+ "I-company_name": 61,
181
+ "I-coordinate": 62,
182
+ "I-country": 63,
183
+ "I-county": 64,
184
+ "I-credit_debit_card": 65,
185
+ "I-customer_id": 66,
186
+ "I-date": 67,
187
+ "I-date_of_birth": 68,
188
+ "I-date_time": 69,
189
+ "I-device_identifier": 70,
190
+ "I-education_level": 71,
191
+ "I-email": 72,
192
+ "I-employee_id": 73,
193
+ "I-employment_status": 74,
194
+ "I-fax_number": 75,
195
+ "I-first_name": 76,
196
+ "I-gender": 77,
197
+ "I-health_plan_beneficiary_number": 78,
198
+ "I-http_cookie": 79,
199
+ "I-ipv4": 80,
200
+ "I-ipv6": 81,
201
+ "I-language": 82,
202
+ "I-last_name": 83,
203
+ "I-license_plate": 84,
204
+ "I-mac_address": 85,
205
+ "I-medical_record_number": 86,
206
+ "I-occupation": 87,
207
+ "I-password": 88,
208
+ "I-phone_number": 89,
209
+ "I-pin": 90,
210
+ "I-political_view": 91,
211
+ "I-postcode": 92,
212
+ "I-race_ethnicity": 93,
213
+ "I-religious_belief": 94,
214
+ "I-sexuality": 95,
215
+ "I-ssn": 96,
216
+ "I-state": 97,
217
+ "I-street_address": 98,
218
+ "I-swift_bic": 99,
219
+ "I-tax_id": 100,
220
+ "I-time": 101,
221
+ "I-unique_id": 102,
222
+ "I-url": 103,
223
+ "I-user_name": 104,
224
+ "I-vehicle_identifier": 105,
225
+ "O": 0
226
+ },
227
+ "problem_type": null,
228
+ "vocab_size": 50265,
229
+ "hidden_size": 768,
230
+ "num_hidden_layers": 12,
231
+ "num_attention_heads": 12,
232
+ "intermediate_size": 3072,
233
+ "hidden_act": "gelu",
234
+ "hidden_dropout_prob": 0.1,
235
+ "attention_probs_dropout_prob": 0.1,
236
+ "max_position_embeddings": 514,
237
+ "type_vocab_size": 1,
238
+ "initializer_range": 0.02,
239
+ "layer_norm_eps": 1e-05,
240
+ "pad_token_id": 1,
241
+ "bos_token_id": 0,
242
+ "eos_token_id": 2,
243
+ "use_cache": true,
244
+ "classifier_dropout": null,
245
+ "is_decoder": false,
246
+ "add_cross_attention": false,
247
+ "tie_word_embeddings": true,
248
+ "_name_or_path": "OpenMed/OpenMed-PII-SuperMedical-Base-125M-v1",
249
+ "model_type": "roberta",
250
+ "position_embedding_type": "absolute",
251
+ "output_attentions": false,
252
+ "_mlx_position_offset": 2,
253
+ "_mlx_model_type": "bert",
254
+ "num_labels": 106,
255
+ "_mlx_weights_format": "safetensors"
256
+ }
id2label.json ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "0": "O",
3
+ "1": "B-account_number",
4
+ "2": "B-age",
5
+ "3": "B-api_key",
6
+ "4": "B-bank_routing_number",
7
+ "5": "B-biometric_identifier",
8
+ "6": "B-blood_type",
9
+ "7": "B-certificate_license_number",
10
+ "8": "B-city",
11
+ "9": "B-company_name",
12
+ "10": "B-coordinate",
13
+ "11": "B-country",
14
+ "12": "B-county",
15
+ "13": "B-credit_debit_card",
16
+ "14": "B-customer_id",
17
+ "15": "B-cvv",
18
+ "16": "B-date",
19
+ "17": "B-date_of_birth",
20
+ "18": "B-date_time",
21
+ "19": "B-device_identifier",
22
+ "20": "B-education_level",
23
+ "21": "B-email",
24
+ "22": "B-employee_id",
25
+ "23": "B-employment_status",
26
+ "24": "B-fax_number",
27
+ "25": "B-first_name",
28
+ "26": "B-gender",
29
+ "27": "B-health_plan_beneficiary_number",
30
+ "28": "B-http_cookie",
31
+ "29": "B-ipv4",
32
+ "30": "B-ipv6",
33
+ "31": "B-language",
34
+ "32": "B-last_name",
35
+ "33": "B-license_plate",
36
+ "34": "B-mac_address",
37
+ "35": "B-medical_record_number",
38
+ "36": "B-occupation",
39
+ "37": "B-password",
40
+ "38": "B-phone_number",
41
+ "39": "B-pin",
42
+ "40": "B-political_view",
43
+ "41": "B-postcode",
44
+ "42": "B-race_ethnicity",
45
+ "43": "B-religious_belief",
46
+ "44": "B-sexuality",
47
+ "45": "B-ssn",
48
+ "46": "B-state",
49
+ "47": "B-street_address",
50
+ "48": "B-swift_bic",
51
+ "49": "B-tax_id",
52
+ "50": "B-time",
53
+ "51": "B-unique_id",
54
+ "52": "B-url",
55
+ "53": "B-user_name",
56
+ "54": "B-vehicle_identifier",
57
+ "55": "I-account_number",
58
+ "56": "I-api_key",
59
+ "57": "I-biometric_identifier",
60
+ "58": "I-blood_type",
61
+ "59": "I-certificate_license_number",
62
+ "60": "I-city",
63
+ "61": "I-company_name",
64
+ "62": "I-coordinate",
65
+ "63": "I-country",
66
+ "64": "I-county",
67
+ "65": "I-credit_debit_card",
68
+ "66": "I-customer_id",
69
+ "67": "I-date",
70
+ "68": "I-date_of_birth",
71
+ "69": "I-date_time",
72
+ "70": "I-device_identifier",
73
+ "71": "I-education_level",
74
+ "72": "I-email",
75
+ "73": "I-employee_id",
76
+ "74": "I-employment_status",
77
+ "75": "I-fax_number",
78
+ "76": "I-first_name",
79
+ "77": "I-gender",
80
+ "78": "I-health_plan_beneficiary_number",
81
+ "79": "I-http_cookie",
82
+ "80": "I-ipv4",
83
+ "81": "I-ipv6",
84
+ "82": "I-language",
85
+ "83": "I-last_name",
86
+ "84": "I-license_plate",
87
+ "85": "I-mac_address",
88
+ "86": "I-medical_record_number",
89
+ "87": "I-occupation",
90
+ "88": "I-password",
91
+ "89": "I-phone_number",
92
+ "90": "I-pin",
93
+ "91": "I-political_view",
94
+ "92": "I-postcode",
95
+ "93": "I-race_ethnicity",
96
+ "94": "I-religious_belief",
97
+ "95": "I-sexuality",
98
+ "96": "I-ssn",
99
+ "97": "I-state",
100
+ "98": "I-street_address",
101
+ "99": "I-swift_bic",
102
+ "100": "I-tax_id",
103
+ "101": "I-time",
104
+ "102": "I-unique_id",
105
+ "103": "I-url",
106
+ "104": "I-user_name",
107
+ "105": "I-vehicle_identifier"
108
+ }
weights.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40960dd37e81743d08742d8a91c996f903df43047470d622551d422320efdd8b
3
+ size 496567329