保存为 GGUF
model.save_pretrained_gguf("directory", tokenizer, quantization_method = "q4_k_m")
model.save_pretrained_gguf("directory", tokenizer, quantization_method = "q8_0")
model.save_pretrained_gguf("directory", tokenizer, quantization_method = "f16")model.push_to_hub_gguf("hf_username/directory", tokenizer, quantization_method = "q4_k_m")
model.push_to_hub_gguf("hf_username/directory", tokenizer, quantization_method = "q8_0")# https://github.com/ggml-org/llama.cpp/blob/master/examples/quantize/quantize.cpp#L19
ALLOWED_QUANTS = \
{
"not_quantized" : "推荐。转换快。推理慢,文件大。",
"fast_quantized" : "推荐。转换快。推理尚可,文件大小尚可。",
"quantized" : "推荐。转换慢。推理快,文件小。",
"f32" : "不推荐。保留 100% 准确率,但超级慢且占用大量内存。",
"f16" : "转换最快 + 保留 100% 准确率。慢且占用大量内存。",
"q8_0" : "转换快。资源占用高,但通常可接受。",
"q4_k_m" : "推荐。对 attention.wv 和 feed_forward.w2 张量的一半使用 Q6_K,其余使用 Q4_K",
"q5_k_m" : "推荐。对 attention.wv 和 feed_forward.w2 张量的一半使用 Q6_K,其余使用 Q5_K",
"q2_k" : "对 attention.wv 和 feed_forward.w2 张量使用 Q4_K,对其他张量使用 Q2_K。",
"q3_k_l" : "对 attention.wv、attention.wo 和 feed_forward.w2 张量使用 Q5_K,其余使用 Q3_K",
"q3_k_m" : "对 attention.wv、attention.wo 和 feed_forward.w2 张量使用 Q4_K,其余使用 Q3_K",
"q3_k_s" : "对所有张量使用 Q3_K",
"q4_0" : "原始量化方法,4 位。",
"q4_1" : "准确率高于 q4_0,但不如 q5_0。不过推理速度比 q5 模型更快。",
"q4_k_s" : "对所有张量使用 Q4_K",
"q4_k" : "q4_k_m 的别名",
"q5_k" : "q5_k_m 的别名",
"q5_0" : "更高的准确率、更高的资源占用和更慢的推理。",
"q5_1" : "更高的准确率、资源占用和更慢的推理。",
"q5_k_s" : "对所有张量使用 Q5_K",
"q6_k" : "对所有张量使用 Q8_K",
"iq2_xxs" : "2.06 bpw 量化",
"iq2_xs" : "2.31 bpw 量化",
"iq3_xxs" : "3.06 bpw 量化",
"q3_k_xs" : "3 位超小量化",
}在 Unsloth 中运行效果很好,但导出后在其他平台上运行时,结果很差
保存为 GGUF / vLLM 16 位时崩溃
我如何手动保存为 GGUF?
最后更新于
这有帮助吗?

