eek commited on
Commit
69e0b0b
1 Parent(s): 1ce6954

Update Readme with details

Browse files
Files changed (1) hide show
  1. README.md +100 -62
README.md CHANGED
@@ -6,6 +6,7 @@ tags:
6
  - ner
7
  - named-entity-recognition
8
  - generated_from_span_marker_trainer
 
9
  datasets:
10
  - DFKI-SLT/few-nerd
11
  metrics:
@@ -14,27 +15,81 @@ metrics:
14
  - f1
15
  widget: []
16
  pipeline_tag: token-classification
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  ---
18
 
19
  # SpanMarker
20
 
21
- 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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  ## Model Details
24
 
25
  ### Model Description
26
  - **Model Type:** SpanMarker
27
- <!-- - **Encoder:** [Unknown](https://huggingface.co/unknown) -->
28
  - **Maximum Sequence Length:** 256 tokens
29
  - **Maximum Entity Length:** 6 words
30
  - **Training Dataset:** [DFKI-SLT/few-nerd](https://huggingface.co/datasets/DFKI-SLT/few-nerd)
31
- <!-- - **Language:** Unknown -->
32
- <!-- - **License:** Unknown -->
33
 
34
- ### Model Sources
35
 
36
- - **Repository:** [SpanMarker on GitHub](https://github.com/tomaarsen/SpanMarkerNER)
37
- - **Thesis:** [SpanMarker For Named Entity Recognition](https://raw.githubusercontent.com/tomaarsen/SpanMarkerNER/main/thesis.pdf)
38
 
39
  ## Uses
40
 
@@ -44,53 +99,25 @@ This is a [SpanMarker](https://github.com/tomaarsen/SpanMarkerNER) model trained
44
  from span_marker import SpanMarkerModel
45
 
46
  # Download from the 🤗 Hub
47
- model = SpanMarkerModel.from_pretrained("span_marker_model_id")
48
  # Run inference
49
- entities = model.predict("None")
50
  ```
51
 
52
- ### Downstream Use
53
- You can finetune this model on your own dataset.
54
-
55
- <details><summary>Click to expand</summary>
56
 
57
  ```python
58
- from span_marker import SpanMarkerModel, Trainer
59
 
60
- # Download from the 🤗 Hub
61
- model = SpanMarkerModel.from_pretrained("span_marker_model_id")
62
-
63
- # Specify a Dataset with "tokens" and "ner_tag" columns
64
- dataset = load_dataset("conll2003") # For example CoNLL2003
65
 
66
- # Initialize a Trainer using the pretrained model & dataset
67
- trainer = Trainer(
68
- model=model,
69
- train_dataset=dataset["train"],
70
- eval_dataset=dataset["validation"],
71
- )
72
- trainer.train()
73
- trainer.save_model("span_marker_model_id-finetuned")
74
  ```
75
- </details>
76
-
77
- <!--
78
- ### Out-of-Scope Use
79
-
80
- *List how the model may foreseeably be misused and address what users ought not to do with the model.*
81
- -->
82
-
83
- <!--
84
- ## Bias, Risks and Limitations
85
-
86
- *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
87
- -->
88
-
89
- <!--
90
- ### Recommendations
91
-
92
- *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
93
- -->
94
 
95
  ## Training Details
96
 
@@ -102,7 +129,32 @@ trainer.save_model("span_marker_model_id-finetuned")
102
  - Datasets: 2.18.0
103
  - Tokenizers: 0.15.2
104
 
105
- ## Citation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  ### BibTeX
108
  ```
@@ -114,20 +166,6 @@ trainer.save_model("span_marker_model_id-finetuned")
114
  }
115
  ```
116
 
117
- <!--
118
- ## Glossary
119
-
120
- *Clearly define terms in order to be accessible across audiences.*
121
- -->
122
-
123
- <!--
124
  ## Model Card Authors
125
 
126
- *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
127
- -->
128
-
129
- <!--
130
- ## Model Card Contact
131
-
132
- *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
133
- -->
 
6
  - ner
7
  - named-entity-recognition
8
  - generated_from_span_marker_trainer
9
+ - muppet-roberta-large-ner
10
  datasets:
11
  - DFKI-SLT/few-nerd
12
  metrics:
 
15
  - f1
16
  widget: []
17
  pipeline_tag: token-classification
18
+ license: cc-by-sa-4.0
19
+ language:
20
+ - en
21
+ model-index:
22
+ - name: >-
23
+ SpanMarker w. facebook/muppet-roberta-large on finegrained, supervised FewNERD by Radu-Sebastian Amarie
24
+ results:
25
+ - task:
26
+ type: token-classification
27
+ name: Named Entity Recognition
28
+ dataset:
29
+ name: finegrained, supervised FewNERD
30
+ type: DFKI-SLT/few-nerd
31
+ config: supervised
32
+ split: test
33
+ revision: 6f0944f5a1d47c359b4f5de03ed1d58c98f297b5
34
+ metrics:
35
+ - type: f1
36
+ value: 0.705678
37
+ name: F1
38
+ - type: precision
39
+ value: 0.701648
40
+ name: Precision
41
+ - type: recall
42
+ value: 0.709755
43
+ name: Recall
44
+
45
  ---
46
 
47
  # SpanMarker
48
 
49
+ 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.
50
+ Training was done on a Nvidia 4090 in approximately 8 hours (but final chosen checkpoint was from before the first half of training)
51
+
52
+
53
+ ## Training and Validation Metrics
54
+
55
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/630f2745982455e61cc5fb1d/TlEu3b2PmnptXc1pZ7C2u.png)
56
+
57
+ Current model represents STEP 25000
58
+
59
+
60
+ ## Test Set Evaluation
61
+
62
+ The following are some manually-selected checkpoints that correspond to the above steps:
63
+
64
+ ```
65
+ | checkpoint | Precision | Recall | F1 | Accuracy | Runtime | Samples/s |
66
+ |-------------:|----------:|-----------:|-----------:|-----------:|----------:|------------:|
67
+ | 17000 | 0.706066 | 0.691239 | 0.698574 | 0.926213 | 335.172 | 123.474 |
68
+ | 18000 | 0.695331 | 0.700382 | 0.697847 | 0.926372 | 301.435 | 137.293 |
69
+ | 19000 | 0.70618 | 0.693775 | 0.699923 | 0.926492 | 301.032 | 137.477 |
70
+ | 20000 | 0.700665 | 0.701572 | 0.701118 | 0.927128 | 299.706 | 138.085 |
71
+ | 21000 | 0.706467 | 0.695591 | 0.700987 | 0.926318 | 299.62 | 138.125 |
72
+ | 22000 | 0.698079 | 0.710756 | 0.704361 | 0.928094 | 300.041 | 137.931 |
73
+ | 24000 | 0.709286 | 0.695769 | 0.702463 | 0.926329 | 300.339 | 137.794 |
74
+ | 25000 | 0.701648 | 0.709755 | 0.705678 | 0.92792 | 299.905 | 137.994 |
75
+ | 26000 | 0.702509 | 0.708147 | 0.705317 | 0.927998 | 301.161 | 137.418 |
76
+ | 27000 | 0.707315 | 0.698796 | 0.703029 | 0.926493 | 299.692 | 138.092 |
77
+ ```
78
 
79
  ## Model Details
80
 
81
  ### Model Description
82
  - **Model Type:** SpanMarker
83
+ **Encoder:** [muppet-roberta-large](https://huggingface.co/facebook/muppet-roberta-large)
84
  - **Maximum Sequence Length:** 256 tokens
85
  - **Maximum Entity Length:** 6 words
86
  - **Training Dataset:** [DFKI-SLT/few-nerd](https://huggingface.co/datasets/DFKI-SLT/few-nerd)
87
+ - **Language:** en
88
+ - **License:** cc-by-sa-4.0
89
 
90
+ ### Useful Links
91
 
92
+ - Training was done with SpanMarker Trainer that can be found here: [SpanMarker on GitHub](https://github.com/tomaarsen/SpanMarkerNER)
 
93
 
94
  ## Uses
95
 
 
99
  from span_marker import SpanMarkerModel
100
 
101
  # Download from the 🤗 Hub
102
+ model = SpanMarkerModel.from_pretrained("eek/span-marker-muppet-roberta-large-fewnerd-fine-super")
103
  # Run inference
104
+ entities = model.predict("His name was Radu.")
105
  ```
106
 
107
+ or it can be used directly in spacy via [SpanMarker](https://spacy.io/universe/project/span_marker).
 
 
 
108
 
109
  ```python
110
+ import spacy
111
 
112
+ nlp = spacy.load("en_core_web_sm", exclude=["ner"])
113
+ nlp.add_pipe("span_marker", config={"model": "tomaarsen/span-marker-roberta-large-ontonotes5"})
 
 
 
114
 
115
+ text = """Cleopatra VII, also known as Cleopatra the Great, was the last active ruler of the \
116
+ Ptolemaic Kingdom of Egypt. She was born in 69 BCE and ruled Egypt from 51 BCE until her \
117
+ death in 30 BCE."""
118
+ doc = nlp(text)
119
+ print([(entity, entity.label_) for entity in doc.ents])
 
 
 
120
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
122
  ## Training Details
123
 
 
129
  - Datasets: 2.18.0
130
  - Tokenizers: 0.15.2
131
 
132
+ ### Training Arguments
133
+
134
+ ```
135
+ args = TrainingArguments(
136
+ output_dir="models/span-marker-muppet-roberta-large-fewnerd-fine-super",
137
+ learning_rate=1e-5,
138
+ gradient_accumulation_steps=2,
139
+ per_device_train_batch_size=8,
140
+ per_device_eval_batch_size=8,
141
+ num_train_epochs=8,
142
+ evaluation_strategy="steps",
143
+ save_strategy="steps",
144
+ save_steps=1000,
145
+ eval_steps=500,
146
+ push_to_hub=False,
147
+ logging_steps=50,
148
+ fp16=True,
149
+ warmup_ratio=0.1,
150
+ dataloader_num_workers=1,
151
+ load_best_model_at_end=True
152
+ )
153
+ ```
154
+
155
+ ## Thanks
156
+
157
+ Thanks to Tom Aarsen for the SpanMarker library.
158
 
159
  ### BibTeX
160
  ```
 
166
  }
167
  ```
168
 
 
 
 
 
 
 
 
169
  ## Model Card Authors
170
 
171
+ - Done by [Radu-Sebastian Amarie](https://huggingface.co/eek)