hanneshapke commited on
Commit
a0c9dd2
·
verified ·
1 Parent(s): 6745b44

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ model.onnx.data filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,155 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - da
4
+ - de
5
+ - en
6
+ - es
7
+ - fr
8
+ - nl
9
+ license: apache-2.0
10
+ library_name: onnx
11
+ pipeline_tag: token-classification
12
+ tags:
13
+ - pii
14
+ - privacy
15
+ - ner
16
+ - coreference-resolution
17
+ - distilbert
18
+ - multi-task
19
+ - onnx
20
+ - quantized
21
+ - int8
22
+ base_model: DataikuNLP/kiji-pii-model
23
+ ---
24
+
25
+ # Kiji PII Detection Model (ONNX Quantized)
26
+
27
+ INT8-quantized ONNX version of the Kiji PII detection model for efficient CPU inference. Detects Personally Identifiable Information (PII) in text with coreference resolution.
28
+
29
+ ## Source Model
30
+
31
+ This is a quantized version of [DataikuNLP/kiji-pii-model](https://huggingface.co/DataikuNLP/kiji-pii-model) — a multi-task DistilBERT model fine-tuned for PII detection with coreference resolution.
32
+
33
+ ## Model Summary
34
+
35
+ | | |
36
+ |---|---|
37
+ | **Format** | ONNX (INT8 quantized) |
38
+ | **Architecture** | Shared DistilBERT encoder + two classification heads |
39
+ | **Tasks** | PII token classification (53 labels) + coreference detection (7 labels) |
40
+ | **PII entity types** | 26 |
41
+ | **Max sequence length** | 512 tokens |
42
+ | **Runtime** | ONNX Runtime |
43
+
44
+ ## Files
45
+
46
+ | File | Size |
47
+ |------|------|
48
+ | `model_quantized.onnx` | 63.3 MB |
49
+ | `model.onnx.data` | 248.9 MB |
50
+ | `ort_config.json` | 0.7 KB |
51
+ | `label_mappings.json` | 2.9 KB |
52
+ | `model_manifest.json` | 1.6 KB |
53
+ | `tokenizer_config.json` | 1.3 KB |
54
+ | `tokenizer.json` | 653.2 KB |
55
+ | `vocab.txt` | 208.4 KB |
56
+ | `special_tokens_map.json` | 0.7 KB |
57
+
58
+ ## Quantization Details
59
+
60
+ | | |
61
+ |---|---|
62
+ | **Method** | Dynamic quantization (ONNX Runtime / Optimum) |
63
+ | **Weights** | QInt8 (symmetric, per-channel) |
64
+ | **Activations** | QUInt8 (asymmetric, per-tensor) |
65
+ | **Mode** | IntegerOps |
66
+ | **Format** | QOperator |
67
+ | **Operators quantized** | Conv, MatMul, Attention, LSTM, Gather, Transpose, EmbedLayerNormalization |
68
+
69
+ ## Usage
70
+
71
+ ```python
72
+ import numpy as np
73
+ from onnxruntime import InferenceSession
74
+ from transformers import AutoTokenizer
75
+
76
+ # Load tokenizer and model
77
+ tokenizer = AutoTokenizer.from_pretrained("DataikuNLP/kiji-pii-model-onnx")
78
+ session = InferenceSession("DataikuNLP/kiji-pii-model-onnx/model_quantized.onnx") # or local path
79
+
80
+ # Tokenize
81
+ text = "Contact John Smith at john.smith@example.com or call +1-555-123-4567."
82
+ inputs = tokenizer(text, return_tensors="np", truncation=True, max_length=512)
83
+
84
+ # Run inference
85
+ outputs = session.run(None, dict(inputs))
86
+ pii_logits, coref_logits = outputs # (1, seq_len, 53), (1, seq_len, 7)
87
+
88
+ # Decode PII predictions
89
+ pii_predictions = np.argmax(pii_logits, axis=-1)[0]
90
+
91
+ # See label_mappings.json for label ID -> label name mapping
92
+ ```
93
+
94
+ ## PII Labels (BIO tagging)
95
+
96
+ The model uses BIO tagging with 26 entity types:
97
+
98
+ | Label | Description |
99
+ |-------|-------------|
100
+ | `AGE` | Age |
101
+ | `BUILDINGNUM` | Building number |
102
+ | `CITY` | City |
103
+ | `COMPANYNAME` | Company name |
104
+ | `COUNTRY` | Country |
105
+ | `CREDITCARDNUMBER` | Credit Card Number |
106
+ | `DATEOFBIRTH` | Date of birth |
107
+ | `DRIVERLICENSENUM` | Driver's License Number |
108
+ | `EMAIL` | Email |
109
+ | `FIRSTNAME` | First name |
110
+ | `IBAN` | IBAN |
111
+ | `IDCARDNUM` | ID Card Number |
112
+ | `LICENSEPLATENUM` | License Plate Number |
113
+ | `NATIONALID` | National ID |
114
+ | `PASSPORTID` | Passport ID |
115
+ | `PASSWORD` | Password |
116
+ | `PHONENUMBER` | Phone number |
117
+ | `SECURITYTOKEN` | API Security Tokens |
118
+ | `SSN` | Social Security Number |
119
+ | `STATE` | State |
120
+ | `STREET` | Street |
121
+ | `SURNAME` | Last name |
122
+ | `TAXNUM` | Tax Number |
123
+ | `URL` | URL |
124
+ | `USERNAME` | Username |
125
+ | `ZIP` | Zip code |
126
+
127
+
128
+ Each entity type has `B-` (beginning) and `I-` (inside) variants, plus `O` for non-PII tokens.
129
+
130
+ ## Coreference Labels
131
+
132
+ | Label | Description |
133
+ |-------|-------------|
134
+ | `NO_COREF` | Token is not part of a coreference cluster |
135
+ | `CLUSTER_0`-`CLUSTER_3` | Token belongs to coreference cluster 0-3 |
136
+
137
+ ## Training Data
138
+
139
+ The source model was trained on the [DataikuNLP/kiji-pii-training-data](https://huggingface.co/datasets/DataikuNLP/kiji-pii-training-data) dataset — a synthetic multilingual PII dataset with entity annotations and coreference resolution.
140
+
141
+ ## Lineage
142
+
143
+ | Stage | Repository |
144
+ |-------|------------|
145
+ | Dataset | [DataikuNLP/kiji-pii-training-data](https://huggingface.co/datasets/DataikuNLP/kiji-pii-training-data) |
146
+ | Trained model | [DataikuNLP/kiji-pii-model](https://huggingface.co/DataikuNLP/kiji-pii-model) |
147
+ | **Quantized model** | **DataikuNLP/kiji-pii-model-onnx** (this repo) |
148
+
149
+ ## Limitations
150
+
151
+ - Trained on **synthetically generated** data — may not generalize to all real-world text
152
+ - Coreference head supports up to 4 clusters per sequence
153
+ - Optimized for the 6 languages in the training data (English, German, French, Spanish, Dutch, Danish)
154
+ - Max sequence length is 512 tokens
155
+ - Quantization may slightly reduce accuracy compared to the full-precision model
label_mappings.json ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "pii": {
3
+ "label2id": {
4
+ "O": 0,
5
+ "B-SURNAME": 1,
6
+ "I-SURNAME": 2,
7
+ "B-FIRSTNAME": 3,
8
+ "I-FIRSTNAME": 4,
9
+ "B-BUILDINGNUM": 5,
10
+ "I-BUILDINGNUM": 6,
11
+ "B-DATEOFBIRTH": 7,
12
+ "I-DATEOFBIRTH": 8,
13
+ "B-EMAIL": 9,
14
+ "I-EMAIL": 10,
15
+ "B-PHONENUMBER": 11,
16
+ "I-PHONENUMBER": 12,
17
+ "B-CITY": 13,
18
+ "I-CITY": 14,
19
+ "B-URL": 15,
20
+ "I-URL": 16,
21
+ "B-COMPANYNAME": 17,
22
+ "I-COMPANYNAME": 18,
23
+ "B-STATE": 19,
24
+ "I-STATE": 20,
25
+ "B-ZIP": 21,
26
+ "I-ZIP": 22,
27
+ "B-STREET": 23,
28
+ "I-STREET": 24,
29
+ "B-COUNTRY": 25,
30
+ "I-COUNTRY": 26,
31
+ "B-SSN": 27,
32
+ "I-SSN": 28,
33
+ "B-DRIVERLICENSENUM": 29,
34
+ "I-DRIVERLICENSENUM": 30,
35
+ "B-PASSPORTID": 31,
36
+ "I-PASSPORTID": 32,
37
+ "B-NATIONALID": 33,
38
+ "I-NATIONALID": 34,
39
+ "B-IDCARDNUM": 35,
40
+ "I-IDCARDNUM": 36,
41
+ "B-TAXNUM": 37,
42
+ "I-TAXNUM": 38,
43
+ "B-LICENSEPLATENUM": 39,
44
+ "I-LICENSEPLATENUM": 40,
45
+ "B-PASSWORD": 41,
46
+ "I-PASSWORD": 42,
47
+ "B-IBAN": 43,
48
+ "I-IBAN": 44,
49
+ "B-AGE": 45,
50
+ "I-AGE": 46,
51
+ "B-SECURITYTOKEN": 47,
52
+ "I-SECURITYTOKEN": 48,
53
+ "B-CREDITCARDNUMBER": 49,
54
+ "I-CREDITCARDNUMBER": 50,
55
+ "B-USERNAME": 51,
56
+ "I-USERNAME": 52
57
+ },
58
+ "id2label": {
59
+ "0": "O",
60
+ "1": "B-SURNAME",
61
+ "2": "I-SURNAME",
62
+ "3": "B-FIRSTNAME",
63
+ "4": "I-FIRSTNAME",
64
+ "5": "B-BUILDINGNUM",
65
+ "6": "I-BUILDINGNUM",
66
+ "7": "B-DATEOFBIRTH",
67
+ "8": "I-DATEOFBIRTH",
68
+ "9": "B-EMAIL",
69
+ "10": "I-EMAIL",
70
+ "11": "B-PHONENUMBER",
71
+ "12": "I-PHONENUMBER",
72
+ "13": "B-CITY",
73
+ "14": "I-CITY",
74
+ "15": "B-URL",
75
+ "16": "I-URL",
76
+ "17": "B-COMPANYNAME",
77
+ "18": "I-COMPANYNAME",
78
+ "19": "B-STATE",
79
+ "20": "I-STATE",
80
+ "21": "B-ZIP",
81
+ "22": "I-ZIP",
82
+ "23": "B-STREET",
83
+ "24": "I-STREET",
84
+ "25": "B-COUNTRY",
85
+ "26": "I-COUNTRY",
86
+ "27": "B-SSN",
87
+ "28": "I-SSN",
88
+ "29": "B-DRIVERLICENSENUM",
89
+ "30": "I-DRIVERLICENSENUM",
90
+ "31": "B-PASSPORTID",
91
+ "32": "I-PASSPORTID",
92
+ "33": "B-NATIONALID",
93
+ "34": "I-NATIONALID",
94
+ "35": "B-IDCARDNUM",
95
+ "36": "I-IDCARDNUM",
96
+ "37": "B-TAXNUM",
97
+ "38": "I-TAXNUM",
98
+ "39": "B-LICENSEPLATENUM",
99
+ "40": "I-LICENSEPLATENUM",
100
+ "41": "B-PASSWORD",
101
+ "42": "I-PASSWORD",
102
+ "43": "B-IBAN",
103
+ "44": "I-IBAN",
104
+ "45": "B-AGE",
105
+ "46": "I-AGE",
106
+ "47": "B-SECURITYTOKEN",
107
+ "48": "I-SECURITYTOKEN",
108
+ "49": "B-CREDITCARDNUMBER",
109
+ "50": "I-CREDITCARDNUMBER",
110
+ "51": "B-USERNAME",
111
+ "52": "I-USERNAME",
112
+ "-100": "IGNORE"
113
+ }
114
+ },
115
+ "coref": {
116
+ "id2label": {
117
+ "0": "NO_COREF",
118
+ "1": "CLUSTER_0",
119
+ "2": "CLUSTER_1",
120
+ "3": "CLUSTER_2",
121
+ "4": "CLUSTER_3",
122
+ "5": "CLUSTER_4",
123
+ "6": "CLUSTER_5"
124
+ }
125
+ }
126
+ }
model.onnx.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d93759243fb646966fc12b3e1a2cacedaf0326a94e014194faafdb683a50d98b
3
+ size 260976640
model_manifest.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_path": "model/quantized",
3
+ "hashes": {
4
+ "sha256": "8e84ca14b7d7b344e0e9ca338ba1834ba09ff70e0d0342bafd398293aabb6ddd",
5
+ "sha512": "ef56b044de853c69f394c47f15b495cecd81114fdc52d5e4d04f1d83f20d1decc59fd688fe3a72fe88cabd90b2bed710d81e2481e73e20e86392ee33fb7fe8cb"
6
+ },
7
+ "files": [
8
+ {
9
+ "path": "label_mappings.json",
10
+ "sha256": "67c7dc80b62c1f0f83a6a77f9e1990572d5bfbfb0ae7673daad471f845b70ae5"
11
+ },
12
+ {
13
+ "path": "model.onnx",
14
+ "sha256": "aaf9ff3319b5c3d4cc4cc2ae3e6e1acaca6ff91924dc0abb823ca5655b751432"
15
+ },
16
+ {
17
+ "path": "model.onnx.data",
18
+ "sha256": "9a8c787f32551a3e5fafff4ddc32d3048edf7c23435e0030995dde2934c1b9b0"
19
+ },
20
+ {
21
+ "path": "model_manifest.json",
22
+ "sha256": "2539a2b206ebbacb3b5bc42b22dd00fd528c3a8505bfdd06afbd935e54f5ec97"
23
+ },
24
+ {
25
+ "path": "model_quantized.onnx",
26
+ "sha256": "61df2fc432ffbc9c96bb953dbcba4ccb399fb2e326994ca40a5e0d268428c003"
27
+ },
28
+ {
29
+ "path": "ort_config.json",
30
+ "sha256": "713d4cdeb867f45c821d5f2bc226ed33ac3afcce49a83b1b95dc7b45aca116f9"
31
+ },
32
+ {
33
+ "path": "special_tokens_map.json",
34
+ "sha256": "5d5b662e421ea9fac075174bb0688ee0d9431699900b90662acd44b2a350503a"
35
+ },
36
+ {
37
+ "path": "tokenizer.json",
38
+ "sha256": "cb26b43c98e8266ae3e99c2a583cf8315d73b33a17e6b20b4df7ff1f22392d34"
39
+ },
40
+ {
41
+ "path": "tokenizer_config.json",
42
+ "sha256": "91955163d30880d1ef0928cfdd729baaf413401dc4456f3ab1a48b3eec2ec624"
43
+ },
44
+ {
45
+ "path": "vocab.txt",
46
+ "sha256": "eeaa9875b23b04b4c54ef759d03db9d1ba1554838f8fb26c5d96fa551df93d02"
47
+ }
48
+ ]
49
+ }
model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b5f3311391a74470ff26c5b700a422832e5dcdb74fedc205ad5a68e70dbf487c
3
+ size 66338684
ort_config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "one_external_file": true,
3
+ "opset": null,
4
+ "optimization": {},
5
+ "quantization": {
6
+ "activations_dtype": "QUInt8",
7
+ "activations_symmetric": false,
8
+ "format": "QOperator",
9
+ "is_static": false,
10
+ "mode": "IntegerOps",
11
+ "nodes_to_exclude": [],
12
+ "nodes_to_quantize": [],
13
+ "operators_to_quantize": [
14
+ "Conv",
15
+ "MatMul",
16
+ "Attention",
17
+ "LSTM",
18
+ "Gather",
19
+ "Transpose",
20
+ "EmbedLayerNormalization"
21
+ ],
22
+ "per_channel": true,
23
+ "qdq_add_pair_to_weight": false,
24
+ "qdq_dedicated_pair": false,
25
+ "qdq_op_type_per_channel_support_to_axis": {
26
+ "MatMul": 1
27
+ },
28
+ "reduce_range": false,
29
+ "weights_dtype": "QInt8",
30
+ "weights_symmetric": true
31
+ },
32
+ "use_external_data_format": false
33
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "mask_token": {
10
+ "content": "[MASK]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "[PAD]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "sep_token": {
24
+ "content": "[SEP]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "unk_token": {
31
+ "content": "[UNK]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ }
37
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": false,
45
+ "cls_token": "[CLS]",
46
+ "do_lower_case": false,
47
+ "extra_special_tokens": {},
48
+ "mask_token": "[MASK]",
49
+ "max_length": 512,
50
+ "model_max_length": 512,
51
+ "pad_token": "[PAD]",
52
+ "sep_token": "[SEP]",
53
+ "stride": 0,
54
+ "strip_accents": null,
55
+ "tokenize_chinese_chars": true,
56
+ "tokenizer_class": "DistilBertTokenizer",
57
+ "truncation_side": "right",
58
+ "truncation_strategy": "longest_first",
59
+ "unk_token": "[UNK]"
60
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff