安装git clone https://github.com/hiyouga/LLaMA-Factory.git
conda create -n llama_factory python=3.10
conda activate llama_factory
cd LLaMA-Factory
pip install -r requirements.txt
之后运行
CUDA_VISIBLE_DEVICES=0 python src/train_web.py,按如下配置
demo_tran.sh
CUDA_VISIBLE_DEVICES=0 python src/train_bash.py \--stage sft \--model_name_or_path /data/models/llm/chatglm3-lora/ \--do_train \--overwrite_output_dir \--dataset self_cognition \--template chatglm3 \--finetuning_type lora \--lora_target query_key_value \--output_dir export_chatglm3 \--overwrite_cache \--per_device_train_batch_size 4 \--gradient_accumulation_steps 4 \--lr_scheduler_type cosine \--logging_steps 10 \--save_steps 1000 \--learning_rate 1e-3 \--num_train_epochs 10.0 \--plot_loss \--fp16
export_model.sh
python src/export_model.py \--model_name_or_path /data/models/llm/chatglm3-lora/ \--template chatglm3 \--finetuning_type lora \--checkpoint_dir /data/projects/LLaMA-Factory/export_chatglm3 \--export_dir lora_merge_chatglm3
cli_demo.sh
python src/cli_demo.py \--model_name_or_path /data/models/llm/chatglm3-lora/ \--template default \--finetuning_type lora
注意合并模型的时候,最后复制chatglm3的tokenizer.model和tokenizer_config.json到合并后模型覆盖之后,要修改
不覆盖会有这个错误,