baichuan-inc / Baichuan-7B

A large-scale 7B pretraining language model developed by BaiChuan-Inc.
https://huggingface.co/baichuan-inc/baichuan-7B
Apache License 2.0
5.67k stars 504 forks source link

[Question] 实现了百川模型的低资源量化训练和部署 #42

Open jianzhnie opened 1 year ago

jianzhnie commented 1 year ago

Required prerequisites

Questions

实现了百川模型的低资源量化训练和部署:https://github.com/jianzhnie/Efficient-Tuning-LLMs LoRA微调可在单块3090 GPU上运行,同时支持QLoRA方法,最低8G 显存。 运行以下指令即可实现 4bit `量化训练:

python qlora_finetune.py \
    --model_name_or_path  baichuan-inc/baichuan-7B\
    --dataset_name alpaca \
    --output_dir ./work_dir/baichuan-7B \
    --num_train_epochs 3 \
    --per_device_train_batch_size 1 \
    --per_device_eval_batch_size 1 \
    --gradient_accumulation_steps 16 \
    --evaluation_strategy steps \
    --eval_steps 2000 \
    --eval_dataset_size 1024 \
    --max_eval_samples 1000 \
    --save_strategy steps \
    --save_total_limit 5 \
    --save_steps 500 \
    --logging_strategy steps \
    --logging_steps 10 \
    --learning_rate 0.0002 \
    --warmup_ratio 0.03 \
    --weight_decay 0.0 \
    --lr_scheduler_type constant \
    --adam_beta2 0.999 \
    --max_grad_norm 0.3 \
    --max_new_tokens 32 \
    --source_max_len 512 \
    --target_max_len 512 \
    --lora_r 64 \
    --lora_alpha 16 \
    --lora_dropout 0.1 \
    --double_quant \
    --quant_type nf4 \
    --fp16 \
    --bits 4 \
    --gradient_checkpointing \
    --do_train \
    --do_eval \
    --data_seed 42 \
    --seed 0

下面是部署的截图

image image
jianzhnie commented 1 year ago
image