yasuokaの日記: hiroshi-matsuda-rit/electra-base-japanese-discriminator-v2をJCommonSenseQAでチューニング
hiroshi-matsuda-rit/electra-base-japanese-discriminator-v2がリリースされていたので、JGLUEのJCommonSenseQAでファインチューニングしてみた。Google Colaboratory (GPU版)だと、こんな感じ。
trf="transformers-4.28.1"
!test -d {trf} || git clone -b {trf.replace("transformers-","v")} --depth=1 https://github.com/huggingface/transformers {trf}
!test -d JGLUE || ( git clone --depth=1 https://github.com/yahoojapan/JGLUE && cat JGLUE/fine-tuning/patch/transformers-4.9.2_jglue-1.1.0.patch | ( cd {trf} && patch -p1 ) )
!cd {trf} && pip install .
!pip install -r {trf}/examples/pytorch/text-classification/requirements.txt
!pip install protobuf==3.20.3 tensorboard sudachitra
f=trf+"/examples/pytorch/multiple-choice/run_swag.py"
!fgrep trust_remote_code {f} || ( echo '%s/use_fast=.*,/& trust_remote_code=True,/' ; echo wq ) | ex -s {f}
!python {f} --model_name_or_path hiroshi-matsuda-rit/electra-base-japanese-discriminator-v2 --do_train --do_eval --do_predict --max_seq_length 64 --per_device_train_batch_size 16 --learning_rate 5e-05 --num_train_epochs 4 --output_dir ./electra-base-japanese-discriminator-v2-jcommonsenseqa --overwrite_output_dir --train_file JGLUE/datasets/jcommonsenseqa-*/train-*.json --validation_file JGLUE/datasets/jcommonsenseqa-*/valid-*.json --test_file JGLUE/datasets/jcommonsenseqa-*/valid-*.json --use_fast_tokenizer False --evaluation_strategy epoch --warmup_ratio 0.1
trust_remote_code=Trueがトリッキーだが、GPU版なら20分ほどでelectra-base-japanese-discriminator-v2-jcommonsenseqaが出来上がる。私(安岡孝一)の手元では、以下の「eval metrics」が出力された。
***** eval metrics *****
epoch = 4.0
eval_accuracy = 0.8338
eval_loss = 0.6194
eval_runtime = 0:00:08.82
eval_samples = 1119
eval_samples_per_second = 126.832
eval_steps_per_second = 15.868
JCommonSenseQAが0.8338なので、ku-nlp/deberta-v2-base-japaneseにあと一息だ。electraでここまで出るって、すごいなあ。
hiroshi-matsuda-rit/electra-base-japanese-discriminator-v2をJCommonSenseQAでチューニング More ログイン