DeepSeek R1: オープンソースの推論モデル

2025-01-29

先週、中国のAI企業である DeepSeek は、待望のオープンソース推論モデル「 DeepSeek R1 」をリリースしました。DeepSeek R1モデルは、蒸留版とフルサイズ版の両方が、Mac、Windows、LinuxのLM Studioでローカル実行可能です。

* 蒸留モデルとその作成方法については、以下をお読みください。

DeepSeek R1をQwen 7B(MLX、4ビット)に蒸留し、代数問題を解決。M1 Macで100%オフライン。

DeepSeek R1モデル、蒸留版とフルサイズ版

もしここ一週間ほどオンラインで活動していたなら、DeepSeekのニュースを見逃していない可能性はほとんどありません。

DeepSeek R1モデルは、オープンで利用可能なモデルにとって、重要でエキサイティングなマイルストーンとなります。ローカルシステムで、OpenAIのo1モデルに似た「推論」モデルを実行できるようになりました。必要なのは十分なRAMだけです。

DeepSeekからのリリースには以下が含まれます:

  • DeepSeek-R1 - フラッグシップの671Bパラメータ推論モデル
  • DeepSeek-R1 蒸留モデル: DeepSeek-R1の生成物を使用してファインチューニングされた、既存の小規模モデルのコレクション(1.5B、7B、8B、14B、32B、70Bパラメータ)。例としては、DeepSeek-R1-Distill-Qwen-7Bがあります。
  • DeepSeek-R1-Zero - 非教師あり強化学習(RL)のみを使用してファインチューニングされたR1プロトタイプ

DeepSeek R1モデルをローカルで実行できますか?

はい、十分なRAMがあれば可能です。

実行方法はこちら

  • LM Studioを、お使いのオペレーティングシステム用にこちらからダウンロードしてください。
  • サイドバーの🔎アイコンをクリックし、「DeepSeek」を検索します。
  • お使いのシステムに合うオプションを選択してください。例えば、16GBのRAMをお持ちなら、7Bまたは8Bパラメータの蒸留モデルを実行できます。約192GB以上のRAMをお持ちなら、671Bパラメータのフルモデルを実行できます。
  • チャットでモデルをロードし、質問を開始してください!

推論モデルとは何ですか?

推論モデルは、最終的な回答を提供する前に「思考」するように訓練されています。これは「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推論モデルに匹敵するパフォーマンスを発揮します。

蒸留

DeepSeek-R1を「蒸留」するとは: Llama3やQwen2.5のような小規模な「密モデル」を取得し、より大規模なモデルの能力に似せることを意図して、大規模モデルが生成したアーティファクトを使用してファインチューニングすることです。

DeepSeekは、DeepSeek-R1からの約80万件(60万件の推論、20万件の非推論)の高品質な生成物をキュレーションし、Llama3とQwen2.5モデルをそれらでトレーニングすることでこれを実現しました(出典: DeepSeekのR1論文)。

これは、小規模な既存モデルにDeepSeek-R1のように推論する方法を「教える」ための効率的な技術です。

トレーニング

DeepSeek-R1は、主に非教師あり強化学習を使用してトレーニングされました。これは、人間がラベル付き教師ありファインチューニング(SFT)データをそれほど多くキュレーションする必要がなかったため、重要な成果です。

DeepSeek-R1-Zero、DeepSeek-R1の前身は、のみ強化学習を使用してファインチューニングされていました。しかし、可読性と言語の混在に問題がありました。

DeepSeekは最終的に、RLの新規性とコストメリットを維持しつつ、DeepSeek-R1-Zeroの欠点を解決するために、SFTとRL技術を混合したR1のマルチステージトレーニングパイプラインに到達しました。

トレーニングに関するより詳細な情報は、 DeepSeekのR1論文 で確認できます。

独自のコードからDeepSeek R1モデルをローカルで使用する

LM StudioのAPIを利用して、独自のコードからDeepSeek R1モデルを呼び出すことができます。

関連するドキュメントリンクはこちらです。

さらに詳しく