Update README.md
Browse files
README.md
CHANGED
@@ -5,4 +5,87 @@ language:
|
|
5 |
- nl
|
6 |
---
|
7 |
|
8 |
-
The used dataset raalst/squad_v2_dutch was kindly provided by Henryk
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
- nl
|
6 |
---
|
7 |
|
8 |
+
The used dataset raalst/squad_v2_dutch was kindly provided by Henryk
|
9 |
+
it contains train and validation.
|
10 |
+
I declared 20% of Train to function as Test
|
11 |
+
when using raalst/squad_v2_dutch, be sure to clean up quotes and double quotes in the contexts
|
12 |
+
|
13 |
+
def cleanup(mylist):
|
14 |
+
for item in mylist:
|
15 |
+
if '"' in item["context"]:
|
16 |
+
item["context"] = item["context"].replace('"','\\"')
|
17 |
+
if "'" in item["context"]:
|
18 |
+
item["context"] = item["context"].replace("'","\\'")
|
19 |
+
|
20 |
+
The pretrained model was pdelobelle/robbert-v2-dutch-base, a dutch RoBERTa model
|
21 |
+
|
22 |
+
results obtained in training are :
|
23 |
+
|
24 |
+
{'exact': 61.75389109958193,
|
25 |
+
'f1': 66.89717170237417,
|
26 |
+
'total': 19853,
|
27 |
+
'HasAns_exact': 48.967182330322814,
|
28 |
+
'HasAns_f1': 58.09796564493008,
|
29 |
+
'HasAns_total': 11183,
|
30 |
+
'NoAns_exact': 78.24682814302192,
|
31 |
+
'NoAns_f1': 78.24682814302192,
|
32 |
+
'NoAns_total': 8670,
|
33 |
+
'best_exact': 61.75389109958193,
|
34 |
+
'best_exact_thresh': 0.0,
|
35 |
+
'best_f1': 66.89717170237276,
|
36 |
+
'best_f1_thresh': 0.0}
|
37 |
+
|
38 |
+
settings (until I figured out how to report them properly):
|
39 |
+
|
40 |
+
DatasetDict({
|
41 |
+
train: Dataset({
|
42 |
+
features: ['id', 'title', 'context', 'question', 'answers'],
|
43 |
+
num_rows: 79412
|
44 |
+
})
|
45 |
+
test: Dataset({
|
46 |
+
features: ['id', 'title', 'context', 'question', 'answers'],
|
47 |
+
num_rows: 19853
|
48 |
+
})
|
49 |
+
validation: Dataset({
|
50 |
+
features: ['id', 'title', 'context', 'question', 'answers'],
|
51 |
+
num_rows: 9669
|
52 |
+
})
|
53 |
+
})
|
54 |
+
|
55 |
+
tokenizer = AutoTokenizer.from_pretrained("pdelobelle/robbert-v2-dutch-base")
|
56 |
+
|
57 |
+
from transformers import AutoModelForQuestionAnswering, TrainingArguments, Trainer
|
58 |
+
|
59 |
+
model = AutoModelForQuestionAnswering.from_pretrained("pdelobelle/robbert-v2-dutch-base")
|
60 |
+
training_args = TrainingArguments(
|
61 |
+
output_dir="./qa_model",
|
62 |
+
evaluation_strategy="epoch",
|
63 |
+
learning_rate=2e-5,
|
64 |
+
per_device_train_batch_size=16,
|
65 |
+
per_device_eval_batch_size=16,
|
66 |
+
num_train_epochs=3,
|
67 |
+
weight_decay=0.01,
|
68 |
+
push_to_hub=False,
|
69 |
+
)
|
70 |
+
|
71 |
+
trainer = Trainer(
|
72 |
+
model=model,
|
73 |
+
args=training_args,
|
74 |
+
train_dataset=tokenized_squad["train"],
|
75 |
+
eval_dataset=tokenized_squad["validation"],
|
76 |
+
tokenizer=tokenizer,
|
77 |
+
data_collator=data_collator,
|
78 |
+
)
|
79 |
+
|
80 |
+
trainer.train()
|
81 |
+
[15198/15198 2:57:03, Epoch 3/3]
|
82 |
+
Epoch Training Loss Validation Loss
|
83 |
+
1 1.380700 1.177431
|
84 |
+
2 1.093000 1.052601
|
85 |
+
3 0.849700 1.143632
|
86 |
+
|
87 |
+
TrainOutput(global_step=15198, training_loss=1.1917077029499668, metrics={'train_runtime': 10623.9565,
|
88 |
+
'train_samples_per_second': 22.886, 'train_steps_per_second': 1.431, 'total_flos': 4.764955396486349e+16,
|
89 |
+
'train_loss': 1.1917077029499668, 'epoch': 3.0})
|
90 |
+
|
91 |
+
Trained on Ubuntu with 1080Ti
|