tomaarsen HF staff commited on
Commit
07f6697
1 Parent(s): 680f280

Upload model

Browse files
Files changed (3) hide show
  1. README.md +104 -100
  2. config.json +8 -8
  3. pytorch_model.bin +2 -2
README.md CHANGED
@@ -1,127 +1,131 @@
1
-
2
  ---
3
- license: apache-2.0
4
  library_name: span-marker
5
  tags:
6
  - span-marker
7
  - token-classification
8
  - ner
9
  - named-entity-recognition
10
- pipeline_tag: token-classification
11
- widget:
12
- - text: "Here, DA = direct assessment, RR = relative ranking, DS = discrete scale and CS = continuous scale."
13
- example_title: "Example 1"
14
- - text: "Modifying or replacing the Erasable Programmable Read Only Memory (EPROM) in a phone would allow the configuration of any ESN and MIN via software for cellular devices."
15
- example_title: "Example 2"
16
- - text: "We propose a technique called Aggressive Stochastic Weight Averaging (ASWA) and an extension called Norm-filtered Aggressive Stochastic Weight Averaging (NASWA) which improves the stability of models over random seeds."
17
- example_title: "Example 3"
18
- - text: "The choice of the encoder and decoder modules of DNPG can be quite flexible, for instance long-short term memory networks (LSTM) or convolutional neural network (CNN)."
19
- example_title: "Example 4"
20
- model-index:
21
- - name: SpanMarker w. bert-base-cased on Acronym Identification by Tom Aarsen
22
- results:
23
- - task:
24
- type: token-classification
25
- name: Named Entity Recognition
26
- dataset:
27
- type: acronym_identification
28
- name: Acronym Identification
29
- split: validation
30
- revision: c3c245a18bbd57b1682b099e14460eebf154cbdf
31
- metrics:
32
- - type: f1
33
- value: 0.9310
34
- name: F1
35
- - type: precision
36
- value: 0.9423
37
- name: Precision
38
- - type: recall
39
- value: 0.9199
40
- name: Recall
41
- datasets:
42
- - acronym_identification
43
- language:
44
- - en
45
  metrics:
46
- - f1
47
- - recall
48
- - precision
 
 
49
  ---
50
 
51
- # SpanMarker for Acronyms Named Entity Recognition
52
-
53
- This is a [SpanMarker](https://github.com/tomaarsen/SpanMarkerNER) model trained on the [acronym_identification](https://huggingface.co/datasets/acronym_identification) dataset. In particular, this SpanMarker model uses [bert-base-cased](https://huggingface.co/bert-base-cased) as the underlying encoder. See [train.py](train.py) for the training script.
54
 
55
- Is your data not (always) capitalized correctly? Then consider using the uncased variant of this model instead for better performance:
56
- [tomaarsen/span-marker-bert-base-uncased-acronyms](https://huggingface.co/tomaarsen/span-marker-bert-base-uncased-acronyms).
57
 
58
- ## Metrics
59
 
60
- It achieves the following results on the validation set:
61
- - Overall Precision: 0.9423
62
- - Overall Recall: 0.9199
63
- - Overall F1: 0.9310
64
- - Overall Accuracy: 0.9830
 
 
 
65
 
66
- ## Labels
67
 
68
- | **Label** | **Examples** |
69
- |-----------|--------------|
70
- | SHORT | "NLP", "CoQA", "SODA", "SCA" |
71
- | LONG | "Natural Language Processing", "Conversational Question Answering", "Symposium on Discrete Algorithms", "successive convex approximation" |
72
 
 
73
 
74
- ## Usage
75
 
76
- To use this model for inference, first install the `span_marker` library:
 
77
 
78
- ```bash
79
- pip install span_marker
 
 
80
  ```
81
 
82
- You can then run inference with this model like so:
 
 
 
83
 
84
  ```python
85
- from span_marker import SpanMarkerModel
86
 
87
  # Download from the 🤗 Hub
88
- model = SpanMarkerModel.from_pretrained("tomaarsen/span-marker-bert-base-acronyms")
89
- # Run inference
90
- entities = model.predict("Compression algorithms like Principal Component Analysis (PCA) can reduce noise and complexity.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  ```
92
 
93
- See the [SpanMarker](https://github.com/tomaarsen/SpanMarkerNER) repository for documentation and additional information on this library.
94
-
95
- ## Training procedure
96
-
97
- ### Training hyperparameters
98
-
99
- The following hyperparameters were used during training:
100
- - learning_rate: 5e-05
101
- - train_batch_size: 32
102
- - eval_batch_size: 32
103
- - seed: 42
104
- - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
105
- - lr_scheduler_type: linear
106
- - lr_scheduler_warmup_ratio: 0.1
107
- - num_epochs: 2
108
-
109
- ### Training results
110
-
111
- | Training Loss | Epoch | Step | Validation Loss | Overall Precision | Overall Recall | Overall F1 | Overall Accuracy |
112
- |:-------------:|:-----:|:----:|:---------------:|:-----------------:|:--------------:|:----------:|:----------------:|
113
- | 0.0109 | 0.31 | 200 | 0.0079 | 0.9202 | 0.8962 | 0.9080 | 0.9765 |
114
- | 0.0075 | 0.62 | 400 | 0.0070 | 0.9358 | 0.8724 | 0.9030 | 0.9765 |
115
- | 0.0068 | 0.93 | 600 | 0.0059 | 0.9363 | 0.9203 | 0.9282 | 0.9821 |
116
- | 0.0057 | 1.24 | 800 | 0.0056 | 0.9372 | 0.9187 | 0.9278 | 0.9824 |
117
- | 0.0051 | 1.55 | 1000 | 0.0054 | 0.9381 | 0.9170 | 0.9274 | 0.9824 |
118
- | 0.0054 | 1.86 | 1200 | 0.0053 | 0.9424 | 0.9218 | 0.9320 | 0.9834 |
119
- | 0.0054 | 2.00 | 1290 | 0.0054 | 0.9423 | 0.9199 | 0.9310 | 0.9830 |
120
-
121
- ### Framework versions
122
-
123
- - SpanMarker 1.2.4
124
- - Transformers 4.31.0
125
- - Pytorch 1.13.1+cu117
126
- - Datasets 2.14.3
127
- - Tokenizers 0.13.2
 
 
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
  metrics:
10
+ - precision
11
+ - recall
12
+ - f1
13
+ widget: []
14
+ pipeline_tag: token-classification
15
  ---
16
 
17
+ # SpanMarker
 
 
18
 
19
+ This is a [SpanMarker](https://github.com/tomaarsen/SpanMarkerNER) model that can be used for Named Entity Recognition.
 
20
 
21
+ ## Model Details
22
 
23
+ ### Model Description
24
+ - **Model Type:** SpanMarker
25
+ <!-- - **Encoder:** [Unknown](https://huggingface.co/unknown) -->
26
+ - **Maximum Sequence Length:** 256 tokens
27
+ - **Maximum Entity Length:** 8 words
28
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
29
+ <!-- - **Language:** Unknown -->
30
+ <!-- - **License:** Unknown -->
31
 
32
+ ### Model Sources
33
 
34
+ - **Repository:** [SpanMarker on GitHub](https://github.com/tomaarsen/SpanMarkerNER)
35
+ - **Thesis:** [SpanMarker For Named Entity Recognition](https://raw.githubusercontent.com/tomaarsen/SpanMarkerNER/main/thesis.pdf)
 
 
36
 
37
+ ## Uses
38
 
39
+ ### Direct Use for Inference
40
 
41
+ ```python
42
+ from span_marker import SpanMarkerModel
43
 
44
+ # Download from the 🤗 Hub
45
+ model = SpanMarkerModel.from_pretrained("span_marker_model_id")
46
+ # Run inference
47
+ entities = model.predict("Amelia Earhart flew her single engine Lockheed Vega 5B across the Atlantic to Paris.")
48
  ```
49
 
50
+ ### Downstream Use
51
+ You can finetune this model on your own dataset.
52
+
53
+ <details><summary>Click to expand</summary>
54
 
55
  ```python
56
+ from span_marker import SpanMarkerModel, Trainer
57
 
58
  # Download from the 🤗 Hub
59
+ model = SpanMarkerModel.from_pretrained("span_marker_model_id")
60
+
61
+ # Specify a Dataset with "tokens" and "ner_tag" columns
62
+ dataset = load_dataset("conll2003") # For example CoNLL2003
63
+
64
+ # Initialize a Trainer using the pretrained model & dataset
65
+ trainer = Trainer(
66
+ model=model,
67
+ train_dataset=dataset["train"],
68
+ eval_dataset=dataset["validation"],
69
+ )
70
+ trainer.train()
71
+ trainer.save_model("span_marker_model_id-finetuned")
72
+ ```
73
+ </details>
74
+
75
+ <!--
76
+ ### Out-of-Scope Use
77
+
78
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
79
+ -->
80
+
81
+ <!--
82
+ ## Bias, Risks and Limitations
83
+
84
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
85
+ -->
86
+
87
+ <!--
88
+ ### Recommendations
89
+
90
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
91
+ -->
92
+
93
+ ## Training Details
94
+
95
+ ### Framework Versions
96
+ - Python: 3.9.16
97
+ - SpanMarker: 1.3.1.dev
98
+ - Transformers: 4.30.0
99
+ - PyTorch: 2.0.1+cu118
100
+ - Datasets: 2.14.0
101
+ - Tokenizers: 0.13.2
102
+
103
+ ## Citation
104
+
105
+ ### BibTeX
106
+ ```
107
+ @software{Aarsen_SpanMarker,
108
+ author = {Aarsen, Tom},
109
+ license = {Apache-2.0},
110
+ title = {{SpanMarker for Named Entity Recognition}},
111
+ url = {https://github.com/tomaarsen/SpanMarkerNER}
112
+ }
113
  ```
114
 
115
+ <!--
116
+ ## Glossary
117
+
118
+ *Clearly define terms in order to be accessible across audiences.*
119
+ -->
120
+
121
+ <!--
122
+ ## Model Card Authors
123
+
124
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
125
+ -->
126
+
127
+ <!--
128
+ ## Model Card Contact
129
+
130
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
131
+ -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
config.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "_name_or_path": "models\\span_marker_bert_base_acronyms\\checkpoint-final",
3
  "architectures": [
4
  "SpanMarkerModel"
5
  ],
@@ -84,7 +84,7 @@
84
  "top_p": 1.0,
85
  "torch_dtype": null,
86
  "torchscript": false,
87
- "transformers_version": "4.31.0",
88
  "type_vocab_size": 2,
89
  "typical_p": 1.0,
90
  "use_bfloat16": false,
@@ -94,8 +94,8 @@
94
  "entity_max_length": 8,
95
  "id2label": {
96
  "0": "O",
97
- "1": "LONG",
98
- "2": "SHORT"
99
  },
100
  "id2reduced_id": {
101
  "0": 1,
@@ -105,9 +105,9 @@
105
  "4": 0
106
  },
107
  "label2id": {
108
- "LONG": 1,
109
  "O": 0,
110
- "SHORT": 2
 
111
  },
112
  "marker_max_length": 128,
113
  "max_next_context": null,
@@ -115,9 +115,9 @@
115
  "model_max_length": 256,
116
  "model_max_length_default": 512,
117
  "model_type": "span-marker",
118
- "span_marker_version": "1.2.5.dev",
119
  "torch_dtype": "float32",
120
  "trained_with_document_context": false,
121
- "transformers_version": "4.31.0",
122
  "vocab_size": 28998
123
  }
 
1
  {
2
+ "_name_or_path": "models\\tomaarsen\\span-marker-bert-base-acronyms\\checkpoint-final",
3
  "architectures": [
4
  "SpanMarkerModel"
5
  ],
 
84
  "top_p": 1.0,
85
  "torch_dtype": null,
86
  "torchscript": false,
87
+ "transformers_version": "4.30.0",
88
  "type_vocab_size": 2,
89
  "typical_p": 1.0,
90
  "use_bfloat16": false,
 
94
  "entity_max_length": 8,
95
  "id2label": {
96
  "0": "O",
97
+ "1": "long",
98
+ "2": "short"
99
  },
100
  "id2reduced_id": {
101
  "0": 1,
 
105
  "4": 0
106
  },
107
  "label2id": {
 
108
  "O": 0,
109
+ "long": 1,
110
+ "short": 2
111
  },
112
  "marker_max_length": 128,
113
  "max_next_context": null,
 
115
  "model_max_length": 256,
116
  "model_max_length_default": 512,
117
  "model_type": "span-marker",
118
+ "span_marker_version": "1.3.1.dev",
119
  "torch_dtype": "float32",
120
  "trained_with_document_context": false,
121
+ "transformers_version": "4.30.0",
122
  "vocab_size": 28998
123
  }
pytorch_model.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b60063b813ab8a8a15e8c15c7258685cd21fe2ca6a5e0e3d2f347140b33f747e
3
- size 433331825
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:30895143e4a162f4a27e493c5d56e7dc6928902762e1ff6b1d1c7522cb7e1f2e
3
+ size 433336245