模型概述
模型特點
模型能力
使用案例
🚀 Phi-4-reasoning-plus模型卡片
Phi-4-reasoning-plus是基於Phi-4微調的推理模型,在數學、科學和編碼等推理密集型任務中表現出色,具有較高的準確性和推理能力。
🚀 快速開始
若要充分發揮模型的能力,推理時必須使用 temperature=0.8
、top_k=50
、top_p=0.95
並設置 do_sample=True
。對於更復雜的查詢,可設置 max_new_tokens=32768
以支持更長的思維鏈(CoT)。
✨ 主要特性
- 先進架構:基於14B參數的密集解碼器Transformer模型,與之前發佈的Phi-4基礎模型相同。
- 高質量訓練:使用16B標記(約83億唯一標記)的訓練數據,訓練時間為2.5天。
- 長上下文處理:支持32k標記的上下文長度,在實驗中擴展到64k標記也能保持良好性能。
- 高準確性:經過強化學習訓練,準確性更高,但平均生成的標記數增加50%,延遲也相應增加。
- 多任務表現出色:在推理任務和通用基準測試中均有良好表現,超越了許多大參數模型。
📦 安裝指南
文檔未提及安裝步驟,暫無法提供。
💻 使用示例
基礎用法
由於訓練數據的特性,推理時始終使用ChatML模板和以下系統提示:
<|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|>
<|im_start|>user<|im_sep|>
What is the derivative of x^2?<|im_end|>
<|im_start|>assistant<|im_sep|>
高級用法
使用transformers
庫
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-4-reasoning-plus")
model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-4-reasoning-plus", device_map="auto", torch_dtype="auto")
messages = [
{"role": "system", "content": "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:"},
{"role": "user", "content": "What is the derivative of x^2?"},
]
inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt")
outputs = model.generate(
inputs.to(model.device),
max_new_tokens=4096,
temperature=0.8,
top_k=50,
top_p=0.95,
do_sample=True,
)
print(tokenizer.decode(outputs[0]))
使用vllm
庫
vllm serve microsoft/Phi-4-reasoning-plus --enable-reasoning --reasoning-parser deepseek_r1
Phi-4-reasoning-plus還支持Ollama、llama.cpp和任何與Phi-4兼容的框架。
📚 詳細文檔
模型概述
屬性 | 詳情 |
---|---|
開發者 | Microsoft Research |
描述 | Phi-4-reasoning-plus是一個最先進的開放權重推理模型,基於Phi-4進行監督微調,並結合強化學習。監督微調數據集包括合成提示和來自公共領域網站的高質量過濾數據,專注於數學、科學和編碼技能以及安全和負責任AI的對齊數據。該模型經過強化學習訓練,準確性更高,但平均生成的標記數增加50%,延遲也相應增加。 |
架構 | 基礎模型與之前發佈的Phi-4相同,14B參數,密集解碼器Transformer模型 |
輸入 | 文本,最適合聊天格式的提示 |
上下文長度 | 32k標記 |
GPU | 32個H100-80G |
訓練時間 | 2.5天 |
訓練數據 | 16B標記,約83億唯一標記 |
輸出 | 對輸入的生成文本,模型響應分為推理思維鏈塊和總結塊兩部分 |
日期 | 2025年1月 - 2025年4月 |
狀態 | 基於離線數據集訓練的靜態模型,公開可用數據截止到2025年3月及更早 |
發佈日期 | 2025年4月30日 |
許可證 | MIT |
預期用途
用途類型 | 詳情 |
---|---|
主要用例 | 該模型旨在加速語言模型的研究,作為生成AI功能的構建塊。適用於需要內存/計算受限環境、低延遲場景和推理邏輯的通用AI系統和應用(主要為英文)。 |
非預期用例 | 該模型僅針對數學推理進行設計和測試,並非針對所有下游用途進行專門設計或評估。開發者在選擇用例時應考慮語言模型的常見限制,並在特定下游用例中使用前評估和緩解準確性、安全性和公平性問題,特別是在高風險場景中。開發者應遵守適用的法律法規(包括隱私、貿易合規等),並參考“負責任AI考慮因素”部分獲取更多指導。 |
數據概述
訓練數據集
訓練數據是數學、科學和編碼領域的問答和聊天格式數據的混合。聊天提示來自過濾後的高質量網絡數據,並可通過合成數據生成管道進行重寫和處理。此外,還包括提高真實性和安全性的數據。
基準數據集
使用開源的Eureka評估套件和內部基準對Phi-4-reasoning-plus進行評估,具體包括:
- 推理任務:AIME 2025、2024、2023和2022、GPQA-Diamond、OmniMath、LiveCodeBench、3SAT和TSP、BA Calendar、Maze和SpatialMap。
- 通用基準:Kitab、IFEval和ArenaHard、PhiBench、FlenQA、HumanEvalPlus、MMLU-Pro。
安全性
方法
Phi-4-reasoning-plus採用了強大的安全後訓練方法,通過監督微調(SFT),利用各種開源和內部生成的合成提示,以及符合微軟嚴格安全指南的LLM生成響應。
安全評估和紅隊測試
在發佈前,Phi-4-reasoning-plus採用了多方面的評估方法,包括使用多個開源安全基準和內部工具進行定量評估,以及與微軟獨立AI紅隊(AIRT)合作進行定性安全評估。還在Toxigen基準上評估模型的偏差和毒性。
模型質量
在代表性基準測試中,Phi-4-reasoning和Phi-4-reasoning-plus在推理任務中表現出色,超越了許多大參數模型,並且在通用能力基準測試中也有顯著提升。
負責任AI考慮因素
Phi-4-reasoning-plus可能存在一些侷限性,如服務質量、群體代表性、不當內容、信息可靠性、選舉信息可靠性和代碼範圍有限等問題。開發者應遵循負責任AI最佳實踐,確保特定用例符合相關法律法規,並使用安全服務進行風險緩解。
🔧 技術細節
文檔未提及技術實現細節,暫無法提供。
📄 許可證
本項目採用MIT許可證。



