使用llama-factory和llama.cpp微调量化Qwen2

使用llama-factory和llama.cpp微调量化Qwen2

准备数据集

1.选定数据集的格式
2.将处理好的数据集上传到/data 文件夹下面,并修改dataset_info.json文件
3.测试数据集同理

微调

在目录LLaMA-Factory/examples/train_lora/llama3_lora_sft_praise.yaml
下修改对应的参数

训练命令:
CUDA_VISIBLE_DEVICES=1 llamafactory-cli train examples/train_lora/llama3_lora_sft_praise.yaml

生成模型将会放在LLaMA-Factory/saves下面

测试

llamafactory-cli train examples/train_lora/llama3_lora_predict.yaml

自己的测试acc脚本
cd saves/Qwen2-1.5B/lora/predict/
python acc.py

合并

llamafactory-cli export examples/merge_lora/llama3_lora_sft.yaml

使用llama.cpp量化

将合并后的模型转化为fp16精度的gguf格式文件
python convert-hf-to-gguf.py /home/ccnu-train/gl/LLaMA-Factory/models/qwen2_lora_sft/question/ --outfile models/1.5B/qwen2-1.5B-question-fp16.gguf

量化为int4精度的模型
./llama-quantize ./models/1.5B/qwen2-1.5b-question2-fp16.gguf ./models/1.5B/qwen2-1.5b-question2-q4_0.gguf q4_0

flash-attn&cuda版本
flash-attn:2.6.3
cuda:12.4

  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值