Update README.md
Browse files
README.md
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
### Model
|
2 |
+
**[`albert-xlarge-v2`](https://huggingface.co/albert-xlarge-v2)** fine-tuned on **[`SQuAD V2`](https://rajpurkar.github.io/SQuAD-explorer/)** using **[`run_squad.py`](https://github.com/huggingface/transformers/blob/master/examples/run_squad.py)**
|
3 |
+
|
4 |
+
### Training Parameters
|
5 |
+
Trained on 4 NVIDIA GeForce RTX 2080 Ti 11Gb
|
6 |
+
```bash
|
7 |
+
BASE_MODEL=albert-xlarge-v2
|
8 |
+
python run_squad.py \
|
9 |
+
--version_2_with_negative \
|
10 |
+
--model_type albert \
|
11 |
+
--model_name_or_path $BASE_MODEL \
|
12 |
+
--output_dir $OUTPUT_MODEL \
|
13 |
+
--do_eval \
|
14 |
+
--do_lower_case \
|
15 |
+
--train_file $SQUAD_DIR/train-v2.0.json \
|
16 |
+
--predict_file $SQUAD_DIR/dev-v2.0.json \
|
17 |
+
--per_gpu_train_batch_size 3 \
|
18 |
+
--per_gpu_eval_batch_size 64 \
|
19 |
+
--learning_rate 3e-5 \
|
20 |
+
--num_train_epochs 3.0 \
|
21 |
+
--max_seq_length 384 \
|
22 |
+
--doc_stride 128 \
|
23 |
+
--save_steps 2000 \
|
24 |
+
--threads 24 \
|
25 |
+
--warmup_steps 814 \
|
26 |
+
--gradient_accumulation_steps 4 \
|
27 |
+
--fp16 \
|
28 |
+
--do_train
|
29 |
+
```
|
30 |
+
|
31 |
+
### Evaluation
|
32 |
+
|
33 |
+
Evaluation on the dev set. I did not sweep for best threshold.
|
34 |
+
|
35 |
+
| | val |
|
36 |
+
|-------------------|-------------------|
|
37 |
+
| exact | 84.41842836688285 |
|
38 |
+
| f1 | 87.4628460501696 |
|
39 |
+
| total | 11873.0 |
|
40 |
+
| HasAns_exact | 80.68488529014844 |
|
41 |
+
| HasAns_f1 | 86.78245127423482 |
|
42 |
+
| HasAns_total | 5928.0 |
|
43 |
+
| NoAns_exact | 88.1412952060555 |
|
44 |
+
| NoAns_f1 | 88.1412952060555 |
|
45 |
+
| NoAns_total | 5945.0 |
|
46 |
+
| best_exact | 84.41842836688285 |
|
47 |
+
| best_exact_thresh | 0.0 |
|
48 |
+
| best_f1 | 87.46284605016956 |
|
49 |
+
| best_f1_thresh | 0.0 |
|
50 |
+
|
51 |
+
|
52 |
+
### Usage
|
53 |
+
|
54 |
+
See [huggingface documentation](https://huggingface.co/transformers/model_doc/albert.html#albertforquestionanswering). Training on `SQuAD V2` allows the model to score if a paragraph contains an answer:
|
55 |
+
```python
|
56 |
+
start_scores, end_scores = model(input_ids)
|
57 |
+
span_scores = start_scores.softmax(dim=1).log()[:,:,None] + end_scores.softmax(dim=1).log()[:,None,:]
|
58 |
+
ignore_score = span_scores[:,0,0] #no answer scores
|
59 |
+
|
60 |
+
```
|