ekurtic commited on
Commit
9a7641b
1 Parent(s): e8efc6e

Initial commit

Browse files
README.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BERT-mini model finetuned with M-FAC
2
+
3
+ This model is finetuned on SST-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/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 SST-2 validation set:
20
+
21
+ ```bash
22
+ accuracy = 84.74
23
+ ```
24
+
25
+ Mean and standard deviation for 5 runs on SST-2 validation set:
26
+ | | Accuracy |
27
+ |:----:|:-----------:|
28
+ | Adam | 85.46 ± 0.58 |
29
+ | M-FAC | 84.20 ± 0.58 |
30
+
31
+ 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:
32
+
33
+ ```bash
34
+ CUDA_VISIBLE_DEVICES=0 python run_glue.py \
35
+ --seed 1234 \
36
+ --model_name_or_path prajjwal1/bert-mini \
37
+ --task_name sst2 \
38
+ --do_train \
39
+ --do_eval \
40
+ --max_seq_length 128 \
41
+ --per_device_train_batch_size 32 \
42
+ --learning_rate 1e-4 \
43
+ --num_train_epochs 3 \
44
+ --output_dir out_dir/ \
45
+ --optim MFAC \
46
+ --optim_args '{"lr": 1e-4, "num_grads": 1024, "damp": 1e-6}'
47
+ ```
48
+
49
+ 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).
50
+
51
+ ## BibTeX entry and citation info
52
+
53
+ ```bibtex
54
+ @article{DBLP:journals/corr/abs-2107-03356,
55
+ author = {Elias Frantar and
56
+ Eldar Kurtic and
57
+ Dan Alistarh},
58
+ title = {Efficient Matrix-Free Approximations of Second-Order Information,
59
+ with Applications to Pruning and Optimization},
60
+ journal = {CoRR},
61
+ volume = {abs/2107.03356},
62
+ year = {2021},
63
+ url = {https://arxiv.org/abs/2107.03356},
64
+ eprinttype = {arXiv},
65
+ eprint = {2107.03356},
66
+ timestamp = {Tue, 20 Jul 2021 15:08:33 +0200},
67
+ biburl = {https://dblp.org/rec/journals/corr/abs-2107-03356.bib},
68
+ bibsource = {dblp computer science bibliography, https://dblp.org}
69
+ }
70
+
71
+ ```
config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "prajjwal1/bert-mini",
3
+ "architectures": [
4
+ "BertForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "finetuning_task": "sst2",
9
+ "gradient_checkpointing": false,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 256,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 1024,
15
+ "layer_norm_eps": 1e-12,
16
+ "max_position_embeddings": 512,
17
+ "model_type": "bert",
18
+ "num_attention_heads": 4,
19
+ "num_hidden_layers": 4,
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:5c5a092f4a73a06e7fce7d4ef49849f095028a723fd4ece5532da8b9212ea605
3
+ size 44717063
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