Files
open-instruct/scripts/dpo_train_with_qlora.sh
Hamish IvisonandGitHub ba10af976d add dpo scripts; docker; readme (#86)
- Adds dpo training script and example bash scripts. 
- I've confirmed that the full-finetuning script replicates tulu-v2-dpo-7b. PEFT works with it too, although I haven't done any hyperparameter tuning or trained a model using it.
- Inline the beaker docker container into the dockerfile to make it portable out of Ai2.
- Update readme for Tulu 2 and associated paper
2023-11-29 11:41:18 +08:00

44 lines
1.4 KiB
Bash
Executable File

export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
NUM_GPUS=8
BATCH_SIZE_PER_GPU=1
TOTAL_BATCH_SIZE=128
GRADIENT_ACC_STEPS=$(($TOTAL_BATCH_SIZE/$NUM_GPUS/$BATCH_SIZE_PER_GPU))
echo "Training model using $NUM_GPUS GPUs, $BATCH_SIZE_PER_GPU batch size per GPU, $GRADIENT_ACC_STEPS gradient accumulation steps"
# Lora training
accelerate launch \
--num_machines 1 \
--num_processes $NUM_GPUS \
open_instruct/dpo_tune.py \
--model_name_or_path allenai/tulu-2-7b \
--use_qlora \
--use_lora \
--use_flash_attn \
--lora_rank 64 \
--lora_alpha 16 \
--lora_dropout 0.1 \
--tokenizer_name allenai/tulu-2-7b \
--use_slow_tokenizer \
--dataset_name HuggingFaceH4/ultrafeedback_binarized \
--max_seq_length 1024 \
--preprocessing_num_workers 128 \
--per_device_train_batch_size $BATCH_SIZE_PER_GPU \
--gradient_accumulation_steps $GRADIENT_ACC_STEPS \
--learning_rate 1e-4 \
--lr_scheduler_type linear \
--warmup_ratio 0.03 \
--weight_decay 0. \
--num_train_epochs 5 \
--output_dir output/tulu_v2_dpo_qlora/ \
--with_tracking \
--report_to tensorboard \
--logging_steps 1 &&
python open_instruct/merge_lora.py \
--base_model_name_or_path allenai/tulu-2-7b \
--lora_model_name_or_path output/tulu_v2_dpo_qlora/ \
--output_dir output/tulu_v2_dpo_qlora_merged/ \
--qlora \
--save_tokenizer