DeepSeek R1: オープンソース推論モデル
先週、中国のAI企業であるDeepSeekは、待望のオープンソース推論モデル「DeepSeek R1
」を発表しました。ディストール版*とフルサイズ版の両方のDeepSeek R1モデルは、Mac、Windows、Linux上のLM Studioでローカルに実行できます。
DeepSeek R1をQwen 7B (MLX, 4-bit)にディストールし、M1 Macで代数問題を100%オフラインで解決しています。
この1週間ほどインターネットを見ていた方なら、DeepSeekに関するニュースを見逃すことはなかったでしょう。
DeepSeek R1モデルは、オープンに利用可能なモデルにとって重要かつエキサイティングなマイルストーンとなります。OpenAIのo1モデルと同様の「推論」モデルを、ローカルシステムで実行できるようになりました。必要なのは十分なRAMだけです。
DeepSeekによるリリースには以下が含まれます。
はい、十分なRAMがあれば実行できます。
方法はこちらです。
推論モデルは、最終的な回答を提供する前に「思考」するように訓練されています。これは、「思考の連鎖(Chain-of-thought, CoT)」と呼ばれる手法を使用して行われます。CoTは、モデルが複雑な問題をより小さく、より管理しやすいステップに分解することを促す手法です。これにより、モデルは一度に問題を解決しようとするのではなく、一連の中間ステップを通じて最終的な回答にたどり着くことができます。DeepSeekのCoTは、<think>...</think>
トークンに含まれています。
重要ではない質問をされた場合、DeepSeekモデルは応答を<think>
トークンで開始します。その後の内容は、モデルが問題を段階的に解き進めているような長い思考の流れのように見えることがよくあります。閉じタグの</think>
トークンの後、モデルは通常のコンテンツ(質問に対する最終的な回答)の生成を開始します。</think>
トークン後の内容は、<think>
セクション内のコンテンツに直接影響されます。
以下はDeepSeek-R1-Distill-Qwen-7Bの出力で、「トマトは果物ですか?」という質問に全体的に「思考」して回答する能力を示しています。思考セクションは<think>...</think>
タグで囲まれています。
ユーザーの質問
トマトは果物ですか?
モデルの回答
DeepSeek-R1-Distill-Qwen-7B: <think> Okay, so I'm trying to figure out whether tomatoes are fruits or vegetables. I know that in many places like Italy, they're definitely considered fruits because you can eat them raw and they have a sweet taste. But here in the US, it's usually said they're vegetables. Hmm, why is there this difference? I remember learning that fruits come from flowers that aren't pollinated, right? Like roses where bees don't help them reproduce. Tomatoes grow on vines and are typically picked when ripe. They have seeds inside which you eat. On the other hand, vegetables usually come from plants that do get pollinated, like carrots or tomatoes when they're on a plant with flowers. Wait, but tomatoes can be both eaten raw and cooked, just like many fruits. So maybe it's more about how they're grown rather than their natural state. I think the confusion comes from different regions having different classifications. In Italy, they're definitely fruits because they're used as such in dishes without needing to be cooked down or anything. I guess in the US, tomatoes are considered vegetables because they come from plants that do produce flowers and require pollination by insects like bees. So even though you can eat them raw, their classification as a vegetable is based on their origin and how they're typically used in cooking here. But then again, I've seen them used both ways—like people making sauces or just eating them as snacks. But maybe in the culinary sense, they're more often used as vegetables because of their typical preparation methods like slicing or chopping for soups or salads. So it's probably a matter of regional definitions and how they are primarily consumed here versus where they might be considered fruits naturally. </think> Tomatoes can be both fruits and vegetables depending on the context: Fruit Perspective: In many countries, including Italy, tomatoes are classified as fruits because they grow on vines without needing pollination and can be eaten raw with a sweet taste. Vegetable Perspective (US Context): In the United States, tomatoes are considered vegetables due to their origin from plants that do produce flowers and require pollination by insects like bees. They are often used in cooking methods such as slicing or chopping for soups and salads, which aligns more with vegetable preparation. Thus, the classification of tomatoes can vary based on regional definitions and usage.
AIME 2024、MATH-500、CodeForcesなどのいくつかの一般的な推論ベンチマークによると、オープンソースのフラッグシップ671BパラメータDeepSeek-R1モデルは、OpenAIのフルサイズo1推論モデルに匹敵する性能を発揮します。より小型のDeepSeek-R1「ディストール」モデルは、OpenAIのo1-mini推論モデルに匹敵する性能を発揮します。
出典: Xの@deepseek_ai
DeepSeek-R1の「ディストール」とは、Llama3やQwen2.5のようなより小さな「密なモデル」を、より大きなモデルによって生成された成果物を使用してファインチューニングし、その中に大きなモデルに似た能力を植え付けることを意味します。
DeepSeekは、DeepSeek-R1から約80万(推論60万、非推論20万)の高品質な生成物を厳選し、それらのデータでLlama3およびQwen2.5モデルを訓練することによってこれを実現しました(出典: DeepSeekのR1公開資料)。
これは、既存のより小さなモデルにDeepSeek-R1のように推論する方法を「教える」効率的な手法です。
DeepSeek-R1は、主に教師なし強化学習を使用して訓練されました。これは、人間がラベル付けされた教師ありファインチューニング(SFT)データをそれほど多く整理する必要がなかったことを意味するため、重要な成果です。
DeepSeek-R1の先行モデルであるDeepSeek-R1-Zeroは、強化学習のみを使用してファインチューニングされました。しかし、可読性や言語の混在に問題がありました。
DeepSeekは最終的に、DeepSeek-R1-Zeroの欠点を克服しつつ、RLの斬新さとコストメリットを維持するために、SFTとRLの手法を組み合わせたR1向けの多段階トレーニングパイプラインにたどり着きました。
トレーニングに関するより詳細な情報は、DeepSeekのR1公開資料で確認できます。
LM StudioのAPIを活用して、独自のコードからDeepSeek R1モデルを呼び出すことができます。
関連ドキュメントのリンクを以下に示します。
lms
: LM StudioのCLI