sjrhuschlee commited on
Commit
d685831
1 Parent(s): 28fd968

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +242 -0
README.md CHANGED
@@ -1,3 +1,245 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ datasets:
4
+ - squad_v2
5
+ - squad
6
+ language:
7
+ - en
8
+ library_name: transformers
9
+ pipeline_tag: question-answering
10
+ tags:
11
+ - deberta
12
+ - deberta-v3
13
+ - question-answering
14
+ - squad
15
+ - squad_v2
16
+ model-index:
17
+ - name: sjrhuschlee/deberta-v3-base-squad2-ext-v1
18
+ results:
19
+ - task:
20
+ type: question-answering
21
+ name: Question Answering
22
+ dataset:
23
+ name: squad_v2
24
+ type: squad_v2
25
+ config: squad_v2
26
+ split: validation
27
+ metrics:
28
+ - type: exact_match
29
+ value: 79.483
30
+ name: Exact Match
31
+ - type: f1
32
+ value: 82.343
33
+ name: F1
34
+ - task:
35
+ type: question-answering
36
+ name: Question Answering
37
+ dataset:
38
+ name: squad
39
+ type: squad
40
+ config: plain_text
41
+ split: validation
42
+ metrics:
43
+ - type: exact_match
44
+ value: 85.894
45
+ name: Exact Match
46
+ - type: f1
47
+ value: 91.298
48
+ name: F1
49
+ - task:
50
+ type: question-answering
51
+ name: Question Answering
52
+ dataset:
53
+ name: adversarial_qa
54
+ type: adversarial_qa
55
+ config: adversarialQA
56
+ split: validation
57
+ metrics:
58
+ - type: exact_match
59
+ value: 44.867
60
+ name: Exact Match
61
+ - type: f1
62
+ value: 55.996
63
+ name: F1
64
+ - task:
65
+ type: question-answering
66
+ name: Question Answering
67
+ dataset:
68
+ name: squad_adversarial
69
+ type: squad_adversarial
70
+ config: AddOneSent
71
+ split: validation
72
+ metrics:
73
+ - type: exact_match
74
+ value: 80.190
75
+ name: Exact Match
76
+ - type: f1
77
+ value: 85.028
78
+ name: F1
79
+ - task:
80
+ type: question-answering
81
+ name: Question Answering
82
+ dataset:
83
+ name: squadshifts
84
+ type: squadshifts
85
+ config: amazon
86
+ split: test
87
+ metrics:
88
+ - type: exact_match
89
+ value: 69.712
90
+ name: Exact Match
91
+ - type: f1
92
+ value: 81.171
93
+ name: F1
94
+ - task:
95
+ type: question-answering
96
+ name: Question Answering
97
+ dataset:
98
+ name: squadshifts
99
+ type: squadshifts
100
+ config: new_wiki
101
+ split: test
102
+ metrics:
103
+ - type: exact_match
104
+ value: 81.544
105
+ name: Exact Match
106
+ - type: f1
107
+ value: 89.782
108
+ name: F1
109
+ - task:
110
+ type: question-answering
111
+ name: Question Answering
112
+ dataset:
113
+ name: squadshifts
114
+ type: squadshifts
115
+ config: nyt
116
+ split: test
117
+ metrics:
118
+ - type: exact_match
119
+ value: 80.05
120
+ name: Exact Match
121
+ - type: f1
122
+ value: 87.756
123
+ name: F1
124
+ - task:
125
+ type: question-answering
126
+ name: Question Answering
127
+ dataset:
128
+ name: squadshifts
129
+ type: squadshifts
130
+ config: reddit
131
+ split: test
132
+ metrics:
133
+ - type: exact_match
134
+ value: 60.481
135
+ name: Exact Match
136
+ - type: f1
137
+ value: 68.686
138
+ name: F1
139
  ---
140
+
141
+ # deberta-v3-base for Extractive QA
142
+
143
+ This is the [deberta-v3-base](https://huggingface.co/microsoft/deberta-v3-base) model, fine-tuned using the [SQuAD2.0](https://huggingface.co/datasets/squad_v2) dataset. It's been trained on question-answer pairs, including unanswerable questions, for the task of Extractive Question Answering.
144
+
145
+ ## Overview
146
+ **Language model:** deberta-v3-base
147
+ **Language:** English
148
+ **Downstream-task:** Extractive QA
149
+ **Training data:** SQuAD 2.0
150
+ **Eval data:** SQuAD 2.0
151
+ **Infrastructure**: 1x NVIDIA 3070
152
+
153
+ ## Model Usage
154
+ ```python
155
+ import torch
156
+ from transformers import(
157
+ AutoModelForQuestionAnswering,
158
+ AutoTokenizer,
159
+ pipeline
160
+ )
161
+ model_name = "sjrhuschlee/deberta-v3-base-squad2-ext-v1"
162
+
163
+ # a) Using pipelines
164
+ nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
165
+ qa_input = {
166
+ 'question': 'Where do I live?',
167
+ 'context': 'My name is Sarah and I live in London'
168
+ }
169
+ res = nlp(qa_input)
170
+ # {'score': 0.984, 'start': 30, 'end': 37, 'answer': ' London'}
171
+
172
+ # b) Load model & tokenizer
173
+ model = AutoModelForQuestionAnswering.from_pretrained(model_name)
174
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
175
+
176
+ question = 'Where do I live?'
177
+ context = 'My name is Sarah and I live in London'
178
+ encoding = tokenizer(question, context, return_tensors="pt")
179
+ start_scores, end_scores = model(
180
+ encoding["input_ids"],
181
+ attention_mask=encoding["attention_mask"],
182
+ return_dict=False
183
+ )
184
+
185
+ all_tokens = tokenizer.convert_ids_to_tokens(input_ids[0].tolist())
186
+ answer_tokens = all_tokens[torch.argmax(start_scores):torch.argmax(end_scores) + 1]
187
+ answer = tokenizer.decode(tokenizer.convert_tokens_to_ids(answer_tokens))
188
+ # 'London'
189
+ ```
190
+
191
+ ## Metrics
192
+
193
+ ```bash
194
+ # Squad v2
195
+ {
196
+ "eval_HasAns_exact": 84.36234817813765,
197
+ "eval_HasAns_f1": 90.09079905537246,
198
+ "eval_HasAns_total": 5928,
199
+ "eval_NoAns_exact": 74.61732548359966,
200
+ "eval_NoAns_f1": 74.61732548359966,
201
+ "eval_NoAns_total": 5945,
202
+ "eval_best_exact": 79.45759285774446,
203
+ "eval_best_exact_thresh": 0.0,
204
+ "eval_best_f1": 82.31771724081922,
205
+ "eval_best_f1_thresh": 0.0,
206
+ "eval_exact": 79.48286027120358,
207
+ "eval_f1": 82.34298465427844,
208
+ "eval_runtime": 109.7262,
209
+ "eval_samples": 11951,
210
+ "eval_samples_per_second": 108.917,
211
+ "eval_steps_per_second": 4.539,
212
+ "eval_total": 11873
213
+ }
214
+
215
+ # Squad
216
+ {
217
+ "eval_exact": 85.89403973509934,
218
+ "eval_f1": 91.2982923196374,
219
+ "eval_runtime": 96.6499,
220
+ "eval_samples": 10618,
221
+ "eval_samples_per_second": 109.86,
222
+ "eval_steps_per_second": 4.584,
223
+ "eval_total": 10570
224
+ }
225
+ ```
226
+
227
+ ## Training procedure
228
+
229
+ ### Training hyperparameters
230
+
231
+ The following hyperparameters were used during training:
232
+ - learning_rate: 1e-06
233
+ - train_batch_size: 12
234
+ - eval_batch_size: 8
235
+ - seed: 42
236
+ - gradient_accumulation_steps: 8
237
+ - total_train_batch_size: 96
238
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
239
+ - lr_scheduler_type: linear
240
+ - lr_scheduler_warmup_ratio: 0.1
241
+ - num_epochs: 3.0
242
+
243
+ ### Framework versions
244
+
245
+ - Transformers 4.31.0.dev0