llama.cpp github地址:GitHub - ggerganov/llama.cpp: LLM inference in C/C++
克隆地址并尝试build:
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make GGML_CUDA=1 #没有gpu的linux使用make命令代替这一行即可
安装依赖项:
python3 -m pip install -r requirements.txt
在之前的教程中,我们提到了unsloth微调的办法,那时候保存的模型直接为.safetensors格式的,所以我们要先将其转换为gguf FP16格式格式。
# 转换模型为ggml FP16格式(cd ./llama.cpp)
python convert-hf-to-gguf.py ./your_hf_model_file --outfile ./mymodel/yourmodel.gguf --outtype f16
其中./your_hf_model_file为你的hf或者gguf格式的模型文件文件夹地址,llama.cpp还支持多种模型格式转换方法,可以去github项目地址自行查看,其中./mymodel/yourmodel.gguf是输出文件夹的地址和输出的gguf格式文件名称,记得一定要以.gguf结尾。
# 四位量化 (us