Llama factory微调后的模型怎么通过ollama发布
接上一篇博客:用Llama Factory单机多卡微调Qwen2.5时报torch.OutOfMemoryError: CUDA out of memory的解决办法_llama-factory cuda out of memory-CSDN博客
把Lora模块和其基模型merge到一起之后,就可以通过ollama之类的框架提供服务了。不过还是有些格式转换的工作要做:
首先
git clone https://github.com/ggerganov/llama.cpp
其次我们可以创建一个conda环境,然后运行:
pip install -r requirements.txt
这样就把llama.cpp的环境和依赖配置好了,我们注意到llama.cpp文件夹下有convert_hf_to_gguf.py之类的文件,实际上使用这种文件就可以了,例如我这里运行:
python convert_hf_to_gguf.py /home/quyu/Projects/LLaMA-Factory/models/qwen2.5-7b_lora_sft/ --outfile /home/quyu/qwen2.5_7b_finetuned.gguf
顾名思义,就是把huggingface类的文件转成g