Views
No views yet
vuiseng9/bert-base-squadv1-block-pruning-hybrid-filled-lt using OpenVINO/NNCF. Applied optimization includes:bert-large-uncased-whole-word-masking-finetuned-squad eval_exact_match = 80.2081
eval_f1 = 87.5921
eval_samples = 107841# OpenVINO/NNCF
2git clone https://github.com/vuiseng9/nncf && cd nncf
3git checkout tld-poc
4git reset --hard 1dec7afe7a4b567c059fcf287ea2c234980fded2
5python setup.py develop
6pip install -r examples/torch/requirements.txt
7
8# Huggingface nn_pruning
9git clone https://github.com/vuiseng9/nn_pruning && cd nn_pruning
10git checkout reproduce-evaluation
11git reset --hard 2d4e196d694c465e43e5fbce6c3836d0a60e1446
12pip install -e ".[dev]"
13
14# Huggingface Transformers
15git clone https://github.com/vuiseng9/transformers && cd transformers
16git checkout tld-poc
17git reset --hard 10a1e29d84484e48fd106f58957d9ffc89dc43c5
18pip install -e .
19head -n 1 examples/pytorch/question-answering/requirements.txt | xargs -i pip install {}
20
21# Additional dependencies
22pip install onnx1git clone https://huggingface.co/vuiseng9/bert-base-squadv1-block-pruning-hybrid-filled-lt
2BASE_MODEL=/path/to/cloned_repo_above #to-revise
3
4wget https://huggingface.co/vuiseng9/bert-base-squadv1-block-pruning-hybrid-filled-lt-nncf-50.0sparse-qat-lt/raw/main/nncf_bert_squad_sparsity.json
5NNCF_CFG=/path/to/downloaded_nncf_cfg_above #to-revise
6
7OUTROOT=/path/to/train_output_root #to-revise
8WORKDIR=transformers/examples/pytorch/question-answering #to-revise
9RUNID=bert-base-squadv1-block-pruning-hybrid-filled-lt-nncf-50.0sparse-qat-lt
10
11cd $WORKDIR
12
13OUTDIR=$OUTROOT/$RUNID
14mkdir -p $OUTDIR
15
16export CUDA_VISIBLE_DEVICES=0
17NEPOCH=5
18
19python run_qa.py \
20 --model_name_or_path vuiseng9/bert-base-squadv1-block-pruning-hybrid \
21 --optimize_model_before_eval \
22 --optimized_checkpoint $BASE_MODEL \
23 --dataset_name squad \
24 --do_eval \
25 --do_train \
26 --evaluation_strategy steps \
27 --eval_steps 250 \
28 --learning_rate 3e-5 \
29 --lr_scheduler_type cosine_with_restarts \
30 --warmup_ratio 0.25 \
31 --cosine_cycles 1 \
32 --teacher bert-large-uncased-whole-word-masking-finetuned-squad \
33 --teacher_ratio 0.9 \
34 --num_train_epochs $NEPOCH \
35 --per_device_eval_batch_size 128 \
36 --per_device_train_batch_size 16 \
37 --max_seq_length 384 \
38 --doc_stride 128 \
39 --save_steps 250 \
40 --nncf_config $NNCF_CFG \
41 --logging_steps 1 \
42 --overwrite_output_dir \
43 --run_name $RUNID \
44 --output_dir $OUTDIR1git clone https://huggingface.co/vuiseng9/bert-base-squadv1-block-pruning-hybrid-filled-lt-nncf-50.0sparse-qat-lt
2MODELROOT=/path/to/cloned_repo_above #to-revise
3
4export CUDA_VISIBLE_DEVICES=0
5
6OUTDIR=eval-bert-base-squadv1-block-pruning-hybrid-filled-lt-nncf-50.0sparse-qat-lt
7WORKDIR=transformers/examples/pytorch/question-answering #to-revise
8cd $WORKDIR
9mkdir $OUTDIR
10
11nohup python run_qa.py \
12 --model_name_or_path vuiseng9/bert-base-squadv1-block-pruning-hybrid \
13 --dataset_name squad \
14 --optimize_model_before_eval \
15 --qat_checkpoint $MODELROOT/checkpoint-26250 \
16 --nncf_config $MODELROOT/nncf_bert_squad_sparsity.json \
17 --to_onnx $OUTDIR/bert-base-squadv1-block-pruning-hybrid-filled-lt-nncf-50.0sparse-qat-lt.onnx \
18 --do_eval \
19 --per_device_eval_batch_size 128 \
20 --max_seq_length 384 \
21 --doc_stride 128 \
22 --overwrite_output_dir \
23 --output_dir $OUTDIR 2>&1 | tee $OUTDIR/run.log &