Pratik-B commited on
Commit
9d5a838
1 Parent(s): cc2f3aa

Pratik-B/span-marker-bert-base-fewnerd-coarse-super

Browse files
README.md ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: span-marker
3
+ tags:
4
+ - span-marker
5
+ - token-classification
6
+ - ner
7
+ - named-entity-recognition
8
+ - generated_from_span_marker_trainer
9
+ datasets:
10
+ - DFKI-SLT/few-nerd
11
+ metrics:
12
+ - precision
13
+ - recall
14
+ - f1
15
+ widget:
16
+ - text: The Hebrew Union College libraries in Cincinnati and Los Angeles, the Library
17
+ of Congress in Washington, D.C ., the Jewish Theological Seminary in New York
18
+ City, and the Harvard University Library (which received donations of Deinard's
19
+ texts from Lucius Nathan Littauer, housed in Widener and Houghton libraries) also
20
+ have large collections of Deinard works.
21
+ - text: Abu Abd Allah Muhammad al-Idrisi (1099–1165 or 1166), the Moroccan Muslim
22
+ geographer, cartographer, Egyptologist and traveller who lived in Sicily at the
23
+ court of King Roger II, mentioned this island, naming it جزيرة مليطمة ("jazīrat
24
+ Malīṭma", "the island of Malitma ") on page 583 of his book "Nuzhat al-mushtaq
25
+ fi ihtiraq ghal afaq", otherwise known as The Book of Roger, considered a geographic
26
+ encyclopaedia of the medieval world.
27
+ - text: The font is also used in the logo of the American rock band Greta Van Fleet,
28
+ in the logo for Netflix show "Stranger Things ", and in the album art for rapper
29
+ Logic's album "Supermarket ".
30
+ - text: Caretaker manager George Goss led them on a run in the FA Cup, defeating Liverpool
31
+ in round 4, to reach the semi-final at Stamford Bridge, where they were defeated
32
+ 2–0 by Sheffield United on 28 March 1925.
33
+ - text: In 1991, the National Science Foundation (NSF), which manages the U.S . Antarctic
34
+ Program (US AP), honoured his memory by dedicating a state-of-the-art laboratory
35
+ complex in his name, the Albert P. Crary Science and Engineering Center (CSEC)
36
+ located in McMurdo Station.
37
+ pipeline_tag: token-classification
38
+ model-index:
39
+ - name: SpanMarker
40
+ results:
41
+ - task:
42
+ type: token-classification
43
+ name: Named Entity Recognition
44
+ dataset:
45
+ name: Unknown
46
+ type: DFKI-SLT/few-nerd
47
+ split: test
48
+ metrics:
49
+ - type: f1
50
+ value: 0.7710703953712633
51
+ name: F1
52
+ - type: precision
53
+ value: 0.778881745567894
54
+ name: Precision
55
+ - type: recall
56
+ value: 0.7634141684170327
57
+ name: Recall
58
+ ---
59
+
60
+ # SpanMarker
61
+
62
+ This is a [SpanMarker](https://github.com/tomaarsen/SpanMarkerNER) model trained on the [DFKI-SLT/few-nerd](https://huggingface.co/datasets/DFKI-SLT/few-nerd) dataset that can be used for Named Entity Recognition.
63
+
64
+ ## Model Details
65
+
66
+ ### Model Description
67
+ - **Model Type:** SpanMarker
68
+ <!-- - **Encoder:** [Unknown](https://huggingface.co/unknown) -->
69
+ - **Maximum Sequence Length:** 256 tokens
70
+ - **Maximum Entity Length:** 8 words
71
+ - **Training Dataset:** [DFKI-SLT/few-nerd](https://huggingface.co/datasets/DFKI-SLT/few-nerd)
72
+ <!-- - **Language:** Unknown -->
73
+ <!-- - **License:** Unknown -->
74
+
75
+ ### Model Sources
76
+
77
+ - **Repository:** [SpanMarker on GitHub](https://github.com/tomaarsen/SpanMarkerNER)
78
+ - **Thesis:** [SpanMarker For Named Entity Recognition](https://raw.githubusercontent.com/tomaarsen/SpanMarkerNER/main/thesis.pdf)
79
+
80
+ ### Model Labels
81
+ | Label | Examples |
82
+ |:-------------|:-------------------------------------------------------------------------------|
83
+ | art | "The Seven Year Itch", "Time", "Imelda de ' Lambertazzi" |
84
+ | building | "Henry Ford Museum", "Sheremetyevo International Airport", "Boston Garden" |
85
+ | event | "French Revolution", "Iranian Constitutional Revolution", "Russian Revolution" |
86
+ | location | "Croatian", "the Republic of Croatia", "Mediterranean Basin" |
87
+ | organization | "IAEA", "Church 's Chicken", "Texas Chicken" |
88
+ | other | "Amphiphysin", "N-terminal lipid", "BAR" |
89
+ | person | "Edmund Payne", "Ellaline Terriss", "Hicks" |
90
+ | product | "100EX", "Phantom", "Corvettes - GT1 C6R" |
91
+
92
+ ## Evaluation
93
+
94
+ ### Metrics
95
+ | Label | Precision | Recall | F1 |
96
+ |:-------------|:----------|:-------|:-------|
97
+ | **all** | 0.7789 | 0.7634 | 0.7711 |
98
+ | art | 0.7610 | 0.7256 | 0.7429 |
99
+ | building | 0.6316 | 0.6857 | 0.6575 |
100
+ | event | 0.6304 | 0.5346 | 0.5786 |
101
+ | location | 0.8114 | 0.8554 | 0.8328 |
102
+ | organization | 0.7370 | 0.68 | 0.7074 |
103
+ | other | 0.7407 | 0.6085 | 0.6682 |
104
+ | person | 0.8611 | 0.9035 | 0.8818 |
105
+ | product | 0.704 | 0.5966 | 0.6459 |
106
+
107
+ ## Uses
108
+
109
+ ### Direct Use for Inference
110
+
111
+ ```python
112
+ from span_marker import SpanMarkerModel
113
+
114
+ # Download from the 🤗 Hub
115
+ model = SpanMarkerModel.from_pretrained("span_marker_model_id")
116
+ # Run inference
117
+ entities = model.predict("Caretaker manager George Goss led them on a run in the FA Cup, defeating Liverpool in round 4, to reach the semi-final at Stamford Bridge, where they were defeated 2–0 by Sheffield United on 28 March 1925.")
118
+ ```
119
+
120
+ ### Downstream Use
121
+ You can finetune this model on your own dataset.
122
+
123
+ <details><summary>Click to expand</summary>
124
+
125
+ ```python
126
+ from span_marker import SpanMarkerModel, Trainer
127
+
128
+ # Download from the 🤗 Hub
129
+ model = SpanMarkerModel.from_pretrained("span_marker_model_id")
130
+
131
+ # Specify a Dataset with "tokens" and "ner_tag" columns
132
+ dataset = load_dataset("conll2003") # For example CoNLL2003
133
+
134
+ # Initialize a Trainer using the pretrained model & dataset
135
+ trainer = Trainer(
136
+ model=model,
137
+ train_dataset=dataset["train"],
138
+ eval_dataset=dataset["validation"],
139
+ )
140
+ trainer.train()
141
+ trainer.save_model("span_marker_model_id-finetuned")
142
+ ```
143
+ </details>
144
+
145
+ <!--
146
+ ### Out-of-Scope Use
147
+
148
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
149
+ -->
150
+
151
+ <!--
152
+ ## Bias, Risks and Limitations
153
+
154
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
155
+ -->
156
+
157
+ <!--
158
+ ### Recommendations
159
+
160
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
161
+ -->
162
+
163
+ ## Training Details
164
+
165
+ ### Training Set Metrics
166
+ | Training set | Min | Median | Max |
167
+ |:----------------------|:----|:--------|:----|
168
+ | Sentence length | 1 | 24.4956 | 163 |
169
+ | Entities per sentence | 0 | 2.5439 | 35 |
170
+
171
+ ### Training Hyperparameters
172
+ - learning_rate: 5e-05
173
+ - train_batch_size: 4
174
+ - eval_batch_size: 4
175
+ - seed: 42
176
+ - gradient_accumulation_steps: 2
177
+ - total_train_batch_size: 8
178
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
179
+ - lr_scheduler_type: linear
180
+ - lr_scheduler_warmup_ratio: 0.1
181
+ - num_epochs: 1
182
+
183
+ ### Training Results
184
+ | Epoch | Step | Validation Loss | Validation Precision | Validation Recall | Validation F1 | Validation Accuracy |
185
+ |:------:|:----:|:---------------:|:--------------------:|:-----------------:|:-------------:|:-------------------:|
186
+ | 0.1629 | 200 | 0.0335 | 0.6884 | 0.6223 | 0.6537 | 0.9062 |
187
+ | 0.3259 | 400 | 0.0238 | 0.7412 | 0.7193 | 0.7301 | 0.9242 |
188
+ | 0.4888 | 600 | 0.0220 | 0.7628 | 0.7378 | 0.7501 | 0.9325 |
189
+ | 0.6517 | 800 | 0.0211 | 0.7614 | 0.7677 | 0.7645 | 0.9376 |
190
+ | 0.8147 | 1000 | 0.0197 | 0.7839 | 0.7596 | 0.7716 | 0.9384 |
191
+ | 0.9776 | 1200 | 0.0194 | 0.7803 | 0.7633 | 0.7717 | 0.9393 |
192
+
193
+ ### Framework Versions
194
+ - Python: 3.10.12
195
+ - SpanMarker: 1.5.0
196
+ - Transformers: 4.37.2
197
+ - PyTorch: 2.1.0+cu121
198
+ - Datasets: 2.17.1
199
+ - Tokenizers: 0.15.2
200
+
201
+ ## Citation
202
+
203
+ ### BibTeX
204
+ ```
205
+ @software{Aarsen_SpanMarker,
206
+ author = {Aarsen, Tom},
207
+ license = {Apache-2.0},
208
+ title = {{SpanMarker for Named Entity Recognition}},
209
+ url = {https://github.com/tomaarsen/SpanMarkerNER}
210
+ }
211
+ ```
212
+
213
+ <!--
214
+ ## Glossary
215
+
216
+ *Clearly define terms in order to be accessible across audiences.*
217
+ -->
218
+
219
+ <!--
220
+ ## Model Card Authors
221
+
222
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
223
+ -->
224
+
225
+ <!--
226
+ ## Model Card Contact
227
+
228
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
229
+ -->
added_tokens.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "<end>": 28997,
3
+ "<start>": 28996
4
+ }
config.json ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SpanMarkerModel"
4
+ ],
5
+ "encoder": {
6
+ "_name_or_path": "bert-base-cased",
7
+ "add_cross_attention": false,
8
+ "architectures": [
9
+ "BertForMaskedLM"
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": 768,
32
+ "id2label": {
33
+ "0": "O",
34
+ "1": "art",
35
+ "2": "building",
36
+ "3": "event",
37
+ "4": "location",
38
+ "5": "organization",
39
+ "6": "other",
40
+ "7": "person",
41
+ "8": "product"
42
+ },
43
+ "initializer_range": 0.02,
44
+ "intermediate_size": 3072,
45
+ "is_decoder": false,
46
+ "is_encoder_decoder": false,
47
+ "label2id": {
48
+ "O": 0,
49
+ "art": 1,
50
+ "building": 2,
51
+ "event": 3,
52
+ "location": 4,
53
+ "organization": 5,
54
+ "other": 6,
55
+ "person": 7,
56
+ "product": 8
57
+ },
58
+ "layer_norm_eps": 1e-12,
59
+ "length_penalty": 1.0,
60
+ "max_length": 20,
61
+ "max_position_embeddings": 512,
62
+ "min_length": 0,
63
+ "model_type": "bert",
64
+ "no_repeat_ngram_size": 0,
65
+ "num_attention_heads": 12,
66
+ "num_beam_groups": 1,
67
+ "num_beams": 1,
68
+ "num_hidden_layers": 12,
69
+ "num_return_sequences": 1,
70
+ "output_attentions": false,
71
+ "output_hidden_states": false,
72
+ "output_scores": false,
73
+ "pad_token_id": 0,
74
+ "position_embedding_type": "absolute",
75
+ "prefix": null,
76
+ "problem_type": null,
77
+ "pruned_heads": {},
78
+ "remove_invalid_values": false,
79
+ "repetition_penalty": 1.0,
80
+ "return_dict": true,
81
+ "return_dict_in_generate": false,
82
+ "sep_token_id": null,
83
+ "suppress_tokens": null,
84
+ "task_specific_params": null,
85
+ "temperature": 1.0,
86
+ "tf_legacy_loss": false,
87
+ "tie_encoder_decoder": false,
88
+ "tie_word_embeddings": true,
89
+ "tokenizer_class": null,
90
+ "top_k": 50,
91
+ "top_p": 1.0,
92
+ "torch_dtype": null,
93
+ "torchscript": false,
94
+ "transformers_version": "4.37.2",
95
+ "type_vocab_size": 2,
96
+ "typical_p": 1.0,
97
+ "use_bfloat16": false,
98
+ "use_cache": true,
99
+ "vocab_size": 29000
100
+ },
101
+ "entity_max_length": 8,
102
+ "marker_max_length": 128,
103
+ "max_next_context": null,
104
+ "max_prev_context": null,
105
+ "model_max_length": 256,
106
+ "model_max_length_default": 512,
107
+ "model_type": "span-marker",
108
+ "span_marker_version": "1.5.0",
109
+ "torch_dtype": "float32",
110
+ "trained_with_document_context": false,
111
+ "transformers_version": "4.37.2",
112
+ "vocab_size": 29000
113
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd979b2efc7d6b61c64bac7e558666885e8f8b0a02c9c835d7f715c1323a59df
3
+ size 433332812
runs/Feb22_11-50-38_6163c3b3e44c/events.out.tfevents.1708602666.6163c3b3e44c.470.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d16171bd4fe0461d0d1dcdd5427e22c32997cb8f273d813ebf310ebafbc9e03
3
+ size 13816
runs/Feb22_11-50-38_6163c3b3e44c/events.out.tfevents.1708604273.6163c3b3e44c.470.1 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9df2d220edc2858ad00e6bd2399f39017083d43ddf081a60e54d11cfc8ef3cd5
3
+ size 1096
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,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "28996": {
45
+ "content": "<start>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "28997": {
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_lower_case": false,
64
+ "mask_token": "[MASK]",
65
+ "model_max_length": 256,
66
+ "pad_token": "[PAD]",
67
+ "sep_token": "[SEP]",
68
+ "strip_accents": null,
69
+ "tokenize_chinese_chars": true,
70
+ "tokenizer_class": "BertTokenizer",
71
+ "unk_token": "[UNK]"
72
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b252a26ee0168b48fa32b5f1d0db50b7c417473e6d39ec7b6bd306be2c0bee8c
3
+ size 4728
vocab.txt ADDED
The diff for this file is too large to render. See raw diff