ymcui / Chinese-LLaMA-Alpaca-2

中文LLaMA-2 & Alpaca-2大模型二期项目 + 64K超长上下文模型 (Chinese LLaMA-2 & Alpaca-2 LLMs with 64K long context models)
Apache License 2.0
7.04k stars 581 forks source link

指令精调之后,除了指令里面的问题能回答,其他回答全是none #386

Closed Rainlv closed 9 months ago

Rainlv commented 10 months ago

提交前必须检查以下项目

问题类型

模型训练与精调

基础模型

Chinese-Alpaca-2 (7B/13B)

操作系统

Linux

详细描述问题

对Chinese-llama-alpaca2-hf进行指令精调,后将得到的lora与Chinese-llama-alpaca2-hf进行合并,但只能回答指令精调中的内容,其他任何语句的回答均为none

# 请在此处粘贴运行代码(请粘贴在本代码块里)
``lr=1e-4
lora_rank=64
lora_alpha=128
lora_trainable="q_proj,v_proj,k_proj,o_proj,gate_proj,down_proj,up_proj"
modules_to_save="embed_tokens,lm_head"
lora_dropout=0.05
pretrained_model=/home/sensorweb/lijialin/llm_Chinese/Chinese-LLaMA-Alpaca-2/chinese-alpaca-2-7b-hf
chinese_tokenizer_path=/home/sensorweb/lijialin/llm_Chinese/Chinese-LLaMA-Alpaca-2/chinese-alpaca-2-7b-hf
dataset_dir=/home/sensorweb/lijialin/llm_Chinese/Chinese-LLaMA-Alpaca-2/data_final/train
per_device_train_batch_size=1
per_device_eval_batch_size=1
gradient_accumulation_steps=8
max_seq_length=512
output_dir=/home/sensorweb/lijialin/llm_Chinese/Chinese-LLaMA-Alpaca-2/base_sft/lora
peft_model=/home/sensorweb/lijialin/llm_Chinese/Chinese-LLaMA-Alpaca-2/chinese-alpaca-2-lora-7b
validation_file=/home/sensorweb/lijialin/llm_Chinese/Chinese-LLaMA-Alpaca-2/data_final/eval/eval.json
deepspeed_config_file=ds_zero2_no_offload.json
torchrun --nnodes 1 --nproc_per_node 1 run_clm_sft_with_peft.py \
    --deepspeed ${deepspeed_config_file} \
    --model_name_or_path ${pretrained_model} \
    --tokenizer_name_or_path ${chinese_tokenizer_path} \
    --dataset_dir ${dataset_dir} \
    --per_device_train_batch_size ${per_device_train_batch_size} \
    --per_device_eval_batch_size ${per_device_eval_batch_size} \
    --do_train \
    --do_eval \
    --seed $RANDOM \
    --fp16 \
    --num_train_epochs 1 \
    --lr_scheduler_type cosine \
    --learning_rate ${lr} \
    --warmup_ratio 0.03 \
    --weight_decay 0 \
    --logging_strategy steps \
    --logging_steps 10 \
    --save_strategy steps \
    --save_total_limit 3 \
    --evaluation_strategy steps \
    --eval_steps 100 \
    --save_steps 200 \
    --gradient_accumulation_steps ${gradient_accumulation_steps} \
    --preprocessing_num_workers 8 \
    --max_seq_length ${max_seq_length} \
    --output_dir ${output_dir} \
    --overwrite_output_dir \
    --ddp_timeout 30000 \
    --logging_first_step True \
    --torch_dtype float16 \
    --validation_file ${validation_file} \
    --peft_path ${peft_model} \
    --load_in_kbits 16 

### 依赖情况(代码类问题务必提供)

请在此处粘贴依赖情况(请粘贴在本代码块里)


### 运行日志或截图

请在此处粘贴运行日志(请粘贴在本代码块里)


history: [[ 'nihao', None]]Input length: 38 history: [['nihao', 'None' ],['*SBAS#InSAR可观测什么事件',"形变速率'],['事件',"滑坡形变特征']
iMountTai commented 10 months ago

仔细阅读指令精调脚本,如果你是基于Chinese-alpaca-2-7b继续微调,不需要输入--peft_path参数

Rainlv commented 10 months ago

我删除掉--peft_path的结果和这个一样,我就是先进行全新指令微调是这种情况,又加上了--peft_path还是这种情况,指令精调脚本不是说了全新精调才删除,继续精调加上--peft_path

iMountTai commented 10 months ago

你目前的脚本,--peft_path是不需要设置的。另外不清楚你数据集有多大,学习率、total_batchsize等都是需要调整的参数,我们给出的脚本只是个样例,具体的参数设置还需调整

Rainlv commented 10 months ago

非常感谢您的回答,我想请问您一下,基于chinese-alpaca-2-7b-hf微调得出的权重sft_lora是合并到chinese-alpaca-2-7b-hf上吗?您的意思是这种情况出现是因为参数设置的不合理对吗?我的指令数据有三千多条,再次感谢您

iMountTai commented 10 months ago

得到的新lora(不是继续训练的lora)与chinese-alpaca-2-7b-hf合并即可。尝试把学习率降低一下,具体的设置还需根据数据量来,再调试调试吧

459737087 commented 10 months ago

你好,peft_model的作用是什么啊 @iMountTai

github-actions[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your consideration.