Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42961f9
commit 3d8e09a
Showing
5 changed files
with
134 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
baselines/models_pytorch/classifier_pytorch/run_classifier_ocnli.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/usr/bin/env bash | ||
# @Author: bo.shi | ||
# @Date: 2019-11-04 09:56:36 | ||
# @Last Modified by: bo.shi | ||
# @Last Modified time: 2020-01-01 11:40:23 | ||
|
||
TASK_NAME="ocnli" | ||
MODEL_NAME="bert-base-chinese" | ||
CURRENT_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P) | ||
export CUDA_VISIBLE_DEVICES="0" | ||
export BERT_PRETRAINED_MODELS_DIR=$CURRENT_DIR/prev_trained_model | ||
export BERT_WWM_DIR=$BERT_PRETRAINED_MODELS_DIR/$MODEL_NAME | ||
export GLUE_DATA_DIR=$CURRENT_DIR/CLUEdatasets | ||
|
||
# download and unzip dataset | ||
if [ ! -d $GLUE_DATA_DIR ]; then | ||
mkdir -p $GLUE_DATA_DIR | ||
echo "makedir $GLUE_DATA_DIR" | ||
fi | ||
cd $GLUE_DATA_DIR | ||
if [ ! -d $TASK_NAME ]; then | ||
mkdir $TASK_NAME | ||
echo "makedir $GLUE_DATA_DIR/$TASK_NAME" | ||
fi | ||
cd $TASK_NAME | ||
if [ ! -f "train.json" ] || [ ! -f "dev.json" ] || [ ! -f "test.json" ]; then | ||
rm * | ||
wget https://storage.googleapis.com/cluebenchmark/tasks/cmnli_public.zip | ||
unzip cmnli_public.zip | ||
rm cmnli_public.zip | ||
else | ||
echo "data exists" | ||
fi | ||
echo "Finish download dataset." | ||
|
||
# make output dir | ||
if [ ! -d $CURRENT_DIR/${TASK_NAME}_output ]; then | ||
mkdir -p $CURRENT_DIR/${TASK_NAME}_output | ||
echo "makedir $CURRENT_DIR/${TASK_NAME}_output" | ||
fi | ||
|
||
# run task | ||
cd $CURRENT_DIR | ||
echo "Start running..." | ||
if [ $# == 0 ]; then | ||
python run_classifier.py \ | ||
--model_type=bert \ | ||
--model_name_or_path=$MODEL_NAME \ | ||
--task_name=$TASK_NAME \ | ||
--do_train \ | ||
--do_eval \ | ||
--do_lower_case \ | ||
--data_dir=$GLUE_DATA_DIR/${TASK_NAME}/ \ | ||
--max_seq_length=128 \ | ||
--per_gpu_train_batch_size=16 \ | ||
--per_gpu_eval_batch_size=16 \ | ||
--learning_rate=3e-5 \ | ||
--num_train_epochs=2.0 \ | ||
--logging_steps=24487 \ | ||
--save_steps=24487 \ | ||
--output_dir=$CURRENT_DIR/${TASK_NAME}_output/ \ | ||
--overwrite_output_dir \ | ||
--seed=42 | ||
elif [ $1 == "predict" ]; then | ||
echo "Start predict..." | ||
python run_classifier.py \ | ||
--model_type=bert \ | ||
--model_name_or_path=$MODEL_NAME \ | ||
--task_name=$TASK_NAME \ | ||
--do_predict \ | ||
--do_lower_case \ | ||
--data_dir=$GLUE_DATA_DIR/${TASK_NAME}/ \ | ||
--max_seq_length=128 \ | ||
--per_gpu_train_batch_size=16 \ | ||
--per_gpu_eval_batch_size=16 \ | ||
--learning_rate=3e-5 \ | ||
--num_train_epochs=2.0 \ | ||
--logging_steps=24487 \ | ||
--save_steps=24487 \ | ||
--output_dir=$CURRENT_DIR/${TASK_NAME}_output/ \ | ||
--overwrite_output_dir \ | ||
--seed=42 | ||
fi | ||
|
||
|