run_predict.sh 1.9 KB
Newer Older
H
Hongyu Li 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/usr/bin/env bash
# ==============================================================================
# Copyright 2017 Baidu.com, Inc. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

set -xe

H
Hongyu Li 已提交
20 21 22
export FLAGS_sync_nccl_allreduce=0
export FLAGS_eager_delete_tensor_gb=1

H
Hongyu Li 已提交
23 24 25 26
# set CUDA_VISIBLE_DEVICES
export CUDA_VISIBLE_DEVICES=0

# path of pre_train model
H
Hongyu Li 已提交
27
ERNIE_BASE_PATH=ernie_model
H
Hongyu Li 已提交
28 29 30 31 32 33 34 35 36 37 38 39
# path to save checkpoint
CHECKPOINT_PATH=output/
mkdir -p $CHECKPOINT_PATH
# path of init_checkpoint
PATH_init_checkpoint=$1
# path of dev data
DATA_PATH_dev=data/dev

# fine-tune params
python -u src/run_mrqa.py --use_cuda true\
        --batch_size 8 \
        --in_tokens false \
H
Hongyu Li 已提交
40
        --init_pretraining_params ${ERNIE_BASE_PATH}/params \
H
Hongyu Li 已提交
41 42
        --init_checkpoint ${PATH_init_checkpoint} \
        --checkpoints ${CHECKPOINT_PATH} \
H
Hongyu Li 已提交
43
        --vocab_path ${ERNIE_BASE_PATH}/vocab.txt \
H
Hongyu Li 已提交
44 45 46 47 48 49 50
        --do_train false \
        --do_predict true \
        --save_steps 10000 \
        --warmup_proportion 0.1 \
        --weight_decay  0.01 \
        --epoch 2 \
        --max_seq_len 512 \
H
Hongyu Li 已提交
51
        --bert_config_path ${ERNIE_BASE_PATH}/bert_config.json \
H
Hongyu Li 已提交
52 53 54 55 56 57
        --predict_file ${DATA_PATH_dev}/mrqa-combined.raw.json \
        --do_lower_case true \
        --doc_stride 128 \
        --learning_rate 3e-5 \
        --lr_scheduler linear_warmup_decay \
        --skip_steps 200