Guest User

Llama 7B SFT

a guest
Oct 16th, 2023
570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.63 KB | None | 0 0
  1. #!/bin/bash
  2. # Please run this script under ${project_id} in project directory of
  3. #   https://github.com/shizhediao/llm-ft
  4. #     COMMIT: d5fecf30ba8011067b10cf51fede53a5ab6574e4
  5.  
  6. # Parses arguments
  7. model_name_or_path=huggyllama/llama-7b
  8. dataset_path=data/hh_rlhf/sft-not-formatted
  9. output_dir=output_models/llama-7b-sft-not-formatted
  10. deepspeed_args="--master_port=11000"
  11.  
  12. while [[ $# -ge 1 ]]; do
  13.   key="$1"
  14.   case ${key} in
  15.     -m|--model_name_or_path)
  16.       model_name_or_path="$2"
  17.       shift
  18.       ;;
  19.     -d|--dataset_path)
  20.       dataset_path="$2"
  21.       shift
  22.       ;;
  23.     -o|--output_model_path)
  24.       output_dir="$2"
  25.       shift
  26.       ;;
  27.     --deepspeed_args)
  28.       deepspeed_args="$2"
  29.       shift
  30.       ;;
  31.     *)
  32.       echo "error: unknown option \"${key}\"" 1>&2
  33.       exit 1
  34.   esac
  35.   shift
  36. done
  37.  
  38. # Finetune
  39. exp_id=finetune
  40. project_dir=$(cd "$(dirname $0)"/..; pwd)
  41. log_dir=${project_dir}/log/${exp_id}
  42. mkdir -p ${output_dir} ${log_dir}
  43.  
  44. deepspeed ${deepspeed_args} \
  45.   examples/finetune.py \
  46.     --model_name_or_path ${model_name_or_path} \
  47.     --dataset_path ${dataset_path} \
  48.     --output_dir ${output_dir} --overwrite_output_dir \
  49.     --num_train_epochs 1 \
  50.     --learning_rate 2e-5 \
  51.     --block_size 512 \
  52.     --per_device_train_batch_size 4 \
  53.     --per_device_eval_batch_size 4 \
  54.     --deepspeed configs/ds_config_zero3.json \
  55.     --fp16 \
  56.     --run_name llama-7b-sft \
  57.     --validation_split_percentage 0 \
  58.     --logging_steps 20 \
  59.     --do_train \
  60.     --ddp_timeout 72000 \
  61.     --save_steps 5000 \
  62.     --dataloader_num_workers 1 \
  63.     | tee ${log_dir}/train.log \
  64.     2> ${log_dir}/train.err
Advertisement
Add Comment
Please, Sign In to add comment