模型简介
模型特点
模型能力
使用案例
🚀 微软Phi - 4 - reasoning的Llamacpp imatrix量化模型
本项目是对微软Phi - 4 - reasoning模型进行的Llamacpp imatrix量化处理,旨在提升模型在不同硬件上的运行效率和性能。
🚀 快速开始
运行方式
下载文件
可从以下表格中选择合适的文件进行下载:
文件名 | 量化类型 | 文件大小 | 分割情况 | 描述 |
---|---|---|---|---|
[Phi - 4 - reasoning - bf16.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - bf16.gguf) | bf16 | 29.32GB | false | 完整的BF16权重。 |
[Phi - 4 - reasoning - Q8_0.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q8_0.gguf) | Q8_0 | 15.58GB | false | 极高质量,通常无需使用,但为最大可用量化。 |
[Phi - 4 - reasoning - Q6_K_L.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q6_K_L.gguf) | Q6_K_L | 12.28GB | false | 嵌入和输出权重使用Q8_0。非常高质量,近乎完美,推荐。 |
[Phi - 4 - reasoning - Q6_K.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q6_K.gguf) | Q6_K | 12.03GB | false | 非常高质量,近乎完美,推荐。 |
[Phi - 4 - reasoning - Q5_K_L.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q5_K_L.gguf) | Q5_K_L | 10.92GB | false | 嵌入和输出权重使用Q8_0。高质量,推荐。 |
[Phi - 4 - reasoning - Q5_K_M.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q5_K_M.gguf) | Q5_K_M | 10.60GB | false | 高质量,推荐。 |
[Phi - 4 - reasoning - Q5_K_S.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q5_K_S.gguf) | Q5_K_S | 10.15GB | false | 高质量,推荐。 |
[Phi - 4 - reasoning - Q4_K_L.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q4_K_L.gguf) | Q4_K_L | 9.43GB | false | 嵌入和输出权重使用Q8_0。质量良好,推荐。 |
[Phi - 4 - reasoning - Q4_1.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q4_1.gguf) | Q4_1 | 9.27GB | false | 旧格式,在Apple硅芯片上与Q4_K_S性能相似,但每瓦处理的令牌数有所提升。 |
[Phi - 4 - reasoning - Q4_K_M.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q4_K_M.gguf) | Q4_K_M | 9.05GB | false | 质量良好,是大多数用例的默认大小,推荐。 |
[Phi - 4 - reasoning - Q4_K_S.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q4_K_S.gguf) | Q4_K_S | 8.44GB | false | 质量略低,但节省更多空间,推荐。 |
[Phi - 4 - reasoning - Q4_0.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q4_0.gguf) | Q4_0 | 8.41GB | false | 旧格式,可为ARM和AVX CPU推理提供在线重新打包。 |
[Phi - 4 - reasoning - IQ4_NL.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - IQ4_NL.gguf) | IQ4_NL | 8.38GB | false | 与IQ4_XS相似,但略大。可为ARM CPU推理提供在线重新打包。 |
[Phi - 4 - reasoning - Q3_K_XL.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q3_K_XL.gguf) | Q3_K_XL | 8.38GB | false | 嵌入和输出权重使用Q8_0。质量较低但可用,适合低内存情况。 |
[Phi - 4 - reasoning - IQ4_XS.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - IQ4_XS.gguf) | IQ4_XS | 7.94GB | false | 质量尚可,比Q4_K_S小且性能相似,推荐。 |
[Phi - 4 - reasoning - Q3_K_L.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q3_K_L.gguf) | Q3_K_L | 7.93GB | false | 质量较低但可用,适合低内存情况。 |
[Phi - 4 - reasoning - Q3_K_M.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q3_K_M.gguf) | Q3_K_M | 7.36GB | false | 低质量。 |
[Phi - 4 - reasoning - IQ3_M.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - IQ3_M.gguf) | IQ3_M | 6.91GB | false | 中低质量,新方法,性能与Q3_K_M相当。 |
[Phi - 4 - reasoning - Q3_K_S.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q3_K_S.gguf) | Q3_K_S | 6.50GB | false | 低质量,不推荐。 |
[Phi - 4 - reasoning - IQ3_XS.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - IQ3_XS.gguf) | IQ3_XS | 6.25GB | false | 质量较低,新方法,性能尚可,略优于Q3_K_S。 |
[Phi - 4 - reasoning - Q2_K_L.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q2_K_L.gguf) | Q2_K_L | 6.05GB | false | 嵌入和输出权重使用Q8_0。质量极低但意外可用。 |
[Phi - 4 - reasoning - IQ3_XXS.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - IQ3_XXS.gguf) | IQ3_XXS | 5.85GB | false | 质量较低,新方法,性能尚可,与Q3量化相当。 |
[Phi - 4 - reasoning - Q2_K.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - Q2_K.gguf) | Q2_K | 5.55GB | false | 质量极低但意外可用。 |
[Phi - 4 - reasoning - IQ2_M.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - IQ2_M.gguf) | IQ2_M | 5.11GB | false | 相对低质量,使用了最先进技术,意外可用。 |
[Phi - 4 - reasoning - IQ2_S.gguf](https://huggingface.co/bartowski/microsoft_Phi - 4 - reasoning - GGUF/blob/main/microsoft_Phi - 4 - reasoning - IQ2_S.gguf) | IQ2_S | 4.73GB | false | 低质量,使用了最先进技术,可用。 |
下载方法
点击查看下载说明
首先,确保你已安装hugginface - cli:
pip install -U "huggingface_hub[cli]"
然后,你可以指定要下载的特定文件:
huggingface-cli download bartowski/microsoft_Phi - 4 - reasoning - GGUF --include "microsoft_Phi - 4 - reasoning - Q4_K_M.gguf" --local-dir ./
如果模型大于50GB,它会被分割成多个文件。若要将它们全部下载到本地文件夹,运行:
huggingface-cli download bartowski/microsoft_Phi - 4 - reasoning - GGUF --include "microsoft_Phi - 4 - reasoning - Q8_0/*" --local-dir ./
你可以指定一个新的本地目录(如microsoft_Phi - 4 - reasoning - Q8_0),也可以将它们全部下载到当前目录(./)。
✨ 主要特性
- 多种量化类型:提供了丰富的量化类型供用户选择,以满足不同硬件和性能需求。
- 在线重新打包:部分量化类型支持在线重新打包权重,可自动优化在ARM和AVX机器上的性能。
- 性能优化:通过imatrix量化方法,提升了模型在不同硬件上的运行效率。
📚 详细文档
提示格式
<|im_start|>system<|im_sep|>You are Phi, a language model trained by Microsoft to help users. Your role as an assistant involves thoroughly exploring questions through a systematic thinking process before providing the final precise and accurate solutions. This requires engaging in a comprehensive cycle of analysis, summarizing, exploration, reassessment, reflection, backtracing, and iteration to develop well - considered thinking process. Please structure your response into two main sections: Thought and Solution using the specified format:<think>{Thought section}</think>{Solution section}. In the Thought section, detail your reasoning process in steps. Each step should include detailed considerations such as analysing questions, summarizing relevant findings, brainstorming new ideas, verifying the accuracy of the current steps, refining any errors, and revisiting previous steps. In the Solution section, based on various attempts, explorations, and reflections from the Thought section, systematically present the final solution that you deem correct. The Solution section should be logical, accurate, and concise and detail necessary steps needed to reach the conclusion. Now, try to solve the following question through the above guidelines:<|im_end|>{system_prompt}<|end|><|user|>{prompt}<|end|><|assistant|>
嵌入/输出权重
部分量化类型(如Q3_K_XL、Q4_K_L等)采用了标准量化方法,将嵌入和输出权重量化为Q8_0,而非默认设置。
ARM/AVX信息
以前,你会下载Q4_0_4_4/4_8/8_8文件,这些文件的权重会在内存中交错排列,以提高ARM和AVX机器的性能。现在,有了“在线重新打包”功能,详情见this PR。如果你使用Q4_0且硬件能从重新打包权重中受益,它会自动实时处理。
从llama.cpp构建版本b4282开始,你将无法运行Q4_0_X_X文件,而需要使用Q4_0。
此外,如果你想获得略高的质量,可以使用IQ4_NL,感谢this PR,它也会为ARM重新打包权重,不过目前仅支持4_4。加载时间可能会变慢,但总体速度会提升。
点击查看Q4_0_X_X信息(已弃用)
保留此部分是为了展示使用带有在线重新打包的Q4_0在性能上的潜在理论提升。
点击查看AVX2系统(EPYC7702)上的基准测试
模型 | 大小 | 参数 | 后端 | 线程数 | 测试用例 | 每秒令牌数 | 与Q4_0相比的百分比 |
---|---|---|---|---|---|---|---|
qwen2 3B Q4_0 | 1.70 GiB | 3.09 B | CPU | 64 | pp512 | 204.03 ± 1.03 | 100% |
qwen2 3B Q4_0 | 1.70 GiB | 3.09 B | CPU | 64 | pp1024 | 282.92 ± 0.19 | 100% |
qwen2 3B Q4_0 | 1.70 GiB | 3.09 B | CPU | 64 | pp2048 | 259.49 ± 0.44 | 100% |
qwen2 3B Q4_0 | 1.70 GiB | 3.09 B | CPU | 64 | tg128 | 39.12 ± 0.27 | 100% |
qwen2 3B Q4_0 | 1.70 GiB | 3.09 B | CPU | 64 | tg256 | 39.31 ± 0.69 | 100% |
qwen2 3B Q4_0 | 1.70 GiB | 3.09 B | CPU | 64 | tg512 | 40.52 ± 0.03 | 100% |
qwen2 3B Q4_K_M | 1.79 GiB | 3.09 B | CPU | 64 | pp512 | 301.02 ± 1.74 | 147% |
qwen2 3B Q4_K_M | 1.79 GiB | 3.09 B | CPU | 64 | pp1024 | 287.23 ± 0.20 | 101% |
qwen2 3B Q4_K_M | 1.79 GiB | 3.09 B | CPU | 64 | pp2048 | 262.77 ± 1.81 | 101% |
qwen2 3B Q4_K_M | 1.79 GiB | 3.09 B | CPU | 64 | tg128 | 18.80 ± 0.99 | 48% |
qwen2 3B Q4_K_M | 1.79 GiB | 3.09 B | CPU | 64 | tg256 | 24.46 ± 3.04 | 83% |
qwen2 3B Q4_K_M | 1.79 GiB | 3.09 B | CPU | 64 | tg512 | 36.32 ± 3.59 | 90% |
qwen2 3B Q4_0_8_8 | 1.69 GiB | 3.09 B | CPU | 64 | pp512 | 271.71 ± 3.53 | 133% |
qwen2 3B Q4_0_8_8 | 1.69 GiB | 3.09 B | CPU | 64 | pp1024 | 279.86 ± 45.63 | 100% |
qwen2 3B Q4_0_8_8 | 1.69 GiB | 3.09 B | CPU | 64 | pp2048 | 320.77 ± 5.00 | 124% |
qwen2 3B Q4_0_8_8 | 1.69 GiB | 3.09 B | CPU | 64 | tg128 | 43.51 ± 0.05 | 111% |
qwen2 3B Q4_0_8_8 | 1.69 GiB | 3.09 B | CPU | 64 | tg256 | 43.35 ± 0.09 | 110% |
qwen2 3B Q4_0_8_8 | 1.69 GiB | 3.09 B | CPU | 64 | tg512 | 42.60 ± 0.31 | 105% |
Q4_0_8_8在提示处理方面有显著提升,在文本生成方面也有小幅提升。
如何选择文件
点击查看详情
Artefact2提供了一篇很棒的文章,带有展示各种性能的图表,链接为here。
首先,你需要确定能运行多大的模型。为此,你要了解自己有多少内存(RAM)和/或显存(VRAM)。
如果你希望模型运行得尽可能快,你需要将整个模型放入GPU的显存中。选择文件大小比GPU总显存小1 - 2GB的量化模型。
如果你追求绝对的最高质量,将系统内存和GPU显存相加,然后选择文件大小比该总和小1 - 2GB的量化模型。
接下来,你需要决定是使用“I - 量化”还是“K - 量化”。
如果你不想考虑太多,选择K - 量化模型,格式为“QX_K_X”,如Q5_K_M。
如果你想深入了解,可以查看这个非常有用的特性图表: [llama.cpp feature matrix](https://github.com/ggerganov/llama.cpp/wiki/Feature - matrix)
但基本上,如果你目标是低于Q4的量化,并且使用cuBLAS(Nvidia)或rocBLAS(AMD),你应该考虑I - 量化模型,格式为IQX_X,如IQ3_M。这些是新方法,在相同大小下性能更好。
这些I - 量化模型也可以在CPU上使用,但比对应的K - 量化模型慢,所以你需要在速度和性能之间做出权衡。
🔧 技术细节
本项目使用llama.cpp的发布版本b5228进行量化。所有量化均使用imatrix选项,并使用来自here的数据集。
📄 许可证
本项目采用MIT许可证,许可证链接为:[https://huggingface.co/microsoft/Phi - 4 - reasoning/resolve/main/LICENSE](https://huggingface.co/microsoft/Phi - 4 - reasoning/resolve/main/LICENSE)
致谢
感谢kalomaze和Dampf协助创建imatrix校准数据集。 感谢ZeroWw在嵌入/输出实验方面提供的灵感。 感谢LM Studio对本项目的赞助。
如果你想支持我的工作,请访问我的ko - fi页面:[https://ko - fi.com/bartowski](https://ko - fi.com/bartowski)



