模型概述
模型特點
模型能力
使用案例
🚀 微軟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)



