ekurtic commited on
Commit
2d63670
1 Parent(s): f3f94a1

Initial commit

Browse files
README.md ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BERT-mini model finetuned with M-FAC
2
+
3
+ This model is finetuned on SQuAD version 2 dataset with state-of-the-art second-order optimizer M-FAC.
4
+ Check NeurIPS 2021 paper for more details on M-FAC: [https://arxiv.org/pdf/2107.03356.pdf](https://arxiv.org/pdf/2107.03356.pdf).
5
+
6
+ ## Finetuning setup
7
+
8
+ For fair comparison against default Adam baseline, we finetune the model in the same framework as described here [https://github.com/huggingface/transformers/tree/master/examples/pytorch/question-answering](https://github.com/huggingface/transformers/tree/master/examples/pytorch/question-answering) and just swap Adam optimizer with M-FAC.
9
+ Hyperparameters used by M-FAC optimizer:
10
+
11
+ ```bash
12
+ learning rate = 1e-4
13
+ number of gradients = 1024
14
+ dampening = 1e-6
15
+ ```
16
+
17
+ ## Results
18
+
19
+ We share the best model out of 5 runs with the following score on SQuAD version 2 validation set:
20
+
21
+ ```bash
22
+ exact_match = 58.38
23
+ f1 = 61.65
24
+ ```
25
+
26
+ Mean and standard deviation for 5 runs on SQuAD version 2 validation set:
27
+ | | Exact Match | F1 |
28
+ |:----:|:-----------:|:----:|
29
+ | Adam | 54.80 ± 0.47 | 58.13 ± 0.31 |
30
+ | M-FAC | 58.02 ± 0.39 | 61.35 ± 0.24 |
31
+
32
+ Results can be reproduced by adding M-FAC optimizer code in [https://github.com/huggingface/transformers/blob/master/examples/pytorch/question-answering/run_qa.py](https://github.com/huggingface/transformers/blob/master/examples/pytorch/question-answering/run_qa.py) and running the following bash script:
33
+
34
+ ```bash
35
+ CUDA_VISIBLE_DEVICES=0 python run_qa.py \
36
+ --seed 8276 \
37
+ --model_name_or_path prajjwal1/bert-mini \
38
+ --dataset_name squad_v2 \
39
+ --version_2_with_negative \
40
+ --do_train \
41
+ --do_eval \
42
+ --per_device_train_batch_size 12 \
43
+ --learning_rate 1e-4 \
44
+ --num_train_epochs 2 \
45
+ --max_seq_length 384 \
46
+ --doc_stride 128 \
47
+ --output_dir out_dir/ \
48
+ --optim MFAC \
49
+ --optim_args '{"lr": 1e-4, "num_grads": 1024, "damp": 1e-6}'
50
+ ```
51
+
52
+ We believe these results could be improved with modest tuning of hyperparameters: `per_device_train_batch_size`, `learning_rate`, `num_train_epochs`, `num_grads` and `damp`. For the sake of fair comparison and a robust default setup we use the same hyperparameters across all models (`bert-tiny`, `bert-mini`) and all datasets (SQuAD version 2 and GLUE).
53
+
54
+ ## BibTeX entry and citation info
55
+
56
+ ```bibtex
57
+ @article{DBLP:journals/corr/abs-2107-03356,
58
+ author = {Elias Frantar and
59
+ Eldar Kurtic and
60
+ Dan Alistarh},
61
+ title = {Efficient Matrix-Free Approximations of Second-Order Information,
62
+ with Applications to Pruning and Optimization},
63
+ journal = {CoRR},
64
+ volume = {abs/2107.03356},
65
+ year = {2021},
66
+ url = {https://arxiv.org/abs/2107.03356},
67
+ eprinttype = {arXiv},
68
+ eprint = {2107.03356},
69
+ timestamp = {Tue, 20 Jul 2021 15:08:33 +0200},
70
+ biburl = {https://dblp.org/rec/journals/corr/abs-2107-03356.bib},
71
+ bibsource = {dblp computer science bibliography, https://dblp.org}
72
+ }
73
+
74
+ ```
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "prajjwal1/bert-mini",
3
+ "architectures": [
4
+ "BertForQuestionAnswering"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 256,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 1024,
14
+ "layer_norm_eps": 1e-12,
15
+ "max_position_embeddings": 512,
16
+ "model_type": "bert",
17
+ "num_attention_heads": 4,
18
+ "num_hidden_layers": 4,
19
+ "pad_token_id": 0,
20
+ "position_embedding_type": "absolute",
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.10.0.dev0",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 30522
26
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:559be2ea2fa2f4cb165ef321721d1460141e2da9fc4e95c2c58bd61196cf949d
3
+ size 44453133
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"do_lower_case": true, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "special_tokens_map_file": null, "name_or_path": "prajjwal1/bert-mini", "do_basic_tokenize": true, "never_split": null, "tokenizer_class": "BertTokenizer"}
vocab.txt ADDED
The diff for this file is too large to render. See raw diff