thomasbeste commited on
Commit
9882e67
·
verified ·
1 Parent(s): d2e80a4

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - da
4
+ license: apache-2.0
5
+ tags:
6
+ - token-classification
7
+ - ner
8
+ - danish
9
+ - modernbert
10
+ - onnx
11
+ - quantized
12
+ - int8
13
+ datasets:
14
+ - alexandrainst/dane
15
+ metrics:
16
+ - f1
17
+ - precision
18
+ - recall
19
+ pipeline_tag: token-classification
20
+ ---
21
+
22
+ # ModernBERT Danish NER (Base) — ONNX INT8
23
+
24
+ ONNX INT8 dynamically quantized version of [`thomasbeste/modernbert-da-ner-base`](https://huggingface.co/thomasbeste/modernbert-da-ner-base).
25
+
26
+ Quantized with AVX-512 VNNI configuration for fast CPU inference.
27
+
28
+ ## Benchmark: DaNE Test Set
29
+
30
+ | Entity | Precision | Recall | F1 | Support |
31
+ |--------|-----------|--------|----|---------|
32
+ | PER | 0.8962 | 0.9061 | 0.9011 | 181 |
33
+ | ORG | 0.6929 | 0.6299 | 0.6599 | 154 |
34
+ | LOC | 0.7500 | 0.8969 | 0.8169 | 97 |
35
+ | MISC | 0.4878 | 0.6316 | 0.5505 | 95 |
36
+ | **micro avg** | **0.7260** | **0.7742** | **0.7493** | |
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+ from optimum.onnxruntime import ORTModelForTokenClassification
42
+ from transformers import AutoTokenizer, pipeline
43
+
44
+ model = ORTModelForTokenClassification.from_pretrained("thomasbeste/modernbert-da-ner-base-onnx-int8")
45
+ tokenizer = AutoTokenizer.from_pretrained("thomasbeste/modernbert-da-ner-base-onnx-int8")
46
+ ner = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy="simple")
47
+
48
+ results = ner("Jens Peter Hansen bor i København og arbejder hos Novo Nordisk.")
49
+ for entity in results:
50
+ print(f"{entity['word']}: {entity['entity_group']} ({entity['score']:.3f})")
51
+ ```
52
+
53
+ ## Training Details
54
+
55
+ See the PyTorch model card: [thomasbeste/modernbert-da-ner-base](https://huggingface.co/thomasbeste/modernbert-da-ner-base)
config.json ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ModernBertForTokenClassification"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": null,
8
+ "classifier_activation": "silu",
9
+ "classifier_bias": false,
10
+ "classifier_dropout": 0.0,
11
+ "classifier_pooling": "mean",
12
+ "cls_token_id": 50281,
13
+ "decoder_bias": true,
14
+ "deterministic_flash_attn": false,
15
+ "dtype": "float32",
16
+ "embedding_dropout": 0.0,
17
+ "eos_token_id": null,
18
+ "global_attn_every_n_layers": 3,
19
+ "global_rope_theta": 160000.0,
20
+ "gradient_checkpointing": false,
21
+ "hidden_activation": "gelu",
22
+ "hidden_size": 768,
23
+ "id2label": {
24
+ "0": "O",
25
+ "1": "B-PER",
26
+ "2": "I-PER",
27
+ "3": "B-ORG",
28
+ "4": "I-ORG",
29
+ "5": "B-LOC",
30
+ "6": "I-LOC",
31
+ "7": "B-MISC",
32
+ "8": "I-MISC"
33
+ },
34
+ "initializer_cutoff_factor": 2.0,
35
+ "initializer_range": 0.02,
36
+ "intermediate_size": 1152,
37
+ "label2id": {
38
+ "B-LOC": 5,
39
+ "B-MISC": 7,
40
+ "B-ORG": 3,
41
+ "B-PER": 1,
42
+ "I-LOC": 6,
43
+ "I-MISC": 8,
44
+ "I-ORG": 4,
45
+ "I-PER": 2,
46
+ "O": 0
47
+ },
48
+ "layer_norm_eps": 1e-05,
49
+ "local_attention": 128,
50
+ "local_rope_theta": 10000.0,
51
+ "max_position_embeddings": 8192,
52
+ "mlp_bias": false,
53
+ "mlp_dropout": 0.0,
54
+ "model_type": "modernbert",
55
+ "norm_bias": false,
56
+ "norm_eps": 1e-05,
57
+ "num_attention_heads": 12,
58
+ "num_hidden_layers": 22,
59
+ "pad_token_id": 5,
60
+ "position_embedding_type": "absolute",
61
+ "repad_logits_with_grad": false,
62
+ "sep_token_id": 50282,
63
+ "sparse_pred_ignore_index": -100,
64
+ "sparse_prediction": false,
65
+ "transformers_version": "4.57.6",
66
+ "vocab_size": 50368
67
+ }
model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a7a87d7a31516bdfc5ace6c548f3901d5e004e3ca6120d6de86b8fbfaa60c4f4
3
+ size 151335792
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,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|padding|>",
4
+ "<|endoftext|>"
5
+ ],
6
+ "cls_token": {
7
+ "content": "[CLS]",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false
12
+ },
13
+ "mask_token": {
14
+ "content": "[MASK]",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false
19
+ },
20
+ "pad_token": {
21
+ "content": "[PAD]",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false
26
+ },
27
+ "sep_token": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false
33
+ },
34
+ "unk_token": {
35
+ "content": "[UNK]",
36
+ "lstrip": false,
37
+ "normalized": false,
38
+ "rstrip": false,
39
+ "single_word": false
40
+ }
41
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<|padding|>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<|endoftext|>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[UNK]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[CLS]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "4": {
36
+ "content": "[SEP]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ },
43
+ "5": {
44
+ "content": "[PAD]",
45
+ "lstrip": false,
46
+ "normalized": false,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": true
50
+ },
51
+ "6": {
52
+ "content": "[MASK]",
53
+ "lstrip": false,
54
+ "normalized": false,
55
+ "rstrip": false,
56
+ "single_word": false,
57
+ "special": true
58
+ }
59
+ },
60
+ "additional_special_tokens": [
61
+ "<|padding|>",
62
+ "<|endoftext|>"
63
+ ],
64
+ "clean_up_tokenization_spaces": false,
65
+ "cls_token": "[CLS]",
66
+ "extra_special_tokens": {},
67
+ "mask_token": "[MASK]",
68
+ "max_length": 256,
69
+ "model_max_length": 8192,
70
+ "pad_token": "[PAD]",
71
+ "sep_token": "[SEP]",
72
+ "stride": 0,
73
+ "tokenizer_class": "PreTrainedTokenizerFast",
74
+ "truncation_side": "right",
75
+ "truncation_strategy": "longest_first",
76
+ "unk_token": "[UNK]"
77
+ }