nbroad HF staff commited on
Commit
66f03ee
1 Parent(s): 77c3156

Upload model

Browse files
README.md ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: cc-by-sa-4.0
5
+ library_name: span-marker
6
+ tags:
7
+ - span-marker
8
+ - token-classification
9
+ - ner
10
+ - named-entity-recognition
11
+ - generated_from_span_marker_trainer
12
+ datasets:
13
+ - tomaarsen/ner-orgs
14
+ metrics:
15
+ - precision
16
+ - recall
17
+ - f1
18
+ widget:
19
+ - text: De Napoli played for FC Luzern in the second half of the 2005–06 Swiss Super
20
+ League campaign, scoring five times in fifteen games and helping Luzern to promotion
21
+ from the Swiss Challenge League.
22
+ - text: The issue continued to simmer while full-communion agreements with the Presbyterian
23
+ Church USA, Reformed Church in America, United Church of Christ, and Episcopal
24
+ Church (United States) were debated and adopted in 1997 and 1999.
25
+ - text: Rune Gerhardsen (born 13 June 1946) is a Norwegian politician, representing
26
+ the Norwegian Labour Party and a former sports leader at Norwegian Skating Association
27
+ representing from Aktiv SK.
28
+ - text: Konstantin Vladimirovich Pushkaryov (; born February 12, 1985) is a Kazakhstani
29
+ professional ice hockey winger who is currently playing with HK Kurbads of the
30
+ Latvian Hockey League (LAT).
31
+ - text: SCL claims that its methodology has been approved or endorsed by agencies
32
+ of the Government of the United Kingdom and the Federal government of the United
33
+ States, among others.
34
+ pipeline_tag: token-classification
35
+ base_model: microsoft/xtremedistil-l12-h384-uncased
36
+ model-index:
37
+ - name: SpanMarker with microsoft/xtremedistil-l12-h384-uncased on FewNERD, CoNLL2003,
38
+ and OntoNotes v5
39
+ results:
40
+ - task:
41
+ type: token-classification
42
+ name: Named Entity Recognition
43
+ dataset:
44
+ name: FewNERD, CoNLL2003, and OntoNotes v5
45
+ type: tomaarsen/ner-orgs
46
+ split: test
47
+ metrics:
48
+ - type: f1
49
+ value: 0.7558602090122487
50
+ name: F1
51
+ - type: precision
52
+ value: 0.7620428694430598
53
+ name: Precision
54
+ - type: recall
55
+ value: 0.749777064383806
56
+ name: Recall
57
+ ---
58
+
59
+ # SpanMarker with microsoft/xtremedistil-l12-h384-uncased on FewNERD, CoNLL2003, and OntoNotes v5
60
+
61
+ This is a [SpanMarker](https://github.com/tomaarsen/SpanMarkerNER) model trained on the [FewNERD, CoNLL2003, and OntoNotes v5](https://huggingface.co/datasets/tomaarsen/ner-orgs) dataset that can be used for Named Entity Recognition. This SpanMarker model uses [microsoft/xtremedistil-l12-h384-uncased](https://huggingface.co/microsoft/xtremedistil-l12-h384-uncased) as the underlying encoder.
62
+
63
+ ## Model Details
64
+
65
+ ### Model Description
66
+ - **Model Type:** SpanMarker
67
+ - **Encoder:** [microsoft/xtremedistil-l12-h384-uncased](https://huggingface.co/microsoft/xtremedistil-l12-h384-uncased)
68
+ - **Maximum Sequence Length:** 256 tokens
69
+ - **Maximum Entity Length:** 8 words
70
+ - **Training Dataset:** [FewNERD, CoNLL2003, and OntoNotes v5](https://huggingface.co/datasets/tomaarsen/ner-orgs)
71
+ - **Language:** en
72
+ - **License:** cc-by-sa-4.0
73
+
74
+ ### Model Sources
75
+
76
+ - **Repository:** [SpanMarker on GitHub](https://github.com/tomaarsen/SpanMarkerNER)
77
+ - **Thesis:** [SpanMarker For Named Entity Recognition](https://raw.githubusercontent.com/tomaarsen/SpanMarkerNER/main/thesis.pdf)
78
+
79
+ ### Model Labels
80
+ | Label | Examples |
81
+ |:------|:---------------------------------------------|
82
+ | ORG | "Texas Chicken", "IAEA", "Church 's Chicken" |
83
+
84
+ ## Evaluation
85
+
86
+ ### Metrics
87
+ | Label | Precision | Recall | F1 |
88
+ |:--------|:----------|:-------|:-------|
89
+ | **all** | 0.7620 | 0.7498 | 0.7559 |
90
+ | ORG | 0.7620 | 0.7498 | 0.7559 |
91
+
92
+ ## Uses
93
+
94
+ ### Direct Use for Inference
95
+
96
+ ```python
97
+ from span_marker import SpanMarkerModel
98
+
99
+ # Download from the 🤗 Hub
100
+ model = SpanMarkerModel.from_pretrained("nbroad/span-marker-xdistil-l12-h384-orgs-v3")
101
+ # Run inference
102
+ entities = model.predict("SCL claims that its methodology has been approved or endorsed by agencies of the Government of the United Kingdom and the Federal government of the United States, among others.")
103
+ ```
104
+
105
+ ### Downstream Use
106
+ You can finetune this model on your own dataset.
107
+
108
+ <details><summary>Click to expand</summary>
109
+
110
+ ```python
111
+ from span_marker import SpanMarkerModel, Trainer
112
+
113
+ # Download from the 🤗 Hub
114
+ model = SpanMarkerModel.from_pretrained("nbroad/span-marker-xdistil-l12-h384-orgs-v3")
115
+
116
+ # Specify a Dataset with "tokens" and "ner_tag" columns
117
+ dataset = load_dataset("conll2003") # For example CoNLL2003
118
+
119
+ # Initialize a Trainer using the pretrained model & dataset
120
+ trainer = Trainer(
121
+ model=model,
122
+ train_dataset=dataset["train"],
123
+ eval_dataset=dataset["validation"],
124
+ )
125
+ trainer.train()
126
+ trainer.save_model("nbroad/span-marker-xdistil-l12-h384-orgs-v3-finetuned")
127
+ ```
128
+ </details>
129
+
130
+ <!--
131
+ ### Out-of-Scope Use
132
+
133
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
134
+ -->
135
+
136
+ <!--
137
+ ## Bias, Risks and Limitations
138
+
139
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
140
+ -->
141
+
142
+ <!--
143
+ ### Recommendations
144
+
145
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
146
+ -->
147
+
148
+ ## Training Details
149
+
150
+ ### Training Set Metrics
151
+ | Training set | Min | Median | Max |
152
+ |:----------------------|:----|:--------|:----|
153
+ | Sentence length | 1 | 23.5706 | 263 |
154
+ | Entities per sentence | 0 | 0.7865 | 39 |
155
+
156
+ ### Training Hyperparameters
157
+ - learning_rate: 0.0003
158
+ - train_batch_size: 128
159
+ - eval_batch_size: 128
160
+ - seed: 42
161
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
162
+ - lr_scheduler_type: linear
163
+ - lr_scheduler_warmup_ratio: 0.05
164
+ - num_epochs: 3
165
+ - mixed_precision_training: Native AMP
166
+
167
+ ### Training Results
168
+ | Epoch | Step | Validation Loss | Validation Precision | Validation Recall | Validation F1 | Validation Accuracy |
169
+ |:------:|:----:|:---------------:|:--------------------:|:-----------------:|:-------------:|:-------------------:|
170
+ | 0.5720 | 600 | 0.0086 | 0.7150 | 0.7095 | 0.7122 | 0.9660 |
171
+ | 1.1439 | 1200 | 0.0074 | 0.7556 | 0.7253 | 0.7401 | 0.9682 |
172
+ | 1.7159 | 1800 | 0.0073 | 0.7482 | 0.7619 | 0.7550 | 0.9702 |
173
+ | 2.2879 | 2400 | 0.0072 | 0.7761 | 0.7573 | 0.7666 | 0.9713 |
174
+ | 2.8599 | 3000 | 0.0070 | 0.7691 | 0.7688 | 0.7689 | 0.9720 |
175
+
176
+ ### Framework Versions
177
+ - Python: 3.10.12
178
+ - SpanMarker: 1.5.0
179
+ - Transformers: 4.35.2
180
+ - PyTorch: 2.1.0a0+32f93b1
181
+ - Datasets: 2.15.0
182
+ - Tokenizers: 0.15.0
183
+
184
+ ## Citation
185
+
186
+ ### BibTeX
187
+ ```
188
+ @software{Aarsen_SpanMarker,
189
+ author = {Aarsen, Tom},
190
+ license = {Apache-2.0},
191
+ title = {{SpanMarker for Named Entity Recognition}},
192
+ url = {https://github.com/tomaarsen/SpanMarkerNER}
193
+ }
194
+ ```
195
+
196
+ <!--
197
+ ## Glossary
198
+
199
+ *Clearly define terms in order to be accessible across audiences.*
200
+ -->
201
+
202
+ <!--
203
+ ## Model Card Authors
204
+
205
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
206
+ -->
207
+
208
+ <!--
209
+ ## Model Card Contact
210
+
211
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
212
+ -->
added_tokens.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "<end>": 30523,
3
+ "<start>": 30522
4
+ }
config.json ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SpanMarkerModel"
4
+ ],
5
+ "encoder": {
6
+ "_name_or_path": "microsoft/xtremedistil-l12-h384-uncased",
7
+ "add_cross_attention": false,
8
+ "architectures": [
9
+ "BertModel"
10
+ ],
11
+ "attention_probs_dropout_prob": 0.1,
12
+ "bad_words_ids": null,
13
+ "begin_suppress_tokens": null,
14
+ "bos_token_id": null,
15
+ "chunk_size_feed_forward": 0,
16
+ "classifier_dropout": null,
17
+ "cross_attention_hidden_size": null,
18
+ "decoder_start_token_id": null,
19
+ "diversity_penalty": 0.0,
20
+ "do_sample": false,
21
+ "early_stopping": false,
22
+ "encoder_no_repeat_ngram_size": 0,
23
+ "eos_token_id": null,
24
+ "exponential_decay_length_penalty": null,
25
+ "finetuning_task": null,
26
+ "forced_bos_token_id": null,
27
+ "forced_eos_token_id": null,
28
+ "gradient_checkpointing": false,
29
+ "hidden_act": "gelu",
30
+ "hidden_dropout_prob": 0.1,
31
+ "hidden_size": 384,
32
+ "id2label": {
33
+ "0": "O",
34
+ "1": "B-ORG",
35
+ "2": "I-ORG"
36
+ },
37
+ "initializer_range": 0.02,
38
+ "intermediate_size": 1536,
39
+ "is_decoder": false,
40
+ "is_encoder_decoder": false,
41
+ "label2id": {
42
+ "B-ORG": 1,
43
+ "I-ORG": 2,
44
+ "O": 0
45
+ },
46
+ "layer_norm_eps": 1e-12,
47
+ "length_penalty": 1.0,
48
+ "max_length": 20,
49
+ "max_position_embeddings": 512,
50
+ "min_length": 0,
51
+ "model_type": "bert",
52
+ "no_repeat_ngram_size": 0,
53
+ "num_attention_heads": 12,
54
+ "num_beam_groups": 1,
55
+ "num_beams": 1,
56
+ "num_hidden_layers": 12,
57
+ "num_return_sequences": 1,
58
+ "output_attentions": false,
59
+ "output_hidden_states": false,
60
+ "output_scores": false,
61
+ "pad_token_id": 0,
62
+ "position_embedding_type": "absolute",
63
+ "prefix": null,
64
+ "problem_type": null,
65
+ "pruned_heads": {},
66
+ "remove_invalid_values": false,
67
+ "repetition_penalty": 1.0,
68
+ "return_dict": true,
69
+ "return_dict_in_generate": false,
70
+ "sep_token_id": null,
71
+ "suppress_tokens": null,
72
+ "task_specific_params": null,
73
+ "temperature": 1.0,
74
+ "tf_legacy_loss": false,
75
+ "tie_encoder_decoder": false,
76
+ "tie_word_embeddings": true,
77
+ "tokenizer_class": null,
78
+ "top_k": 50,
79
+ "top_p": 1.0,
80
+ "torch_dtype": null,
81
+ "torchscript": false,
82
+ "transformers_version": "4.35.2",
83
+ "type_vocab_size": 2,
84
+ "typical_p": 1.0,
85
+ "use_bfloat16": false,
86
+ "use_cache": true,
87
+ "vocab_size": 30528
88
+ },
89
+ "entity_max_length": 8,
90
+ "id2label": {
91
+ "0": "O",
92
+ "1": "ORG"
93
+ },
94
+ "id2reduced_id": {
95
+ "0": 0,
96
+ "1": 1,
97
+ "2": 1
98
+ },
99
+ "label2id": {
100
+ "O": 0,
101
+ "ORG": 1
102
+ },
103
+ "marker_max_length": 128,
104
+ "max_next_context": null,
105
+ "max_prev_context": null,
106
+ "model_max_length": 256,
107
+ "model_max_length_default": 512,
108
+ "model_type": "span-marker",
109
+ "span_marker_version": "1.5.0",
110
+ "torch_dtype": "float32",
111
+ "trained_with_document_context": false,
112
+ "transformers_version": "4.35.2",
113
+ "vocab_size": 30528
114
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:601560b79a01a6c6ca9918ac10bb2277855f017f7b052a686c0fd36855e2e022
3
+ size 133479232
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "30522": {
45
+ "content": "<start>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "30523": {
53
+ "content": "<end>",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ }
60
+ },
61
+ "clean_up_tokenization_spaces": true,
62
+ "cls_token": "[CLS]",
63
+ "do_basic_tokenize": true,
64
+ "do_lower_case": true,
65
+ "entity_max_length": 8,
66
+ "marker_max_length": 128,
67
+ "mask_token": "[MASK]",
68
+ "model_max_length": 256,
69
+ "never_split": null,
70
+ "pad_token": "[PAD]",
71
+ "sep_token": "[SEP]",
72
+ "strip_accents": null,
73
+ "tokenize_chinese_chars": true,
74
+ "tokenizer_class": "BertTokenizer",
75
+ "unk_token": "[UNK]"
76
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff