模型概述
模型特點
模型能力
使用案例
🚀 微軟Phi - 4 - reasoning - plus的Llamacpp imatrix量化模型
本項目提供了微軟Phi - 4 - reasoning - plus模型的量化版本,解決了大模型在資源有限設備上運行的難題,讓用戶能在不同硬件條件下高效使用該模型進行文本生成任務。
🚀 快速開始
本項目使用 llama.cpp 的 b5228 版本進行量化。原始模型可訪問 這裡。
你可以在 LM Studio 中運行這些量化模型,也可以直接使用 llama.cpp 或任何基於llama.cpp的項目來運行。
✨ 主要特性
- 多種量化類型:提供了豐富的量化類型供用戶選擇,如bf16、Q8_0、Q6_K_L等,滿足不同的性能和質量需求。
- 優化嵌入/輸出權重:部分量化模型(如Q3_K_XL、Q4_K_L等)將嵌入和輸出權重量化為Q8_0,提升了模型性能。
- 在線重打包功能:支持Q4_0的在線重打包,可根據硬件情況自動優化權重,提高ARM和AVX機器的性能。
📦 安裝指南
使用huggingface - cli下載
首先,確保你已安裝huggingface - cli:
pip install -U "huggingface_hub[cli]"
然後,你可以指定要下載的特定文件:
huggingface-cli download bartowski/microsoft_Phi-4-reasoning-plus-GGUF --include "microsoft_Phi-4-reasoning-plus-Q4_K_M.gguf" --local-dir ./
如果模型大小超過50GB,它會被拆分為多個文件。若要將它們全部下載到本地文件夾,可運行:
huggingface-cli download bartowski/microsoft_Phi-4-reasoning-plus-GGUF --include "microsoft_Phi-4-reasoning-plus-Q8_0/*" --local-dir ./
你可以指定一個新的本地目錄(如microsoft_Phi - 4 - reasoning - plus - Q8_0),也可以將它們全部下載到當前目錄(./)。
📚 詳細文檔
提示格式
<|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|>
下載文件選擇
文件名 | 量化類型 | 文件大小 | 拆分情況 | 描述 |
---|---|---|---|---|
Phi - 4 - reasoning - plus - bf16.gguf | bf16 | 29.32GB | false | 完整的BF16權重。 |
Phi - 4 - reasoning - plus - Q8_0.gguf | Q8_0 | 15.58GB | false | 極高質量,通常不需要,但為最大可用量化。 |
Phi - 4 - reasoning - plus - Q6_K_L.gguf | Q6_K_L | 12.28GB | false | 嵌入和輸出權重使用Q8_0。非常高質量,接近完美,推薦。 |
Phi - 4 - reasoning - plus - Q6_K.gguf | Q6_K | 12.03GB | false | 非常高質量,接近完美,推薦。 |
Phi - 4 - reasoning - plus - Q5_K_L.gguf | Q5_K_L | 10.92GB | false | 嵌入和輸出權重使用Q8_0。高質量,推薦。 |
Phi - 4 - reasoning - plus - Q5_K_M.gguf | Q5_K_M | 10.60GB | false | 高質量,推薦。 |
Phi - 4 - reasoning - plus - Q5_K_S.gguf | Q5_K_S | 10.15GB | false | 高質量,推薦。 |
Phi - 4 - reasoning - plus - Q4_K_L.gguf | Q4_K_L | 9.43GB | false | 嵌入和輸出權重使用Q8_0。質量良好,推薦。 |
Phi - 4 - reasoning - plus - Q4_1.gguf | Q4_1 | 9.27GB | false | 舊格式,性能與Q4_K_S相似,但在蘋果硅芯片上每瓦令牌數有所提升。 |
Phi - 4 - reasoning - plus - Q4_K_M.gguf | Q4_K_M | 9.05GB | false | 質量良好,大多數用例的默認大小,推薦。 |
Phi - 4 - reasoning - plus - Q4_K_S.gguf | Q4_K_S | 8.44GB | false | 質量稍低,但節省更多空間,推薦。 |
Phi - 4 - reasoning - plus - Q4_0.gguf | Q4_0 | 8.41GB | false | 舊格式,為ARM和AVX CPU推理提供在線重新打包。 |
Phi - 4 - reasoning - plus - IQ4_NL.gguf | IQ4_NL | 8.38GB | false | 類似於IQ4_XS,但稍大。為ARM CPU推理提供在線重新打包。 |
Phi - 4 - reasoning - plus - Q3_K_XL.gguf | Q3_K_XL | 8.38GB | false | 嵌入和輸出權重使用Q8_0。質量較低但可用,適合低內存情況。 |
Phi - 4 - reasoning - plus - IQ4_XS.gguf | IQ4_XS | 7.94GB | false | 質量尚可,比Q4_K_S小且性能相似,推薦。 |
Phi - 4 - reasoning - plus - Q3_K_L.gguf | Q3_K_L | 7.93GB | false | 質量較低但可用,適合低內存情況。 |
Phi - 4 - reasoning - plus - Q3_K_M.gguf | Q3_K_M | 7.36GB | false | 低質量。 |
Phi - 4 - reasoning - plus - IQ3_M.gguf | IQ3_M | 6.91GB | false | 中低質量,新方法,性能與Q3_K_M相當。 |
Phi - 4 - reasoning - plus - Q3_K_S.gguf | Q3_K_S | 6.50GB | false | 低質量,不推薦。 |
Phi - 4 - reasoning - plus - IQ3_XS.gguf | IQ3_XS | 6.25GB | false | 質量較低,新方法,性能尚可,略優於Q3_K_S。 |
Phi - 4 - reasoning - plus - Q2_K_L.gguf | Q2_K_L | 6.05GB | false | 嵌入和輸出權重使用Q8_0。質量非常低,但出人意料地可用。 |
Phi - 4 - reasoning - plus - IQ3_XXS.gguf | IQ3_XXS | 5.85GB | false | 質量較低,新方法,性能尚可,與Q3量化相當。 |
Phi - 4 - reasoning - plus - Q2_K.gguf | Q2_K | 5.55GB | false | 質量非常低,但出人意料地可用。 |
Phi - 4 - reasoning - plus - IQ2_M.gguf | IQ2_M | 5.11GB | false | 質量相對較低,使用最先進技術,出人意料地可用。 |
Phi - 4 - reasoning - plus - IQ2_S.gguf | IQ2_S | 4.73GB | false | 質量較低,使用最先進技術,可用。 |
嵌入/輸出權重
部分量化模型(如Q3_K_XL、Q4_K_L等)採用標準量化方法,將嵌入和輸出權重量化為Q8_0,而非默認值。
ARM/AVX信息
以前,你會下載Q4_0_4_4/4_8/8_8,這些模型的權重會在內存中交錯排列,以便通過一次加載更多數據來提高ARM和AVX機器的性能。
然而,現在有了所謂的權重“在線重打包”功能,詳情見 此PR。如果你使用Q4_0,並且你的硬件能從權重重打包中受益,它將自動即時進行重打包。
從llama.cpp構建 b4282 開始,你將無法運行Q4_0_X_X文件,而需要使用Q4_0。
此外,如果你想獲得稍好的質量,可以使用IQ4_NL,感謝 此PR,它也會為ARM重新打包權重,不過目前僅適用於4_4。加載時間可能會更長,但會帶來整體速度的提升。
選擇哪個文件?
點擊查看詳情
Artefact2在 這裡 提供了一篇很棒的文章,帶有展示各種性能的圖表。
首先要確定你能運行多大的模型。為此,你需要弄清楚你有多少RAM和/或VRAM。
如果你希望模型運行得儘可能快,你需要將整個模型放入GPU的VRAM中。目標是選擇一個文件大小比GPU總VRAM小1 - 2GB的量化模型。
如果你追求絕對最高質量,將系統RAM和GPU的VRAM相加,然後選擇一個文件大小比該總和小1 - 2GB的量化模型。
接下來,你需要決定是使用“I - 量化”還是“K - 量化”。
如果你不想考慮太多,選擇一個K - 量化模型。這些模型的格式為“QX_K_X”,如Q5_K_M。
如果你想深入瞭解,可以查看這個非常有用的特性圖表:
但基本上,如果你目標是低於Q4,並且你使用的是cuBLAS(Nvidia)或rocBLAS(AMD),你應該考慮I - 量化模型。這些模型的格式為IQX_X,如IQ3_M。這些是較新的模型,在相同大小下提供更好的性能。
這些I - 量化模型也可以在CPU上使用,但比同等的K - 量化模型慢,所以你需要在速度和性能之間做出權衡。
🔧 技術細節
ARM/AVX性能優化
之前,為了提高ARM和AVX機器的性能,會下載Q4_0_4_4/4_8/8_8文件,其權重在內存中交錯排列,以便一次加載更多數據。現在,有了“在線重打包”功能,使用Q4_0時,若硬件適合重打包權重,會自動即時進行。從llama.cpp構建 b4282 起,不能運行Q4_0_X_X文件,需用Q4_0。此外,IQ4_NL可藉助 此PR 為ARM重打包權重,雖加載時間可能變長,但整體速度提升。
量化類型選擇依據
對於模型量化類型的選擇,首先要考慮能運行的模型大小,這取決於RAM和/或VRAM的容量。若追求最快速度,應選擇文件大小比GPU總VRAM小1 - 2GB的量化模型;若追求最高質量,可將系統RAM和GPU的VRAM相加,選擇比該總和小1 - 2GB的量化模型。在選擇“I - 量化”還是“K - 量化”時,若不想深入考慮,可選擇K - 量化(格式為“QX_K_X”);若使用cuBLAS(Nvidia)或rocBLAS(AMD)且目標低於Q4,可考慮I - 量化(格式為IQX_X),其較新且相同大小下性能更好,但在CPU上比K - 量化慢,需在速度和性能間權衡。
📄 許可證
本項目採用MIT許可證,詳情見 許可證鏈接。
致謝
感謝kalomaze和Dampf協助創建imatrix校準數據集。 感謝ZeroWw啟發對嵌入/輸出進行實驗。 感謝LM Studio贊助本項目工作。
如果你想支持我的工作,請訪問我的ko - fi頁面:https://ko-fi.com/bartowski



