DeepSeek-V4:エージェントが実際に活用できる100万トークンコンテキスト
DeepSeekが自律型エージェントの実用性を重視した100万トークンコンテキスト長の新モデル「DeepSeek-V4」を公開した。
キーポイント
コンテキスト長の突破
100万トークンという超大規模なコンテキスト長を実現し、長期記憶が必要なタスクのボトルネックを解消。
エージェント最適化
単なるベンチマーク数値の向上ではなく、自律型エージェントが実際に活用できる設計思想を反映。
公開プラットフォーム
Hugging Face Blogを通じてモデルが公開され、開発者コミュニティへの迅速な展開を意味する。
影響分析・編集コメントを表示
影響分析
100万トークンコンテキストの実現は、複雑なドキュメント分析や長期対話メモリを必要とする自律型エージェントの実用化に直結する。開発者コミュニティは、このモデルを既存のワークフローに組み込むことで、従来不可能だった大規模文書処理や継続的な自律行動の実験が可能になる。今後はコンテキスト管理のコスト最適化と精度維持が次の課題となる見込みだ。
編集コメント
コンテキスト長の数値競争から「実エージェント利用」への転換は、LLM応用段階の成熟を示す明確な指標である。今後は推論コストとコンテキスト圧縮技術の進化が、このモデルの実装成否を分けるだろう。
- エージェントにおけるKVキャッシュ(KV cache)の問題
- ハイブリッドアテンション:CSAとHCA
- エージェントにとっての変更:ツール呼び出しをまたぐインターリーブ思考
- 専用トークンを持つツール呼び出しスキーマ
- DSec:RLロールアウト(RL rollouts)用に構築されたサンドボックス
- エージェントベンチマーク結果
- モデルの使用法
DeepSeekは本日V4をリリースしました。Hubには2つのMoE(Mixture of Experts)チェックポイントが公開されています:総パラメータ数1.6T、アクティブ49BのDeepSeek-V4-Proと、総パラメータ数284B、アクティブ13BのDeepSeek-V4-Flashです。両者とも1Mトークンのコンテキストウィンドウを備えています。ベンチマークの数値は競争力がありますが、SOTA(State of the Art)ではありません。それは問題ありません。真の革新は、DeepSeek V4が効率的な大規模コンテキスト長サポートのためにどのように設計されているか、そしてそれゆえにエージェントタスクの最有力候補の一つとなっている点にあります。
長時間実行されるエージェントワークロードへの焦点。現在、最先端のオープンモデルをエージェントとして実行すると、予測可能な方法で失敗します。モデルが停止する。再プロンプトする。トレースがコンテキスト予算を超えたり、KVキャッシュ(KV cache)がGPUを埋め尽くしたり、あるいは長時間のタスクの途中でツール呼び出しの往復が劣化したりする。V4はこれらの既知の失敗を修正するために構築されており、コミュニティが従うべき道を示すものです。
本記事では3つのトピックをカバーします:長文コンテキスト推論を低コストにするためにアーキテクチャがどのように異なることをしているか、それに加えて重なるエージェント固有のポストトレーニングでの判断、そしてこれらの変更について推論するのに役立つ論文からのいくつかの知見です。
エージェントにおけるKVキャッシュ(KV cache)の問題
1Mのコンテキストウィンドウは単なる容量であり、パフォーマンスではありません。それを使用できるかどうかは、その深さでのすべてのフォワードパス(forward pass)のコストにかかっています。長時間のツール使用軌道(tool-use trajectory)を実行するエージェントにとって、すべてのツール結果はコンテキストに追加され、その後のすべてのトークンは以前のものすべてに対して完全なアテンションコストを支払います。
重要なのは2つの数値です:単一トークン推論FLOPs(single-token inference FLOPs)とKVキャッシュ(KV cache)サイズ。両者はシーケンス長とともに増加します。1Mトークンにおいて、DeepSeek-V4-ProはDeepSeek-V3.2と比較して単一トークン推論FLOPsの27%しか必要としないため、同じハードウェアでより高速に動作します。また、KVキャッシュメモリも10%しか使用しません。V4-Flashはこれらの数値をさらに低下させます:FLOPsの10%、KVキャッシュの7%です。
8つのヘッドを持つグループドクエリアテンション(Grouped Query Attention)のような確立されたアーキテクチャと比較し、通常のbfloat16形式で保存した場合、DeepSeek V4は約2%のキャッシュサイズしか必要としません。これにより、非常に大規模なコンテキスト処理のためのデプロイがはるかに容易になります。
*図1:ベンチマーク比較(左)、シーケンス長に対するトークンあたりのFLOPsと累積KVキャッシュ(KV cache)(右)。*
ハイブリッドアテンション:CSAとHCA
効率の向上は、アテンションを2つのメカニズムに分割し、レイヤー間でインターリーブ(交互配置)することから得られます。
圧縮スパースアテンション(Compressed Sparse Attention, CSA)は、学習された位置バイアス付きのsoftmaxゲート型プーリングを用いて、シーケンス次元に沿ってKVエントリを4倍に圧縮します。ライトニングインデクサ(FP4、ReLUスコア付きマルチヘッドドット積)は、各クエリに対して上位k個の圧縮ブロックを選択します。これはV3.2のDeepSeekスパースアテンションからスパース選択のアイデアを継承していますが、元のシーケンスよりもすでに4倍短いブロックに対して実行されます。インデクサの探索空間もそれに伴って縮小します。
*Figure 3: CSA. The compressor collapses every 4 tokens into one compressed KV entry. The lightning indexer picks the top-k compressed blocks per query. A sliding-window branch handles the most recent uncompressed tokens.*
重圧縮アテンション(Heavily Compressed Attention, HCA)はKVエントリを128倍に圧縮し、スパース選択を廃止します。すべてのクエリは各圧縮ブロックに対して密なアテンション(Dense Attention)を適用します。圧縮されたシーケンスは十分に短いため、密なアテンションのコストは低くなります。
*Figure 4: HCA. A heavier compressor (128x vs. 4x) followed by dense attention over the compressed stream, with the same sliding-window branch for recency.*
各レイヤーはCSAとHCAを交互に切り替えます。異なるレイヤーは異なるアテンションパターンを担っており、すべてのレイヤーに一つの機構を強制的に適用すると容量が無駄になります。V4-Proの61層構成では、レイヤー0〜1はHCA、レイヤー2〜60はCSAとHCAを交互に切り替え、末尾のMTP(Multi-Token Prediction)ブロックはスライディングウィンドウのみを実行します。
両方のパスは、ほとんどのKVエントリにFP8ストレージを使用し、RoPE(Rotary Positional Embedding)次元にはBF16のみを使用します。CSA内部のライトニングインデクサはFP4で動作します。これらのストレージ選択と圧縮率が相乗的に作用し、KVキャッシュが2%という数値を実現しています。
*Figure 2: overall architecture. Attention layers alternate between CSA and HCA. Feed-forward layers use DeepSeekMoE. Residual connections are replaced with manifold-constrained hyper-connections (mHC).*
エージェントにとっての変更点
効率的なロングコンテキストアテンション(Long-Context Attention)はエージェントワークフローに必要ですが、それだけでは不十分です。本論文では、エージェントの使用ケースを直接対象とした3つのポストトレーニングおよびインフラストラクチャの選択について説明しています。
ツール呼び出しをまたぐ思考のインターリーブ(Interleaved thinking across tool calls)
V3.2はツール結果ラウンドをまたいで推論トレース(Reasoning Traces)を保持しましたが、新しいユーザーメッセージが届くたびに破棄していました。単一のユーザーターンを処理するエージェントにとってはこれで問題ありませんでした。しかし、エージェントがすでに複数のツール呼び出しをチェーンした後にユーザーがフォローアップを送信するマルチターンエージェントワークフローでは、モデルは蓄積された推論を失い、状態を再構築する必要がありました。
V4は、会話にツール呼び出しが含まれる場合、ユーザーメッセージの境界をまたいで推論内容を保持します。モデルはすべてのラウンド、およびユーザーターンをまたいで、完全な推論履歴を保持します。これにより、長期にわたるエージェントタスクで一貫性のある累積的な思考の連鎖(Chain of Thought)が可能になります。ツールを使用しない対話用途では、従来の動作が維持されます:コンテキストを簡潔に保つため、各ターンで推論はフラッシュ(破棄)されます。
*Figure 7: thinking with tools (top) preserves reasoning across all turns. Thinking without tools (bottom) discards reasoning at each new user message.*
専用トークンによるツール呼び出しスキーマ(tool-call schema)
V4では、|DSML|という特殊トークン(special token)とXMLベースのツール呼び出し形式が導入されました。このXML形式は、モデルがネストされた引用コンテンツ(nested quoted content)を出力する際に発生しやすい失敗モードである「JSON文字列内でのツール呼び出し(JSON-in-string tool calls)」に比べて、エスケープ処理の失敗(escaping failures)を減らします。
このスキーマは、文字列パラメータ(string parameters、string="true"でそのまま渡される)と構造化パラメータ(structured parameters、string="false"でJSONとして渡される)を分離しています。これにより、JSONベースのツール呼び出し形式(JSON tool-call formats)で頻繁に発生する数値やブール値に関する一連のパースエラー(parsing errors)が解消されます。
DSec:強化学習ロールアウト(RL rollouts)用に構築されたサンドボックス
エージェントの動作は、実際のツール環境に対して強化学習(Reinforcement Learning, RL)で訓練されました。論文では、その目的のために構築されたサンドボックスインフラストラクチャ(sandbox infrastructure)について説明しています。DeepSeek Elastic Compute(DSec)は、1つのPython SDKの背後に4つの実行基盤(execution substrates)を公開するRustプラットフォームです。これには関数呼び出し、コンテナ、マイクロVM(Firecracker)、フルVM(QEMU)が含まれます。単一のクラスターで、数十万の並行サンドボックスが実行されます。
エージェント訓練において重要なDSecの3つの特徴は、階層型3FSストレージによる高速イメージ読み込み(RLロールアウトがコンテナの起動を待たなくて済むように)、プリエンプション安全な軌道リプレイ(preemption-safe trajectory replay、中断された訓練ステップがツール呼び出しを再実行せずに再開できるように)、そして基盤全体にわたる統一API(訓練ハーネス(training harnesses)が書き換えなしで関数呼び出しまたはフルVMを対象にできるように)です。これらのインフラストラクチャの決定が、エージェントベンチマークスコア(agent benchmark scores)の基盤となっています。
エージェントベンチマーク結果(agent benchmark results)
知識と推論の数値は競争力がありますが、トップではありません。エージェントの数値こそが、V4-Pro-Maxが他のモデルを大きく引き離す部分です。
表6のエージェントセクションからの具体的な数値は以下の通りです:
- Terminal Bench 2.0:V4-Pro-Maxは67.9点を記録し、GLM-5.1(63.5)やK2.6(66.7)を上回り、GPT-5.4-xHigh(75.1)やGemini-3.1-Pro(68.5)には及びません。
- SWE Verified:80.6件の解決。Opus-4.6-Max(80.8)およびGemini-3.1-Pro(80.6)とほぼ同点です。
- MCPAtlas Public:73.6。Opus-4.6-Max(73.8)に次ぐ第2位です。
- Toolathlon:51.8。K2.6(50.0)、GLM-5.1(40.7)、Gemini-3.1-Pro(48.8)を上回ります。
論文内の社内R&Dコーディングベンチマークでは、PyTorch、CUDA、Rust、C++にわたる30の厳選タスクにおいて、V4-Pro-Maxは67%の合格率を記録しました。Sonnet 4.5(47%)やOpus 4.5(70%)と比較した結果です。V4-Proを日常の主要モデルとして使用しているDeepSeekの開発者85名への調査では、52%が現在の主要コーディングモデルを置き換える準備ができていると回答し、39%が「はい」に傾いていると答えました。
長期コンテキストの検索数値は図9に示されています。MRCR 8-needleの精度(accuracy)は256Kトークンまで0.82以上を維持し、1Mでは0.59で安定しています。
*図9:MRCR 8-needle検索。V4-Pro-Maxは256Kまで0.82以上を維持し、1Mで0.59に落ち着きます。*
モデルの使用(Using the models)
4つのチェックポイント(checkpoints)がHubに公開されています。インストラクトモデルは、MoEのエキスパート重み(MoE expert weights)にFP4を、その他にFP8を使用しています。ベースモデルは全体がFP8です。
- deepseek-ai/DeepSeek-V4-Pro(1.6T / 49B活性化、インストラクト)
- deepseek-ai/DeepSeek-V4-Flash(284B / 13B活性化、インストラクト)
- deepseek-ai/DeepSeek-V4-Pro-Base(1.6T / 49B活性化、ベース)
- deepseek-ai/DeepSeek-V4-Flash-Base(284B / 13B活性化、ベース)
原文を表示
- The KV cache problem for agents
- Hybrid attention: CSA and HCA
- What changes for agents Interleaved thinking across tool calls
- Tool-call schema with dedicated tokens
- DSec: a sandbox built for RL rollouts
- Agent benchmark results
- Using the models
DeepSeek released V4 today. Two MoE checkpoints are on the Hub: DeepSeek-V4-Pro at 1.6T total parameters with 49B active, and DeepSeek-V4-Flash at 284B total with 13B active. Both have a 1M-token context window. The benchmark numbers are competitive, but not SOTA. It doesn't matter. The real innovation is how DeepSeek v4 is designed for efficient large context length support, and hence as one of the best candidates for agentic tasks.
Focusing on long running agentic workloads. Running a frontier open model as an agent today breaks in predictable ways. The model stops. You reprompt. The trace blows past the context budget, or the KV cache fills the GPU, or tool-call round trips degrade halfway through a long task. V4 is built to fix these known failures, and point the way for the community to follow.
This post covers three things: what the architecture does differently to make long-context inference cheap, the agent-specific post-training decisions that compound on top of it, and some takeaways from the paper that help reason about these changes.
The KV cache problem for agents
A 1M context window is just capacity, not performance. Whether you can use it depends on the cost of every forward pass at that depth. For an agent running a long tool-use trajectory (a SWE-bench task, a multi-step browse session, a terminal session with hundreds of commands), every tool result is appended to the context, and every subsequent token pays the full attention cost against everything that came before.
Two numbers matter: single-token inference FLOPs and KV cache size. Both grow with sequence length. At 1M tokens, DeepSeek-V4-Pro requires 27% of single-token inference FLOPs compared with DeepSeek-V3.2, so it runs faster on the same hardware. It also uses 10% of the KV cache memory. V4-Flash drops these numbers even further: 10% of the FLOPs and 7% of the KV cache.
If we compare the KV cache memory against a established architecture like grouped query attention with 8 heads, stored in the usual bfloat16 format, DeepSeek v4 requires roughly 2% the cache size. This makes it much easier to deploy for very large context handling.
*Figure 1: benchmark comparison (left), per-token FLOPs and accumulated KV cache against sequence length (right).*
Hybrid attention: CSA and HCA
The efficiency gain comes from splitting attention into two mechanisms and interleaving them across layers.
Compressed Sparse Attention (CSA) compresses KV entries by 4x along the sequence dimension using softmax-gated pooling with a learned positional bias. A lightning indexer (FP4, ReLU-scored multi-head dot product) picks the top-k compressed blocks per query. It inherits the sparse-selection idea from DeepSeek Sparse Attention in V3.2, but runs it over blocks that are already 4x shorter than the original sequence. The indexer's search space shrinks with it.
*Figure 3: CSA. The compressor collapses every 4 tokens into one compressed KV entry. The lightning indexer picks the top-k compressed blocks per query. A sliding-window branch handles the most recent uncompressed tokens.*
Heavily Compressed Attention (HCA) compresses KV entries by 128x and drops the sparse selection. Every query attends densely to every compressed block. The compressed sequence is short enough that dense attention is cheap.
*Figure 4: HCA. A heavier compressor (128x vs. 4x) followed by dense attention over the compressed stream, with the same sliding-window branch for recency.*
The layers alternate between CSA and HCA. Different layers carry different attention patterns, and forcing one mechanism across all of them wastes capacity. In V4-Pro's 61-layer stack, layers 0–1 are HCA, layers 2–60 alternate CSA and HCA, and the MTP block at the end runs sliding-window only.
Both paths use FP8 storage for most KV entries and BF16 only for the RoPE dimensions. The lightning indexer inside CSA runs in FP4. These storage choices compound with the compression ratios to produce the 2% KV cache figure.
*Figure 2: overall architecture. Attention layers alternate between CSA and HCA. Feed-forward layers use DeepSeekMoE. Residual connections are replaced with manifold-constrained hyper-connections (mHC).*
What changes for agents
Efficient long-context attention is necessary for agent workflows but not sufficient. The paper describes three post-training and infrastructure choices that target agent use cases directly.
Interleaved thinking across tool calls
V3.2 kept reasoning traces across tool-result rounds but discarded them whenever a new user message arrived. For an agent handling a single user turn, this was fine. For multi-turn agentic workflows, where the user sends a follow-up after the agent has already chained several tool calls, the model lost its accumulated reasoning and had to reconstruct state.
V4 preserves reasoning content across user message boundaries when the conversation contains tool calls. The model retains the complete reasoning history across all rounds, including across user turns. This allows a coherent, cumulative chain of thought over long-horizon agent tasks. For conversational use without tools, the old behavior is preserved: reasoning is flushed on each turn to keep context concise.
*Figure 7: thinking with tools (top) preserves reasoning across all turns. Thinking without tools (bottom) discards reasoning at each new user message.*
Tool-call schema with dedicated tokens
V4 introduces a |DSML| special token and an XML-based tool-call format. The XML format reduces escaping failures compared to JSON-in-string tool calls, a common failure mode when models emit nested quoted content.
The schema separates string parameters (passed as-is with string="true") from structured parameters (passed as JSON with string="false"). This removes a class of parsing errors around numbers and booleans that JSON tool-call formats routinely hit.
DSec: a sandbox built for RL rollouts
The agent behavior was trained with RL against real tool environments. The paper describes the sandbox infrastructure built for that purpose. DeepSeek Elastic Compute (DSec) is a Rust platform that exposes four execution substrates behind one Python SDK: function calls, containers, microVMs (Firecracker), and full VMs (QEMU). A single cluster runs hundreds of thousands of concurrent sandboxes.
Three DSec features matter for agent training: fast image loading via layered 3FS storage (so RL rollouts do not wait on container startup), preemption-safe trajectory replay (so interrupted training steps resume without re-running tool calls), and a uniform API across substrates (so training harnesses target function calls or full VMs without rewriting). These infrastructure decisions underpin the agent benchmark scores.
Agent benchmark results
The knowledge and reasoning numbers are competitive but not leading. The agent numbers are where V4-Pro-Max separates from the field.
Specific numbers from the agent section of Table 6:
- Terminal Bench 2.0: V4-Pro-Max scores 67.9, ahead of GLM-5.1 (63.5) and K2.6 (66.7), behind GPT-5.4-xHigh (75.1) and Gemini-3.1-Pro (68.5).
- SWE Verified: 80.6 resolved, within a point of Opus-4.6-Max (80.8) and Gemini-3.1-Pro (80.6).
- MCPAtlas Public: 73.6, second only to Opus-4.6-Max (73.8).
- Toolathlon: 51.8, ahead of K2.6 (50.0), GLM-5.1 (40.7), and Gemini-3.1-Pro (48.8).
In the paper's internal R&D coding benchmark, 30 curated tasks across PyTorch, CUDA, Rust, and C++, V4-Pro-Max hits 67% pass rate, versus 47% for Sonnet 4.5 and 70% for Opus 4.5. In a survey of 85 DeepSeek developers using V4-Pro as their daily driver, 52% said it was ready to replace their current primary coding model and 39% leaned toward yes.
The long-context retrieval numbers are in Figure 9. MRCR 8-needle accuracy stays above 0.82 through 256K tokens and holds at 0.59 at 1M.
*Figure 9: MRCR 8-needle retrieval. V4-Pro-Max stays above 0.82 through 256K and holds at 0.59 at 1M.*
Using the models
Four checkpoints are on the Hub. The instruct models use FP4 for MoE expert weights and FP8 for everything else. The base models are FP8 throughout.
- deepseek-ai/DeepSeek-V4-Pro (1.6T / 49B activated, instruct)
- deepseek-ai/DeepSeek-V4-Flash (284B / 13B activated, instruct)
- deepseek-ai/DeepSeek-V4-Pro-Base (1.6T / 49B activated, base)
- deepseek-ai/DeepSeek-V4-Flash-Base (284B / 13B activated, base)
Both instruct models support three reasoning modes: Non-think (fast, no chain of thought), Think High (explicit reasoning in <think> blocks), and Think Max (maximum reasoning effort with a dedicated system prompt). Think Max requires a context window of at least 384K tokens. The recommended sampling parameters across all modes are temperature=1.0, top_p=1.0.
The V4-Pro numbers on SWE Verified, MCPAtlas, and the internal R&D benchmark put it at parity with frontier closed models on agent tasks. The open question is how the community's tool harnesses adapt to the |DSML| schema and whether the interleaved thinking gains transfer to out-of-domain agent frameworks.
Figures in this blog post are from the technical report at DeepSeek_V4.pdf.
関連記事
駿馬が春を迎え、共に新たな境地へ駆ける | DeepSeek 丙午新年・春節 AI 挨拶
DeepSeekが春節の挨拶を発表し、AI技術の進展と新年の希望を詩的な表現で示した。
DeepSeek V4 Flash のための軽量ネイティブ推論エンジン「ds4.c」が GitHub に公開
開発チームは、DeepSeek V4 Flash 専用として意図的に小型化されたローカル推論エンジン「ds4.c」を公開した。このプロジェクトはエンドツーエンドで完成したモデル体験を目指し、現在は Metal 環境のみ対応のアルファ版だが、将来的に CUDA サポートも検討されている。
NVIDIA BlackwellとGPUアクセラレーションエンドポイントを用いたDeepSeek V4の構築
DeepSeekは第4世代フラッグシップモデル「V4-Pro/Flash」を公開し、NVIDIA BlackwellとGPUアクセラレーションエンドポイントを活用した構築環境を提供した。