モデル概要
モデル特徴
モデル能力
使用事例
🚀 Phi-4-reasoningモデルカード
Phi-4-reasoningは、高度に微調整された先進的な推論モデルです。Phi-4をベースに、監督微調整と強化学習を通じて特定のデータセットで訓練され、数学、科学、コーディングなどの分野での推論能力を向上させることに特化しています。これにより、生成型AI機能の強力な構成要素となっています。
🚀 クイックスタート
このモデルは、言語モデルの研究を加速するために設計されており、生成型AI機能の構成要素として使用できます。モデルを使用して推論を行う場合は、以下の内容を参考にしてください。
推論パラメータ
推論時には、temperature=0.8
、top_p=0.95
を設定し、do_sample
をTrue
にすることをおすすめします。より複雑なクエリの場合、最大トークン数を32kに設定すると、より長い思考過程(CoT)をサポートできます。
入力形式
訓練データの性質上、推論時には常にChatMLテンプレートを使用し、以下のシステムプロンプトを併用してください。
<|im_start|>system<|im_sep|>
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")
model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-4-reasoning", 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_p=0.95,
do_sample=True,
)
print(tokenizer.decode(outputs[0]))
vllm
ライブラリの使用
vllm serve microsoft/Phi-4-reasoning --enable-reasoning --reasoning-parser deepseek_r1
Phi-4-reasoningは、Ollama、llama.cpp、およびPhi-4互換のすべてのフレームワークで直接使用することもできます。
✨ 主な機能
- 先進的な推論能力:Phi-4-reasoningは、先進的なオープンウェイトの推論モデルです。思考過程の痕跡データセットでの監督微調整と強化学習を通じて、数学、科学、コーディングなどの分野での推論能力を向上させています。
- 効率的なアーキテクチャ設計:以前に公開されたPhi-4ベースモデルをベースに、14Bのパラメータを持ち、密集型のデコーダー専用Transformerアーキテクチャを採用しています。
- 長文脈処理能力:32kトークンのコンテキスト長をサポートし、複雑な入力を処理できます。
- 広範な評価検証:数学オリンピック問題、コード生成、アルゴリズム問題解決など、複数のオープンソースおよび内部のベンチマークテストで評価され、優れた性能を示しています。
💻 使用例
基本的な使用法
transformers
ライブラリを使用した推論の基本的な例:
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-4-reasoning")
model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-4-reasoning", 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_p=0.95,
do_sample=True,
)
print(tokenizer.decode(outputs[0]))
高度な使用法
vllm
ライブラリを使用した推論の高度な例:
vllm serve microsoft/Phi-4-reasoning --enable-reasoning --reasoning-parser deepseek_r1
📚 ドキュメント
モデル概要
属性 | 詳細 |
---|---|
開発者 | Microsoft Research |
説明 | Phi-4-reasoningは、先進的なオープンウェイトの推論モデルです。Phi-4をベースに監督微調整と強化学習を行っています。監督微調整データセットには、合成プロンプトと公共のウェブサイトからの高品質なフィルタリング済みデータが含まれ、数学、科学、コーディングスキル、および安全で責任あるAIのアライメントデータに焦点を当てています。 |
アーキテクチャ | ベースモデルは以前に公開されたPhi-4と同じで、14Bのパラメータを持ち、密集型のデコーダー専用Transformerアーキテクチャを採用しています。 |
入力 | テキスト、チャット形式のプロンプトに最適 |
コンテキスト長 | 32kトークン |
GPU要件 | 32個のH100 - 80G GPU |
訓練時間 | 2.5日 |
訓練データ | 16Bトークン、約8.3Bの一意のトークン |
出力 | 入力に対応するテキストを生成します。モデルの応答は、思考過程の推論ブロックと要約ブロックの2つの部分に分かれています。 |
期間 | 2025年1月 - 2025年4月 |
状態 | オフラインデータセットで訓練された静的モデルで、公開されているデータの期限は2025年3月までです。 |
公開日 | 2025年4月30日 |
ライセンス | MIT |
想定用途
用途の種類 | 詳細 |
---|---|
主なユースケース | このモデルは、言語モデルの研究を加速するために設計されており、生成型AI機能の構成要素として使用できます。メモリ/計算資源が制限された環境、低遅延シナリオ、および推論ロジックが必要な一般的なAIシステムやアプリケーション(主に英語)に適しています。 |
想定外のユースケース | このモデルは数学的な推論に特化して設計およびテストされており、すべての下流の用途に対して特別に設計または評価されているわけではありません。開発者は、言語モデルの一般的な制限を考慮し、特定の下流のユースケースで使用する前に、精度、安全性、および公平性の問題を評価し、軽減する必要があります。特に、高リスクのシナリオでは、開発者は適用可能な法律および規制を遵守し、「責任あるAIに関する考慮事項」のセクションを参照してさらなるガイダンスを得る必要があります。 |
データ概要
訓練データセット
訓練データには、数学、科学、コーディング分野の質問と回答、およびチャット形式のデータが含まれています。チャットプロンプトは、フィルタリングされた高品質なウェブデータから取得され、合成データ生成パイプラインを通じて書き換えおよび処理されます。また、信憑性と安全性を向上させるためのデータも含まれています。
ベンチマークデータセット
Phi-4-reasoningは、オープンソースのEureka評価キットと内部のベンチマークテストを使用して評価されています。具体的には以下の通りです。
- 推論タスク: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は、強力な安全事後訓練方法を採用しています。監督微調整(SFT)を通じて、複数のオープンソースおよび内部生成の合成プロンプトと、Microsoftの厳格な安全ガイドラインに従ったLLM生成応答を利用しています。
安全評価とレッドチームテスト
公開前に、Phi-4-reasoningは多面的な評価方法を採用しています。複数のオープンソースの安全ベンチマークと内部ツールを使用して定量的な評価を行い、敵対的な対話シミュレーションを利用しています。Microsoftの独立したAIレッドチーム(AIRT)と協力して定性的な安全評価を行い、平均的および敵対的なユーザーシナリオでの安全リスクを評価しています。また、Toxigenベンチマークでモデルのバイアスと毒性を評価しています。
モデル品質
代表的なベンチマークでのモデル品質の概要:
モデル | AIME 24 | AIME 25 | OmniMath | GPQA - D | LiveCodeBench (8/1/24–2/1/25) |
---|---|---|---|---|---|
Phi-4-reasoning | 75.3 | 62.9 | 76.6 | 65.8 | 53.8 |
Phi-4-reasoning-plus | 81.3 | 78.0 | 81.9 | 68.9 | 53.1 |
OpenThinker2 - 32B | 58.0 | 58.0 | — | 64.1 | — |
QwQ 32B | 79.5 | 65.8 | — | 59.5 | 63.4 |
EXAONE - Deep - 32B | 72.1 | 65.8 | — | 66.1 | 59.5 |
DeepSeek - R1 - Distill - 70B | 69.3 | 51.5 | 63.4 | 66.2 | 57.5 |
DeepSeek - R1 | 78.7 | 70.4 | 85.0 | 73.0 | 62.8 |
o1 - mini | 63.6 | 54.8 | — | 60.0 | 53.8 |
o1 | 74.6 | 75.3 | 67.5 | 76.7 | 71.0 |
o3 - mini | 88.0 | 78.0 | 74.6 | 77.7 | 69.5 |
Claude - 3.7 - Sonnet | 55.3 | 58.7 | 54.6 | 76.8 | — |
Gemini - 2.5 - Pro | 92.0 | 86.7 | 61.1 | 84.0 | 69.2 |
モデル | FlenQA [3K - token subset] | IFEval Strict | ArenaHard | HumanEvalPlus | MMLUPro | Kitab No Context - Precision With Context - Precision No Context - Recall With Context - Recall |
Toxigen Discriminative Toxic category Neutral category |
PhiBench 2.21 |
---|---|---|---|---|---|---|---|---|
Phi-4 | 19.3 88.5 8.2 68.1 |
62.3 | 68.1 | 83.5 | 71.5 | 19.3 88.5 8.2 68.1 |
72.6 90.0 |
58.2 |
Phi-4-reasoning | 23.2 91.5 4.9 74.8 |
83.4 | 73.3 | 92.9 | 74.3 | 23.2 91.5 4.9 74.8 |
86.7 84.7 |
70.6 |
Phi-4-reasoning-plus | 27.6 93.6 6.3 75.4 |
84.9 | 79.0 | 92.3 | 76.0 | 27.6 93.6 6.3 75.4 |
77.3 90.5 |
74.2 |
o3 - mini | 37.9 94.0 4.2 76.1 |
91.5 | 81.9 | 94.0 | 79.4 | 37.9 94.0 4.2 76.1 |
85.4 88.7 |
78.0 |
GPT - 4o | 53.7 84.7 20.3 69.2 |
81.8 | 75.6 | 88.0 | 73.0 | 53.7 84.7 20.3 69.2 |
87.6 85.1 |
72.4 |
全体的に、Phi-4-reasoningはわずか14Bのパラメータしか持っていませんが、広範な推論タスクで優れた性能を発揮し、DeepSeek - R1蒸留70Bモデルなどのより大きなオープンウェイトモデルを大幅に上回り、完全なDeepSeek R1モデルの性能レベルに近づいています。
責任あるAIに関する考慮事項
他の言語モデルと同様に、Phi-4-reasoningには不公平、信頼できない、または不快な行動が含まれる可能性があります。開発者は、責任あるAIのベストプラクティスを適用し、特定のユースケースが関連する法律および規制に準拠していることを確認する必要があります。Azure AI Content Safetyなどの安全サービスの使用をおすすめします。
制限事項
- サービス品質:モデルは主に英語のテキストで訓練されているため、非英語の言語での性能は低下します。訓練データでの表現が少ない英語のバリエーションは、標準的なアメリカ英語よりも性能が悪くなる可能性があります。Phi-4-reasoningは多言語対応ではありません。
- 損害表現と固定観念の拡大:モデルは、特定の集団を過大または過小に表現し、特定のグループの表現を抹消し、または貶めるまたは否定的な固定観念を強化する可能性があります。
- 不適切または不快な内容:モデルは、他のタイプの不適切または不快な内容を生成する可能性があり、敏感なコンテキストでの展開時には追加の緩和策が必要です。
- 情報の信頼性:言語モデルは、無意味な内容を生成したり、合理的に聞こえるが不正確または古い内容を捏造する可能性があります。
- 選挙情報の信頼性:モデルは、選挙に関する重要なクエリに回答する際に高い欠陥率を示す可能性があり、不正確または信頼できない選挙情報を提示する可能性があります。
- コード範囲の制限:Phi-4-reasoningの大部分の訓練データはPythonに基づいており、一般的なパッケージを使用しています。モデルが他のパッケージまたは他の言語を使用するPythonスクリプトを生成する場合、ユーザーはすべてのAPIの使用を手動で検証することをおすすめします。
考慮事項
- 配分:モデルは、法的地位、資源配分、または生活機会に重大な影響を与えるシナリオには適さない可能性があり、さらなる評価と追加のバイアス除去技術が必要です。
- 高リスクシナリオ:開発者は、高リスクシナリオでのモデルの使用適性を評価し、アプリケーションレベルで追加の保障措置を実施する必要があります。
- 誤情報:モデルは不正確な情報を生成する可能性があり、開発者は透明性のベストプラクティスに従い、フィードバックメカニズムとパイプラインを構築する必要があります。
- 有害内容の生成:開発者は、出力のコンテキストを評価し、適切な安全分類器またはカスタムソリューションを使用する必要があります。
- 悪用:詐欺、スパム、またはマルウェアの生成など、他の形態の悪用が存在する可能性があり、開発者はアプリケーションの安全性を確保する必要があります。
📄 ライセンス
このプロジェクトはMITライセンスの下で提供されています。詳細については、ライセンスリンクを参照してください。



