📌 适用场景
将 Hugging Face 格式的语言模型(如 LLaMA、Mistral、Deepseek 等)转换为 GGUF 格式,以便使用 Ollama 进行本地加载和推理。
🛠️ 所需工具
工具 | 说明 |
---|---|
transformers |
Hugging Face 官方模型库 |
gguf-converter (或 llama.cpp) |
将 HF 模型转换为 GGUF |
ollama |
轻量级本地大语言模型推理引擎 |
✅ 推荐使用 llama.cpp 的
convert.py
或社区工具进行转换。
✅ 操作步骤
1️⃣ 下载 Hugging Face 格式模型
2️⃣ 使用 llama.cpp 转换为 GGUF
# 进入 llama.cpp 目录
cd llama.cpp-master
python convert_hf_to_gguf.py --outfile ./your.gguf "your/model/dir"
- 脚本所在目录: