Chua, Vui Seng
commited on
Commit
·
ffc90e9
1
Parent(s):
c67533a
Add collaterals
Browse files- README.md +67 -0
- config.json +115 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- tokenizer.json +0 -0
- tokenizer_config.json +1 -0
- training_args.bin +3 -0
- vocab.txt +0 -0
README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
BERT-base tuned for Squadv1.1 is pruned with movement pruning algorithm in hybrid fashion, i.e. 32x32 block for self-attention layers, per-dimension grain size for ffn layers.
|
| 2 |
+
```
|
| 3 |
+
eval_exact_match = 78.5241
|
| 4 |
+
eval_f1 = 86.4138
|
| 5 |
+
eval_samples = 10784
|
| 6 |
+
```
|
| 7 |
+
This model is a replication of [block pruning paper](https://arxiv.org/abs/2109.04838) with its open-sourced codebase (forked and modified).
|
| 8 |
+
To reproduce this model, pls follow [documentation here](https://github.com/vuiseng9/nn_pruning/blob/reproduce-evaluation/reproduce-eval/readme.md) until step 2.
|
| 9 |
+
|
| 10 |
+
# Eval
|
| 11 |
+
The model can be evaluated out-of-the-box with HF QA example. Note that only pruned self-attention heads are discarded where pruned ffn dimension are sparsified instead of removal. Verified in v4.13
|
| 12 |
+
```bash
|
| 13 |
+
export CUDA_VISIBLE_DEVICES=0
|
| 14 |
+
|
| 15 |
+
OUTDIR=eval-bert-base-squadv1-block-pruning-hybrid
|
| 16 |
+
WORKDIR=transformers/examples/pytorch/question-answering
|
| 17 |
+
cd $WORKDIR
|
| 18 |
+
|
| 19 |
+
nohup python run_qa.py \
|
| 20 |
+
--model_name_or_path vuiseng9/bert-base-squadv1-block-pruning-hybrid \
|
| 21 |
+
--dataset_name squad \
|
| 22 |
+
--do_eval \
|
| 23 |
+
--per_device_eval_batch_size 16 \
|
| 24 |
+
--max_seq_length 384 \
|
| 25 |
+
--doc_stride 128 \
|
| 26 |
+
--overwrite_output_dir \
|
| 27 |
+
--output_dir $OUTDIR 2>&1 | tee $OUTDIR/run.log &
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
If the intent is to observe inference acceleration, the pruned structure in the model must be "cropped"/discarded. Follow the custom setup below.
|
| 31 |
+
```bash
|
| 32 |
+
# OpenVINO/NNCF
|
| 33 |
+
git clone https://github.com/vuiseng9/nncf && cd nncf
|
| 34 |
+
git checkout tld-poc
|
| 35 |
+
git reset --hard 1dec7afe7a4b567c059fcf287ea2c234980fded2
|
| 36 |
+
python setup.py develop
|
| 37 |
+
|
| 38 |
+
# Huggingface Transformers
|
| 39 |
+
git clone https://github.com/vuiseng9/transformers && cd transformers
|
| 40 |
+
git checkout tld-poc
|
| 41 |
+
git reset --hard 10a1e29d84484e48fd106f58957d9ffc89dc43c5
|
| 42 |
+
pip install -e .
|
| 43 |
+
|
| 44 |
+
# Huggingface nn_pruning
|
| 45 |
+
git clone https://github.com/vuiseng9/nn_pruning && cd nn_pruning
|
| 46 |
+
git checkout reproduce-evaluation
|
| 47 |
+
git reset --hard 2d4e196d694c465e43e5fbce6c3836d0a60e1446
|
| 48 |
+
```
|
| 49 |
+
Add ```--optimize_model_before_eval``` during evaluation.
|
| 50 |
+
```bash
|
| 51 |
+
export CUDA_VISIBLE_DEVICES=0
|
| 52 |
+
|
| 53 |
+
OUTDIR=eval-bert-base-squadv1-block-pruning-hybrid-cropped
|
| 54 |
+
WORKDIR=transformers/examples/pytorch/question-answering
|
| 55 |
+
cd $WORKDIR
|
| 56 |
+
|
| 57 |
+
nohup python run_qa.py \
|
| 58 |
+
--model_name_or_path vuiseng9/bert-base-squadv1-block-pruning-hybrid \
|
| 59 |
+
--dataset_name squad \
|
| 60 |
+
--optimize_model_before_eval \
|
| 61 |
+
--do_eval \
|
| 62 |
+
--per_device_eval_batch_size 16 \
|
| 63 |
+
--max_seq_length 384 \
|
| 64 |
+
--doc_stride 128 \
|
| 65 |
+
--overwrite_output_dir \
|
| 66 |
+
--output_dir $OUTDIR 2>&1 | tee $OUTDIR/run.log &
|
| 67 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "bert-base-uncased",
|
| 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": 768,
|
| 12 |
+
"initializer_range": 0.02,
|
| 13 |
+
"intermediate_size": 3072,
|
| 14 |
+
"layer_norm_eps": 1e-12,
|
| 15 |
+
"max_position_embeddings": 512,
|
| 16 |
+
"model_type": "bert",
|
| 17 |
+
"num_attention_heads": 12,
|
| 18 |
+
"num_hidden_layers": 12,
|
| 19 |
+
"pad_token_id": 0,
|
| 20 |
+
"position_embedding_type": "absolute",
|
| 21 |
+
"pruned_heads": {
|
| 22 |
+
"0": [
|
| 23 |
+
0,
|
| 24 |
+
2,
|
| 25 |
+
4,
|
| 26 |
+
5,
|
| 27 |
+
6,
|
| 28 |
+
7,
|
| 29 |
+
11
|
| 30 |
+
],
|
| 31 |
+
"1": [
|
| 32 |
+
0,
|
| 33 |
+
2,
|
| 34 |
+
3,
|
| 35 |
+
5,
|
| 36 |
+
6,
|
| 37 |
+
7,
|
| 38 |
+
8
|
| 39 |
+
],
|
| 40 |
+
"2": [
|
| 41 |
+
8,
|
| 42 |
+
4,
|
| 43 |
+
7
|
| 44 |
+
],
|
| 45 |
+
"3": [
|
| 46 |
+
2,
|
| 47 |
+
4,
|
| 48 |
+
6
|
| 49 |
+
],
|
| 50 |
+
"4": [
|
| 51 |
+
1,
|
| 52 |
+
2,
|
| 53 |
+
11
|
| 54 |
+
],
|
| 55 |
+
"5": [
|
| 56 |
+
1,
|
| 57 |
+
2,
|
| 58 |
+
5,
|
| 59 |
+
6,
|
| 60 |
+
7,
|
| 61 |
+
11
|
| 62 |
+
],
|
| 63 |
+
"6": [
|
| 64 |
+
0,
|
| 65 |
+
2,
|
| 66 |
+
3,
|
| 67 |
+
7,
|
| 68 |
+
10
|
| 69 |
+
],
|
| 70 |
+
"7": [
|
| 71 |
+
1,
|
| 72 |
+
3,
|
| 73 |
+
6,
|
| 74 |
+
7,
|
| 75 |
+
11
|
| 76 |
+
],
|
| 77 |
+
"8": [
|
| 78 |
+
0,
|
| 79 |
+
3,
|
| 80 |
+
4,
|
| 81 |
+
5,
|
| 82 |
+
8
|
| 83 |
+
],
|
| 84 |
+
"9": [
|
| 85 |
+
1,
|
| 86 |
+
3,
|
| 87 |
+
4,
|
| 88 |
+
5,
|
| 89 |
+
7,
|
| 90 |
+
9,
|
| 91 |
+
10
|
| 92 |
+
],
|
| 93 |
+
"10": [
|
| 94 |
+
1,
|
| 95 |
+
4,
|
| 96 |
+
5,
|
| 97 |
+
6,
|
| 98 |
+
7,
|
| 99 |
+
8
|
| 100 |
+
],
|
| 101 |
+
"11": [
|
| 102 |
+
4,
|
| 103 |
+
5,
|
| 104 |
+
7,
|
| 105 |
+
8,
|
| 106 |
+
10,
|
| 107 |
+
11
|
| 108 |
+
]
|
| 109 |
+
},
|
| 110 |
+
"torch_dtype": "float32",
|
| 111 |
+
"transformers_version": "4.10.3",
|
| 112 |
+
"type_vocab_size": 2,
|
| 113 |
+
"use_cache": true,
|
| 114 |
+
"vocab_size": 30522
|
| 115 |
+
}
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:895559c3ab4ac710f1747e5a3d2b5a45fa34edc8975bd9843f3d5960588f05b6
|
| 3 |
+
size 386062513
|
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.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
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, "model_max_length": 512, "special_tokens_map_file": null, "name_or_path": "bert-base-uncased", "tokenizer_class": "BertTokenizer"}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f8baa4f88c06c0a3ab896b378e9ac834751b6b68df585f523ea3489516f5fecd
|
| 3 |
+
size 2927
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|