ekurtic commited on
Commit
f7fe6d9
1 Parent(s): 8ee17e5

Initial commit

Browse files
README.md ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BERT-tiny model finetuned with M-FAC
2
+
3
+ This model is finetuned on QQP 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/text-classification](https://github.com/huggingface/transformers/tree/master/examples/pytorch/text-classification) 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 QQP validation set:
20
+
21
+ ```bash
22
+ f1 = 79.84
23
+ accuracy = 84.40
24
+ ```
25
+
26
+ Mean and standard deviation for 5 runs on QQP validation set:
27
+ | | F1 | Accuracy |
28
+ |:----:|:-----------:|:----------:|
29
+ | Adam | 77.58 ± 0.08 | 81.09 ± 0.15 |
30
+ | M-FAC | 79.71 ± 0.13 | 84.29 ± 0.08 |
31
+
32
+ Results can be reproduced by adding M-FAC optimizer code in [https://github.com/huggingface/transformers/blob/master/examples/pytorch/text-classification/run_glue.py](https://github.com/huggingface/transformers/blob/master/examples/pytorch/text-classification/run_glue.py) and running the following bash script:
33
+
34
+ ```bash
35
+ CUDA_VISIBLE_DEVICES=0 python run_glue.py \
36
+ --seed 1234 \
37
+ --model_name_or_path prajjwal1/bert-tiny \
38
+ --task_name qqp \
39
+ --do_train \
40
+ --do_eval \
41
+ --max_seq_length 128 \
42
+ --per_device_train_batch_size 32 \
43
+ --learning_rate 1e-4 \
44
+ --num_train_epochs 5 \
45
+ --output_dir out_dir/ \
46
+ --optim MFAC \
47
+ --optim_args '{"lr": 1e-4, "num_grads": 1024, "damp": 1e-6}'
48
+ ```
49
+
50
+ 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).
51
+
52
+ ## BibTeX entry and citation info
53
+
54
+ ```bibtex
55
+ @article{DBLP:journals/corr/abs-2107-03356,
56
+ author = {Elias Frantar and
57
+ Eldar Kurtic and
58
+ Dan Alistarh},
59
+ title = {Efficient Matrix-Free Approximations of Second-Order Information,
60
+ with Applications to Pruning and Optimization},
61
+ journal = {CoRR},
62
+ volume = {abs/2107.03356},
63
+ year = {2021},
64
+ url = {https://arxiv.org/abs/2107.03356},
65
+ eprinttype = {arXiv},
66
+ eprint = {2107.03356},
67
+ timestamp = {Tue, 20 Jul 2021 15:08:33 +0200},
68
+ biburl = {https://dblp.org/rec/journals/corr/abs-2107-03356.bib},
69
+ bibsource = {dblp computer science bibliography, https://dblp.org}
70
+ }
71
+
72
+ ```
config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "prajjwal1/bert-tiny",
3
+ "architectures": [
4
+ "BertForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "finetuning_task": "qqp",
9
+ "gradient_checkpointing": false,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 128,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 512,
15
+ "layer_norm_eps": 1e-12,
16
+ "max_position_embeddings": 512,
17
+ "model_type": "bert",
18
+ "num_attention_heads": 2,
19
+ "num_hidden_layers": 2,
20
+ "pad_token_id": 0,
21
+ "position_embedding_type": "absolute",
22
+ "problem_type": "single_label_classification",
23
+ "torch_dtype": "float32",
24
+ "transformers_version": "4.10.0.dev0",
25
+ "type_vocab_size": 2,
26
+ "use_cache": true,
27
+ "vocab_size": 30522
28
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7dcb0b1610336e8a44671f28011e06e8ebf43b9137cb2d41b60378aa3cde2eaa
3
+ size 17564583
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-tiny", "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