This repository has been archived by the owner on Dec 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtraining_only.sh
executable file
·99 lines (82 loc) · 3.04 KB
/
training_only.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
export PYTHONPATH=/home/xiejunlin/workspace/Tianchi_FT-Data_Ranker/data-juicer/data_juicer
export DATA_JUICER_CACHE_HOME=/home/xiejunlin/data1/data_juicer
export https_proxy=http://uestc.sylin.host:7890
export http_proxy=http://uestc.sylin.host:7890
export all_proxy=socks5://uestc.sylin.host:7890
export HF_DATASETS_OFFLINE=1
export TRANSFORMERS_OFFLINE=1
CUDA_VISIBLE_DEVICES=0,1,2,3
NOWTIME=$(date "+%Y-%m-%d-%H-%M-%S")
DATA_PATH=data/unieval/unieval_from_v13_2_gt_0_8.jsonl
EXP_NAME=run_unieval_dialog_from_v13_2_gt_0_8
NAME=${EXP_NAME}_en_${NOWTIME}
# NAME=run_all_sigma_v4_llm_sample_gt_4_2023-11-14-21-34-52
OUTPUT_DIR=checkpoints/run/${NAME}
OUTPUT_DATA_PATH=checkpoints/run/${NAME}/data/training_dataset.jsonl
mkdir -p ${OUTPUT_DIR}
cp ./$0 ${OUTPUT_DIR}
echo "[Shell] Running get_train_dataset_1b.py to sample data"
python lm-training/get_train_dataset_1b.py \
--token_nums 3000000 \
--ratio 1.0 \
--en_data_dir ${DATA_PATH} \
--output_files ${OUTPUT_DATA_PATH}
# --zh_data_dir ${OUTPUT_DIR}/data/zh/datasets_zh.jsonl \
cp ${DATA_PATH} ${OUTPUT_DIR}/data
# training model
# set -e
export CUDA_DEVICE_MAX_CONNECTIONS=1
if [ -z $XDG_CACHE_HOME ]; then
export XDG_CACHE_HOME=$HOME/.cache
fi
# Model Path
# e.g /home/model/baichuan2-7b/
# model_path=${1} #/path/to/your/model/
model_path="data/models/falcon-rw-1b" #/path/to/your/model/
tokenizer=${model_path}
# Data Path
# e.g /home/data/train.jsonl
# data_path=${2} # /path/to/your/dataset.jsonl
# data_path="data/test_data/test_en065zh035_1b.jsonl" # /path/to/your/dataset.jsonl
data_path=${OUTPUT_DATA_PATH} # /path/to/your/dataset.jsonl
# Output Path
# e.g ${WORK_DIR}/checkpoints/baichuan2-7b/
output_path=${OUTPUT_DIR} #/path/to/your/output/
mkdir -p ${output_path}/
WORK_DIR=$(echo `cd $(dirname $0); pwd | xargs dirname`)
# cd ${WORK_DIR}
# Deepspeed
ds_config_file=lm-training/train_scripts/deepspeed_configs/ds_config_stage3.json
# Train Parameter
bs_per_gpu=1
num_nodes=1
nproc_per_node=4
master_port=$(shuf -i 32221-65535 -n 1)
echo "[Shell] Running lm-training"
grad_acc=`expr 256 / ${bs_per_gpu} / ${num_nodes} / ${nproc_per_node}`
# deepspeed --num_gpus ${nproc_per_node} --num_nodes ${num_nodes} --master_port ${master_port} lm-training/train.py \
deepspeed --include localhost:${CUDA_VISIBLE_DEVICES} --master_port ${master_port} lm-training/train.py \
--model_name_or_path ${model_path} \
--tokenizer ${tokenizer} \
--data_path ${data_path} \
--output_dir ${output_path} \
--per_device_train_batch_size ${bs_per_gpu} \
--gradient_accumulation_steps ${grad_acc} \
--lang en \
--bf16 True \
--gradient_checkpointing_enable True \
--num_train_epochs 3 \
--model_max_length 1024 \
--learning_rate 2.5e-5 \
--weight_decay 0 \
--warmup_ratio 0.03 \
--evaluation_strategy "no" \
--save_strategy "no" \
--save_steps -1 \
--save_total_limit 999 \
--lr_scheduler_type "cosine" \
--logging_steps 1 \
--tf32 True \
--deepspeed ${ds_config_file} | tee ${output_path}/training_log.txt
echo "[Shell] Done"