broadfield-dev commited on
Commit
626fa62
·
verified ·
1 Parent(s): 02a401e

Upload folder using huggingface_hub

Browse files
Files changed (7) hide show
  1. README.md +63 -0
  2. config.json +64 -0
  3. model.onnx +3 -0
  4. special_tokens_map.json +37 -0
  5. tokenizer.json +0 -0
  6. tokenizer_config.json +63 -0
  7. vocab.txt +0 -0
README.md ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: broadfield-dev/bert-mini-ner-pii-training-tuned-12270113
3
+ library_name: transformers
4
+ tags:
5
+ - onnx
6
+ - onnxruntime
7
+ - tokenizers
8
+ - optimum
9
+ - token-classification
10
+ language: en
11
+ pipeline_tag: token-classification
12
+ ---
13
+
14
+ # ONNX Export: broadfield-dev/bert-mini-ner-pii-training-tuned-12270113
15
+
16
+ This is a version of [broadfield-dev/bert-mini-ner-pii-training-tuned-12270113](https://huggingface.co/broadfield-dev/bert-mini-ner-pii-training-tuned-12270113) that has been converted to ONNX and optimized.
17
+
18
+ ## Model Details
19
+ - **Base Model:** `broadfield-dev/bert-mini-ner-pii-training-tuned-12270113`
20
+ - **Task:** `token-classification`
21
+ - **Opset Version:** `17`
22
+ - **Optimization:** `FP32 (No Quantization)`
23
+
24
+ ## Usage
25
+
26
+ ### Installation
27
+ For a lightweight mobile/serverless setup, you only need `onnxruntime` and `tokenizers`.
28
+ ```bash
29
+ pip install onnxruntime tokenizers
30
+ ```
31
+
32
+ ### Python Example
33
+ ```python
34
+
35
+ from tokenizers import Tokenizer
36
+ import onnxruntime as ort
37
+ import numpy as np
38
+
39
+ # 1. Load the lightweight tokenizer (No Transformers dependency needed)
40
+ tokenizer = Tokenizer.from_pretrained("broadfield-dev/bert-mini-ner-pii-training-tuned-12270113-onnx")
41
+
42
+ # 2. Load the ONNX model
43
+ session = ort.InferenceSession("model.onnx")
44
+
45
+ # 3. Preprocess (Simple text encoding)
46
+ text = "Run inference on mobile!"
47
+ encoding = tokenizer.encode(text)
48
+
49
+ # Prepare inputs (Exact names vary by model, usually input_ids + attention_mask)
50
+ inputs = {
51
+ "input_ids": np.array([encoding.ids], dtype=np.int64),
52
+ "attention_mask": np.array([encoding.attention_mask], dtype=np.int64)
53
+ }
54
+
55
+ # 4. Run Inference
56
+ outputs = session.run(None, inputs)
57
+ print("Output logits shape:", outputs[0].shape)
58
+
59
+ ```
60
+
61
+ ## About this Export
62
+ This model was exported using [Optimum](https://huggingface.co/docs/optimum/index).
63
+ It includes the `FP32 (No Quantization)` quantization settings and a pre-compiled `tokenizer.json` for fast loading.
config.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForTokenClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "dtype": "float32",
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 256,
11
+ "id2label": {
12
+ "0": "ACCOUNTNUM",
13
+ "1": "BUILDINGNUM",
14
+ "2": "CITY",
15
+ "3": "CREDITCARDNUMBER",
16
+ "4": "DATEOFBIRTH",
17
+ "5": "DRIVERLICENSENUM",
18
+ "6": "EMAIL",
19
+ "7": "GIVENNAME",
20
+ "8": "IDCARDNUM",
21
+ "9": "O",
22
+ "10": "PASSWORD",
23
+ "11": "SOCIALNUM",
24
+ "12": "STREET",
25
+ "13": "SURNAME",
26
+ "14": "TAXNUM",
27
+ "15": "TELEPHONENUM",
28
+ "16": "USERNAME",
29
+ "17": "ZIPCODE"
30
+ },
31
+ "initializer_range": 0.02,
32
+ "intermediate_size": 1024,
33
+ "label2id": {
34
+ "ACCOUNTNUM": 0,
35
+ "BUILDINGNUM": 1,
36
+ "CITY": 2,
37
+ "CREDITCARDNUMBER": 3,
38
+ "DATEOFBIRTH": 4,
39
+ "DRIVERLICENSENUM": 5,
40
+ "EMAIL": 6,
41
+ "GIVENNAME": 7,
42
+ "IDCARDNUM": 8,
43
+ "O": 9,
44
+ "PASSWORD": 10,
45
+ "SOCIALNUM": 11,
46
+ "STREET": 12,
47
+ "SURNAME": 13,
48
+ "TAXNUM": 14,
49
+ "TELEPHONENUM": 15,
50
+ "USERNAME": 16,
51
+ "ZIPCODE": 17
52
+ },
53
+ "layer_norm_eps": 1e-12,
54
+ "max_position_embeddings": 512,
55
+ "model_type": "bert",
56
+ "num_attention_heads": 4,
57
+ "num_hidden_layers": 4,
58
+ "pad_token_id": 0,
59
+ "position_embedding_type": "absolute",
60
+ "transformers_version": "4.57.3",
61
+ "type_vocab_size": 2,
62
+ "use_cache": true,
63
+ "vocab_size": 30522
64
+ }
model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20f0b502555bd277bf4ef2c35ec7c15bba547d49d6a938e569662890d36e742b
3
+ size 44514088
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,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": true,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "[PAD]",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "100": {
13
+ "content": "[UNK]",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "101": {
21
+ "content": "[CLS]",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "102": {
29
+ "content": "[SEP]",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "103": {
37
+ "content": "[MASK]",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ }
44
+ },
45
+ "clean_up_tokenization_spaces": true,
46
+ "cls_token": "[CLS]",
47
+ "do_basic_tokenize": true,
48
+ "do_lower_case": true,
49
+ "extra_special_tokens": {},
50
+ "mask_token": "[MASK]",
51
+ "max_length": 512,
52
+ "model_max_length": 1000000000000000019884624838656,
53
+ "never_split": null,
54
+ "pad_token": "[PAD]",
55
+ "sep_token": "[SEP]",
56
+ "stride": 0,
57
+ "strip_accents": null,
58
+ "tokenize_chinese_chars": true,
59
+ "tokenizer_class": "BertTokenizer",
60
+ "truncation_side": "right",
61
+ "truncation_strategy": "longest_first",
62
+ "unk_token": "[UNK]"
63
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff