Views
No views yet
vuiseng9/bert-base-squadv1-pruneofa-90pc-bt using OpenVINO/NNCF. Applied optimization includes:bert-large-uncased-whole-word-masking-finetuned-squad eval_exact_match = 80.6623
eval_f1 = 87.7147
eval_samples = 107841# OpenVINO/NNCF
2git clone https://github.com/vuiseng9/nncf && cd nncf
3git checkout tld-poc
4git reset --hard 5647610d5ee2bf9f1324604e6579bca1c391e260
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 5dd7402e9a316041dea4ff67508c01047323616e
18pip install -e .
19head -n 1 examples/pytorch/question-answering/requirements.txt | xargs -i pip install {}
20
21# Additional dependencies
22pip install onnx1wget https://huggingface.co/vuiseng9/bert-base-squadv1-pruneofa-90pc-bt-qat-lt/raw/main/nncf_bert_squad_sparsity.json
2NNCF_CFG=/path/to/downloaded_nncf_cfg_above #to-revise
3
4OUTROOT=/path/to/train_output_root #to-revise
5WORKDIR=transformers/examples/pytorch/question-answering #to-revise
6RUNID=bert-base-squadv1-pruneofa-90pc-bt-qat-lt
7
8cd $WORKDIR
9
10OUTDIR=$OUTROOT/$RUNID
11mkdir -p $OUTDIR
12
13export CUDA_VISIBLE_DEVICES=0
14NEPOCH=5
15
16python run_qa.py \
17 --model_name_or_path vuiseng9/bert-base-squadv1-pruneofa-90pc-bt \
18 --pruneofa_qat \
19 --dataset_name squad \
20 --do_eval \
21 --do_train \
22 --evaluation_strategy steps \
23 --eval_steps 250 \
24 --learning_rate 3e-5 \
25 --lr_scheduler_type cosine_with_restarts \
26 --warmup_ratio 0.25 \
27 --cosine_cycles 1 \
28 --teacher bert-large-uncased-whole-word-masking-finetuned-squad \
29 --teacher_ratio 0.9 \
30 --num_train_epochs $NEPOCH \
31 --per_device_eval_batch_size 128 \
32 --per_device_train_batch_size 16 \
33 --max_seq_length 384 \
34 --doc_stride 128 \
35 --save_steps 250 \
36 --nncf_config $NNCF_CFG \
37 --logging_steps 1 \
38 --overwrite_output_dir \
39 --run_name $RUNID \
40 --output_dir $OUTDIR1git clone https://huggingface.co/vuiseng9/bert-base-squadv1-pruneofa-90pc-bt-qat-lt
2MODELROOT=/path/to/cloned_repo_above #to-revise
3
4export CUDA_VISIBLE_DEVICES=0
5
6OUTDIR=eval-bert-base-squadv1-pruneofa-90pc-bt-qat-lt
7WORKDIR=transformers/examples/pytorch/question-answering #to-revise
8cd $WORKDIR
9mkdir $OUTDIR
10
11
12nohup python run_qa.py \
13 --model_name_or_path vuiseng9/bert-base-squadv1-pruneofa-90pc-bt \
14 --dataset_name squad \
15 --qat_checkpoint $MODELROOT/checkpoint-22000 \
16 --nncf_config $MODELROOT/nncf_bert_squad_sparsity.json \
17 --to_onnx $OUTDIR/bert-base-squadv1-pruneofa-90pc-bt-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 &