Skip to content
Snippets Groups Projects
Commit 13c6859f authored by zhouneng2's avatar zhouneng2
Browse files

[bert]add command line argument 'DEVICE_ID' for shell script

parent e5b9a69d
No related branches found
No related tags found
No related merge requests found
...@@ -108,19 +108,19 @@ python pretrain_eval.py ...@@ -108,19 +108,19 @@ python pretrain_eval.py
- Set bert network config and optimizer hyperparameters in `task_[DOWNSTREAM_TASK]_config.yaml`. - Set bert network config and optimizer hyperparameters in `task_[DOWNSTREAM_TASK]_config.yaml`.
- Classification task: Set task related hyperparameters in scripts/run_classifier.sh. - Classification task: Set task related hyperparameters in scripts/run_classifier.sh.
- Run `bash scripts/run_classifier.sh` for fine-tuning of BERT-base and BERT-NEZHA model. - Run `bash scripts/run_classifier.sh [DEVICE_ID]` for fine-tuning of BERT-base and BERT-NEZHA model.
bash scripts/run_classifier.sh bash scripts/run_classifier.sh DEVICE_ID(optional)
- NER task: Set task related hyperparameters in scripts/run_ner.sh. - NER task: Set task related hyperparameters in scripts/run_ner.sh.
- Run `bash scripts/run_ner.sh` for fine-tuning of BERT-base and BERT-NEZHA model. - Run `bash scripts/run_ner.sh [DEVICE_ID]` for fine-tuning of BERT-base and BERT-NEZHA model.
bash scripts/run_ner.sh bash scripts/run_ner.sh DEVICE_ID(optional)
- SQuAD task: Set task related hyperparameters in scripts/run_squad.sh. - SQuAD task: Set task related hyperparameters in scripts/run_squad.sh.
- Run `bash scripts/run_squad.sh` for fine-tuning of BERT-base and BERT-NEZHA model. - Run `bash scripts/run_squad.sh [DEVICE_ID]` for fine-tuning of BERT-base and BERT-NEZHA model.
bash scripts/run_squad.sh bash scripts/run_squad.sh DEVICE_ID(optional)
``` ```
- Running on GPU - Running on GPU
...@@ -137,19 +137,19 @@ bash scripts/run_distributed_pretrain_for_gpu.sh 8 40 /path/cn-wiki-128 ...@@ -137,19 +137,19 @@ bash scripts/run_distributed_pretrain_for_gpu.sh 8 40 /path/cn-wiki-128
- Set bert network config and optimizer hyperparameters in `task_[DOWNSTREAM_TASK]_config.yaml`. - Set bert network config and optimizer hyperparameters in `task_[DOWNSTREAM_TASK]_config.yaml`.
- Classification task: Set task related hyperparameters in scripts/run_classifier.sh. - Classification task: Set task related hyperparameters in scripts/run_classifier.sh.
- Run `bash scripts/run_classifier.sh` for fine-tuning of BERT-base and BERT-NEZHA model. - Run `bash scripts/run_classifier.sh [DEVICE_ID]` for fine-tuning of BERT-base and BERT-NEZHA model.
bash scripts/run_classifier.sh bash scripts/run_classifier.sh DEVICE_ID(optional)
- NER task: Set task related hyperparameters in scripts/run_ner.sh. - NER task: Set task related hyperparameters in scripts/run_ner.sh.
- Run `bash scripts/run_ner.sh` for fine-tuning of BERT-base and BERT-NEZHA model. - Run `bash scripts/run_ner.sh [DEVICE_ID]` for fine-tuning of BERT-base and BERT-NEZHA model.
bash scripts/run_ner.sh bash scripts/run_ner.sh DEVICE_ID(optional)
- SQuAD task: Set task related hyperparameters in scripts/run_squad_gpu.sh. - SQuAD task: Set task related hyperparameters in scripts/run_squad_gpu.sh.
- Run `bash scripts/run_squad_gpu.py` for fine-tuning of BERT-base and BERT-NEZHA model. - Run `bash scripts/run_squad_gpu.py [DEVICE_ID]` for fine-tuning of BERT-base and BERT-NEZHA model.
bash scripts/run_squad_gpu.sh bash scripts/run_squad_gpu.sh DEVICE_ID(optional)
``` ```
- running on ModelArts - running on ModelArts
...@@ -688,7 +688,7 @@ python src/finetune_data_preprocess.py --data_dir=/path/msra_dataset.xml --vocab ...@@ -688,7 +688,7 @@ python src/finetune_data_preprocess.py --data_dir=/path/msra_dataset.xml --vocab
For finetune and evaluation, just do For finetune and evaluation, just do
```bash ```bash
bash scripts/run_ner.sh bash scripts/run_ner.sh DEVICE_ID(optional)
``` ```
The command above will run in the background, you can view training logs in ner_log.txt. The command above will run in the background, you can view training logs in ner_log.txt.
......
...@@ -110,19 +110,19 @@ bash scripts/run_distributed_pretrain_ascend.sh /path/cn-wiki-128 /path/hccl.jso ...@@ -110,19 +110,19 @@ bash scripts/run_distributed_pretrain_ascend.sh /path/cn-wiki-128 /path/hccl.jso
- 在`task_[DOWNSTREAM_TASK]_config.yaml`中设置BERT网络配置和优化器超参。 - 在`task_[DOWNSTREAM_TASK]_config.yaml`中设置BERT网络配置和优化器超参。
- 分类任务:在scripts/run_classifier.sh中设置任务相关的超参。 - 分类任务:在scripts/run_classifier.sh中设置任务相关的超参。
- 运行`bash scripts/run_classifier.sh`,对BERT-base和BERT-NEZHA模型进行微调。 - 运行`bash scripts/run_classifier.sh [DEVICE_ID]`,对BERT-base和BERT-NEZHA模型进行微调。
bash scripts/run_classifier.sh bash scripts/run_classifier.sh DEVICE_ID(optional)
- NER任务:在scripts/run_ner.sh中设置任务相关的超参。 - NER任务:在scripts/run_ner.sh中设置任务相关的超参。
- 运行`bash scripts/run_ner.sh`,对BERT-base和BERT-NEZHA模型进行微调。 - 运行`bash scripts/run_ner.sh [DEVICE_ID]`,对BERT-base和BERT-NEZHA模型进行微调。
bash scripts/run_ner.sh bash scripts/run_ner.sh DEVICE_ID(optional)
- SQUAD任务:在scripts/run_squad.sh中设置任务相关的超参。 - SQUAD任务:在scripts/run_squad.sh中设置任务相关的超参。
-运行`bash scripts/run_squad.sh`,对BERT-base和BERT-NEZHA模型进行微调。 -运行`bash scripts/run_squad.sh [DEVICE_ID]`,对BERT-base和BERT-NEZHA模型进行微调。
bash scripts/run_squad.sh bash scripts/run_squad.sh DEVICE_ID(optional)
``` ```
- 在GPU上运行 - 在GPU上运行
...@@ -143,19 +143,19 @@ bash scripts/run_distributed_pretrain_for_gpu.sh 8 40 /path/cn-wiki-128 ...@@ -143,19 +143,19 @@ bash scripts/run_distributed_pretrain_for_gpu.sh 8 40 /path/cn-wiki-128
- 在`task_[DOWNSTREAM_TASK]_config.yaml`中设置BERT网络配置和优化器超参。 - 在`task_[DOWNSTREAM_TASK]_config.yaml`中设置BERT网络配置和优化器超参。
- 分类任务:在scripts/run_classifier.sh中设置任务相关的超参。 - 分类任务:在scripts/run_classifier.sh中设置任务相关的超参。
- 运行`bash scripts/run_classifier.sh`,对BERT-base和BERT-NEZHA模型进行微调。 - 运行`bash scripts/run_classifier.sh [DEVICE_ID]`,对BERT-base和BERT-NEZHA模型进行微调。
bash scripts/run_classifier.sh bash scripts/run_classifier.sh DEVICE_ID(optional)
- NER任务:在scripts/run_ner.sh中设置任务相关的超参。 - NER任务:在scripts/run_ner.sh中设置任务相关的超参。
- 运行`bash scripts/run_ner.sh`,对BERT-base和BERT-NEZHA模型进行微调。 - 运行`bash scripts/run_ner.sh [DEVICE_ID]`,对BERT-base和BERT-NEZHA模型进行微调。
bash scripts/run_ner.sh bash scripts/run_ner.sh DEVICE_ID(optional)
- SQUAD任务:在scripts/run_squad_gpu.sh中设置任务相关的超参。 - SQUAD任务:在scripts/run_squad_gpu.sh中设置任务相关的超参。
-运行`bash scripts/run_squad_gpu.sh`,对BERT-base和BERT-NEZHA模型进行微调。 -运行`bash scripts/run_squad_gpu.sh [DEVICE_ID]`,对BERT-base和BERT-NEZHA模型进行微调。
bash scripts/run_squad_gpu.sh bash scripts/run_squad_gpu.sh DEVICE_ID(optional)
``` ```
- 在ModelArts上运行(如果你想在modelarts上运行,可以参考以下文档 [modelarts](https://support.huaweicloud.com/modelarts/)) - 在ModelArts上运行(如果你想在modelarts上运行,可以参考以下文档 [modelarts](https://support.huaweicloud.com/modelarts/))
......
...@@ -16,11 +16,20 @@ ...@@ -16,11 +16,20 @@
echo "==============================================================================================================" echo "=============================================================================================================="
echo "Please run the script as: " echo "Please run the script as: "
echo "bash scripts/run_classifier.sh" echo "bash scripts/run_classifier.sh DEVICE_ID"
echo "for example: bash scripts/run_classifier.sh" echo "DEVICE_ID is optional, default value is zero"
echo "for example: bash scripts/run_classifier.sh DEVICE_ID 1"
echo "assessment_method include: [MCC, Spearman_correlation ,Accuracy]" echo "assessment_method include: [MCC, Spearman_correlation ,Accuracy]"
echo "==============================================================================================================" echo "=============================================================================================================="
if [ -z $1 ]
then
export DEVICE_ID=0
else
export DEVICE_ID=$1
fi
mkdir -p ms_log mkdir -p ms_log
CUR_DIR=`pwd` CUR_DIR=`pwd`
PROJECT_DIR=$(cd "$(dirname "$0")" || exit; pwd) PROJECT_DIR=$(cd "$(dirname "$0")" || exit; pwd)
...@@ -32,7 +41,7 @@ python ${PROJECT_DIR}/../run_classifier.py \ ...@@ -32,7 +41,7 @@ python ${PROJECT_DIR}/../run_classifier.py \
--do_train="true" \ --do_train="true" \
--do_eval="false" \ --do_eval="false" \
--assessment_method="Accuracy" \ --assessment_method="Accuracy" \
--device_id=0 \ --device_id=$DEVICE_ID \
--epoch_num=3 \ --epoch_num=3 \
--num_class=2 \ --num_class=2 \
--train_data_shuffle="true" \ --train_data_shuffle="true" \
......
...@@ -16,11 +16,19 @@ ...@@ -16,11 +16,19 @@
echo "==============================================================================================================" echo "=============================================================================================================="
echo "Please run the script as: " echo "Please run the script as: "
echo "bash scripts/run_ner.sh" echo "bash scripts/run_ner.sh DEVICE_ID"
echo "for example: bash scripts/run_ner.sh" echo "DEVICE_ID is optional, default value is zero"
echo "for example: bash scripts/run_ner.sh 1"
echo "assessment_method include: [BF1, MF1, clue_benchmark]" echo "assessment_method include: [BF1, MF1, clue_benchmark]"
echo "==============================================================================================================" echo "=============================================================================================================="
if [ -z $1 ]
then
export DEVICE_ID=0
else
export DEVICE_ID=$1
fi
mkdir -p ms_log mkdir -p ms_log
CUR_DIR=`pwd` CUR_DIR=`pwd`
PROJECT_DIR=$(cd "$(dirname "$0")" || exit; pwd) PROJECT_DIR=$(cd "$(dirname "$0")" || exit; pwd)
...@@ -34,7 +42,7 @@ python ${PROJECT_DIR}/../run_ner.py \ ...@@ -34,7 +42,7 @@ python ${PROJECT_DIR}/../run_ner.py \
--assessment_method="BF1" \ --assessment_method="BF1" \
--use_crf="false" \ --use_crf="false" \
--with_lstm="false" \ --with_lstm="false" \
--device_id=0 \ --device_id=$DEVICE_ID \
--epoch_num=5 \ --epoch_num=5 \
--train_data_shuffle="true" \ --train_data_shuffle="true" \
--eval_data_shuffle="false" \ --eval_data_shuffle="false" \
......
...@@ -16,11 +16,19 @@ ...@@ -16,11 +16,19 @@
echo "==============================================================================================================" echo "=============================================================================================================="
echo "Please run the script as: " echo "Please run the script as: "
echo "bash scripts/run_squad.sh" echo "bash scripts/run_squad.sh DEVICE_ID"
echo "for example: bash scripts/run_squad.sh" echo "DEVICE_ID is optional, default value is zero"
echo "for example: bash scripts/run_squad.sh 1"
echo "assessment_method include: [Accuracy]" echo "assessment_method include: [Accuracy]"
echo "==============================================================================================================" echo "=============================================================================================================="
if [ -z $1 ]
then
export DEVICE_ID=0
else
export DEVICE_ID=$1
fi
mkdir -p ms_log mkdir -p ms_log
CUR_DIR=`pwd` CUR_DIR=`pwd`
PROJECT_DIR=$(cd "$(dirname "$0")" || exit; pwd) PROJECT_DIR=$(cd "$(dirname "$0")" || exit; pwd)
...@@ -31,7 +39,7 @@ python ${PROJECT_DIR}/../run_squad.py \ ...@@ -31,7 +39,7 @@ python ${PROJECT_DIR}/../run_squad.py \
--device_target="Ascend" \ --device_target="Ascend" \
--do_train="true" \ --do_train="true" \
--do_eval="false" \ --do_eval="false" \
--device_id=0 \ --device_id=$DEVICE_ID \
--epoch_num=3 \ --epoch_num=3 \
--num_class=2 \ --num_class=2 \
--train_data_shuffle="true" \ --train_data_shuffle="true" \
......
...@@ -16,11 +16,19 @@ ...@@ -16,11 +16,19 @@
echo "==============================================================================================================" echo "=============================================================================================================="
echo "Please run the script as: " echo "Please run the script as: "
echo "bash scripts/run_squad_gpu.sh" echo "bash scripts/run_squad_gpu.sh DEVICE_ID"
echo "for example: bash scripts/run_squad_gpu.sh" echo "DEVICE_ID is optional, default value is zero"
echo "for example: bash scripts/run_squad_gpu.sh 1"
echo "assessment_method include: [Accuracy]" echo "assessment_method include: [Accuracy]"
echo "==============================================================================================================" echo "=============================================================================================================="
if [ -z $1 ]
then
export DEVICE_ID=0
else
export DEVICE_ID=$1
fi
mkdir -p ms_log mkdir -p ms_log
CUR_DIR=`pwd` CUR_DIR=`pwd`
PROJECT_DIR=$(cd "$(dirname "$0")" || exit; pwd) PROJECT_DIR=$(cd "$(dirname "$0")" || exit; pwd)
...@@ -31,7 +39,7 @@ python ${PROJECT_DIR}/../run_squad.py \ ...@@ -31,7 +39,7 @@ python ${PROJECT_DIR}/../run_squad.py \
--device_target="GPU" \ --device_target="GPU" \
--do_train="true" \ --do_train="true" \
--do_eval="false" \ --do_eval="false" \
--device_id=0 \ --device_id=$DEVICE_ID \
--epoch_num=3 \ --epoch_num=3 \
--num_class=2 \ --num_class=2 \
--train_data_shuffle="true" \ --train_data_shuffle="true" \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment