-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun_senticse_linear_probe.sh
63 lines (57 loc) · 1.86 KB
/
run_senticse_linear_probe.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
MODEL_NAME=$1
DATA_FILE=$2
TRAIN_EPOCH=$3
BATCH_SIZE=$4
LR=$5
MERTRIC=$6
EVAL_STEP=$7
TASK_NAME=$8
MLM_WEIGHT=${9}
POSIIVE_RATIO=${10}
INBATCH_RATIO=${11}
NEGATIVE_RATIO=${12}
HARD_NEG_RATION=${13}
DIAGONAL=${14}
PPNN=${15}
SAVE_NAME=${16}
GRAD_ACCM=${17}
DATA_FILE_DIR="data/$DATA_FILE"
OUTPUT_DIR="./result/$SAVE_NAME-$TASK_NAME-$MODEL_NAME-e$TRAIN_EPOCH-b$BATCH_SIZE-lr$LR"
# In this example, we show how to use trained SentiCSE in linear probing using multiple GPU cards and PyTorch's distributed data parallel on MR dataset.
# Set how many GPUs to use
NUM_GPU=4
# Randomly set a port number
# If you encounter "address already used" error, just run again or manually set an available port id.
PORT_ID=$(expr $RANDOM + 1000)
# Allow multiple threads
export OMP_NUM_THREADS=96
# Use distributed data parallel
# If you only want to use one card, uncomment the following line and comment the line with "torch.distributed.launch"
# python senticse.py \
python -m torch.distributed.launch --nproc_per_node $NUM_GPU --master_port $PORT_ID senticse.py \
--model_name_or_path ${MODEL_NAME} \
--train_file ${DATA_FILE_DIR} \
--output_dir ${OUTPUT_DIR} \
--num_train_epochs $(expr ${TRAIN_EPOCH}) \
--per_device_train_batch_size $(expr ${BATCH_SIZE}) \
--learning_rate $(expr ${LR}) \
--max_seq_length 128 \
--evaluation_strategy steps \
--metric_for_best_model ${MERTRIC} \
--load_best_model_at_end \
--eval_steps $(expr ${EVAL_STEP}) \
--gradient_accumulation_steps ${GRAD_ACCM} \
--pooler_type cls \
--overwrite_output_dir \
--temp 0.05 \
--do_eval \
--fp16 \
--mlm_weight ${MLM_WEIGHT} \
--positive_weight ${POSIIVE_RATIO} \
--inbatch_weight ${INBATCH_RATIO} \
--negative_weight ${NEGATIVE_RATIO} \
--hard_neg_weight ${HARD_NEG_RATION} \
--diagnoal ${DIAGONAL} \
--ppnn ${PPNN} \
"$@"