diff --git a/examples/bert/bert_classifier.py b/examples/bert/bert_classifier.py index 472e39b3436bfe9c32a6941bcfeeac6badb82e5f..e3c9726c9a1eb257748e7a8d2fb35e316b7bd80b 100644 --- a/examples/bert/bert_classifier.py +++ b/examples/bert/bert_classifier.py @@ -157,7 +157,7 @@ def main(): labels, device=device) - cls_model.bert_layer.load("./bert_small", reset_optimizer=True) + cls_model.bert_layer.load("./bert_uncased_L-12_H-768_A-12/bert", reset_optimizer=True) # do train cls_model.fit(train_data=train_dataloader.dataloader, diff --git a/examples/bert/readme.md b/examples/bert/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..f8df579ec8302b890f7fb523facc417fc784536a --- /dev/null +++ b/examples/bert/readme.md @@ -0,0 +1,9 @@ +1. download data: wget https://paddle-hapi.bj.bcebos.com/data/bert_data.tar.gz + +2. unzip data: tar -zvxf bert_data.tar.gz + +3. download pretrained parameters: wget https://paddle-hapi.bj.bcebos.com/models/bert_uncased_L-12_H-768_A-12.tar.gz + +4. unzip pretrained parameters: tar -zvxf bert_uncased_L-12_H-768_A-12.tar.gz + +4. bash run_classifier_single_gpu.sh diff --git a/examples/bert/run_classifier_multi_gpu.sh b/examples/bert/run_classifier_multi_gpu.sh new file mode 100755 index 0000000000000000000000000000000000000000..c3800568da786d1dec170d74022443d65f175f66 --- /dev/null +++ b/examples/bert/run_classifier_multi_gpu.sh @@ -0,0 +1,25 @@ +#!/bin/bash +BERT_BASE_PATH="./bert_uncased_L-12_H-768_A-12/" +DATA_PATH="./data/glue_data/MNLI/" +CKPT_PATH="./data/saved_model/mnli_models" + +# start fine-tuning +python3.7 -m paddle.distributed.launch --started_port 8899 --selected_gpus=1,2,3 bert_classifier.py\ + --use_cuda true \ + --do_train true \ + --do_test true \ + --batch_size 64 \ + --data_dir ${DATA_PATH} \ + --vocab_path ${BERT_BASE_PATH}/vocab.txt \ + --checkpoints ${CKPT_PATH} \ + --save_steps 1000 \ + --weight_decay 0.01 \ + --warmup_proportion 0.1 \ + --validation_steps 100 \ + --epoch 3 \ + --max_seq_len 128 \ + --bert_config_path ${BERT_BASE_PATH}/bert_config.json \ + --learning_rate 5e-5 \ + --skip_steps 10 \ + --shuffle true +