1 Understanding DeepSeek R1
Antoinette Steere edited this page 2025-02-09 23:40:33 +08:00


DeepSeek-R1 is an open-source language model developed on DeepSeek-V3-Base that's been making waves in the AI community. Not only does it match-or even surpass-OpenAI's o1 model in numerous standards, but it also includes totally MIT-licensed weights. This marks it as the first non-OpenAI/Google design to deliver strong reasoning capabilities in an open and available way.

What makes DeepSeek-R1 especially exciting is its openness. Unlike the less-open approaches from some market leaders, has actually released a detailed training method in their paper. The model is also remarkably economical, with input tokens costing just $0.14-0.55 per million (vs o1's $15) and output tokens at $2.19 per million (vs o1's $60).

Until ~ GPT-4, the typical knowledge was that much better designs needed more information and compute. While that's still legitimate, models like o1 and R1 show an option: inference-time scaling through thinking.

The Essentials

The DeepSeek-R1 paper presented several designs, however main among them were R1 and R1-Zero. Following these are a series of distilled models that, while interesting, drapia.org I won't discuss here.

DeepSeek-R1 utilizes two major concepts:

1. A multi-stage pipeline where a small set of cold-start data kickstarts the model, followed by massive RL. 2. Group Relative Policy Optimization (GRPO), a reinforcement learning approach that counts on comparing several design outputs per timely to prevent the need for a different critic.

R1 and R1-Zero are both thinking designs. This essentially suggests they do Chain-of-Thought before answering. For the R1 series of models, this takes type as thinking within a tag, before answering with a final summary.

R1-Zero vs R1

R1-Zero uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base without any supervised fine-tuning (SFT). RL is utilized to optimize the design's policy to make the most of benefit. R1-Zero attains excellent accuracy however in some cases produces complicated outputs, such as mixing numerous languages in a single reaction. R1 repairs that by including minimal monitored fine-tuning and numerous RL passes, which improves both accuracy and readability.

It is interesting how some languages might express certain concepts much better, which leads the model to select the most meaningful language for the job.

Training Pipeline

The training pipeline that DeepSeek released in the R1 paper is tremendously intriguing. It showcases how they created such strong thinking models, and what you can anticipate from each stage. This consists of the problems that the resulting models from each stage have, and how they fixed it in the next stage.

It's interesting that their training pipeline differs from the typical:

The typical training method: Pretraining on big dataset (train to forecast next word) to get the base design → monitored fine-tuningpreference tuning through RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with several SFT and RL stages

Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a few thousand Chain-of-Thought (CoT) samples to guarantee the RL process has a good beginning point. This provides a great model to begin RL. First RL Stage: Apply GRPO with rule-based benefits to enhance thinking correctness and formatting (such as requiring chain-of-thought into thinking tags). When they were near merging in the RL procedure, they transferred to the next step. The result of this action is a strong reasoning model but with weak general abilities, e.g., poor format and language mixing. Rejection Sampling + general information: Create brand-new SFT data through rejection tasting on the RL checkpoint (from action 2), combined with supervised information from the DeepSeek-V3-Base design. They collected around 600k top quality thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k reasoning + 200k basic jobs) for broader abilities. This action led to a strong reasoning model with general abilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to improve the final design, in addition to the reasoning rewards. The result is DeepSeek-R1. They likewise did design distillation for a number of Qwen and Llama models on the thinking traces to get distilled-R1 models.

Model distillation is a method where you use a teacher model to enhance a trainee design by creating training data for the trainee model. The teacher is generally a larger model than the trainee.

Group Relative Policy Optimization (GRPO)

The standard concept behind using reinforcement learning for LLMs is to fine-tune the design's policy so that it naturally produces more accurate and beneficial answers. They utilized a reward system that examines not only for accuracy however likewise for correct formatting and language consistency, so the model gradually learns to favor actions that fulfill these quality criteria.

In this paper, they encourage the R1 model to generate chain-of-thought reasoning through RL training with GRPO. Rather than adding a different module at reasoning time, the training procedure itself pushes the model to produce detailed, detailed outputs-making the chain-of-thought an emergent habits of the optimized policy.

What makes their method particularly interesting is its reliance on straightforward, rule-based benefit functions. Instead of depending on pricey external designs or human-graded examples as in traditional RLHF, the RL utilized for R1 uses easy criteria: it may give a greater benefit if the answer is right, if it follows the expected/ formatting, and if the language of the response matches that of the timely. Not relying on a reward model likewise means you don't need to hang out and effort training it, and it doesn't take memory and calculate away from your main design.

GRPO was presented in the DeepSeekMath paper. Here's how GRPO works:

1. For each input timely, the model produces different responses. 2. Each reaction receives a scalar benefit based on aspects like precision, formatting, and language consistency. 3. Rewards are changed relative to the group's performance, basically measuring how much better each action is compared to the others. 4. The design updates its technique slightly to prefer responses with higher relative advantages. It only makes slight adjustments-using methods like clipping and a KL penalty-to make sure the policy doesn't stray too far from its original habits.

A cool element of GRPO is its flexibility. You can use basic rule-based reward functions-for circumstances, awarding a perk when the design properly utilizes the syntax-to guide the training.

While DeepSeek utilized GRPO, you could utilize alternative methods instead (PPO or PRIME).

For those aiming to dive much deeper, utahsyardsale.com Will Brown has composed quite a good execution of training an LLM with RL utilizing GRPO. GRPO has also currently been added to the Transformer Reinforcement Learning (TRL) library, which is another great resource. Finally, Yannic Kilcher has a great video explaining GRPO by going through the DeepSeekMath paper.

Is RL on LLMs the course to AGI?

As a final note on explaining DeepSeek-R1 and the methods they have actually provided in their paper, I wish to highlight a passage from the DeepSeekMath paper, based upon a point Yannic Kilcher made in his video.

These findings show that RL boosts the model's general efficiency by rendering the output circulation more robust, in other words, it appears that the improvement is associated to enhancing the correct response from TopK instead of the improvement of basic capabilities.

To put it simply, RL fine-tuning tends to shape the output distribution so that the highest-probability outputs are more most likely to be correct, although the total capability (as determined by the variety of right responses) is mainly present in the pretrained model.

This recommends that support knowing on LLMs is more about refining and "shaping" the existing circulation of reactions rather than enhancing the model with completely brand-new capabilities. Consequently, while RL strategies such as PPO and GRPO can produce substantial performance gains, there appears to be an intrinsic ceiling figured out by the underlying model's pretrained knowledge.

It is uncertain to me how far RL will take us. Perhaps it will be the stepping stone to the next huge turning point. I'm delighted to see how it unfolds!

Running DeepSeek-R1

I've utilized DeepSeek-R1 through the main chat user interface for numerous issues, which it appears to solve all right. The extra search performance makes it even nicer to utilize.

Interestingly, o3-mini(-high) was released as I was writing this post. From my initial testing, R1 seems more powerful at math than o3-mini.

I likewise leased a single H100 through Lambda Labs for $2/h (26 CPU cores, 214.7 GB RAM, 1.1 TB SSD) to run some experiments. The main objective was to see how the design would perform when released on a single H100 GPU-not to extensively test the model's capabilities.

671B by means of Llama.cpp

DeepSeek-R1 1.58-bit (UD-IQ1_S) quantized design by Unsloth, with a 4-bit quantized KV-cache and partial GPU offloading (29 layers operating on the GPU), running by means of llama.cpp:

29 layers seemed to be the sweet area offered this setup.

Performance:

A r/localllama user explained that they had the ability to get over 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their local video gaming setup. Digital Spaceport wrote a full guide on how to run Deepseek R1 671b completely locally on a $2000 EPYC server, on which you can get ~ 4.25 to 3.5 tokens per second.

As you can see, the tokens/s isn't rather bearable for any severe work, but it's enjoyable to run these big designs on available hardware.

What matters most to me is a mix of usefulness and time-to-usefulness in these designs. Since reasoning designs require to believe before addressing, their time-to-usefulness is usually higher than other designs, however their usefulness is also usually higher. We require to both maximize effectiveness and reduce time-to-usefulness.

70B via Ollama

70.6 b params, 4-bit KM quantized DeepSeek-R1 running via Ollama:

GPU usage soars here, as expected when compared to the mainly CPU-powered run of 671B that I showcased above.

Resources

DeepSeek-R1: Incentivizing Reasoning Capability in LLMs by means of Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a completely regional "deep scientist" with DeepSeek-R1 - YouTube). DeepSeek R1's recipe to reproduce o1 and the future of thinking LMs. The Illustrated DeepSeek-R1 - by Jay Alammar. Explainer: What's R1 & Everything Else? - Tim Kellogg. DeepSeek R1 Explained to your grandmother - YouTube

DeepSeek

- Try R1 at chat.deepseek.com. GitHub - deepseek-ai/DeepSeek-R 1. deepseek-ai/Janus-Pro -7 B · Hugging Face (January 2025): Janus-Pro is an unique autoregressive framework that merges multimodal understanding and generation. It can both comprehend and produce images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source reasoning model that matches the performance of OpenAI's o1. It provides a detailed approach for training such models utilizing large-scale reinforcement learning techniques. DeepSeek-V3 Technical Report (December 2024) This report discusses the implementation of an FP8 mixed accuracy training structure validated on an incredibly large-scale design, attaining both accelerated training and minimized GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper dives into scaling laws and provides findings that facilitate the scaling of massive models in open-source setups. It presents the DeepSeek LLM project, committed to advancing open-source language designs with a long-lasting perspective. DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research presents the DeepSeek-Coder series, a variety of open-source code models trained from scratch on 2 trillion tokens. The designs are pre-trained on a top quality project-level code corpus and employ a fill-in-the-blank task to improve code generation and infilling. DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model (May 2024) This paper provides DeepSeek-V2, a Mixture-of-Experts (MoE) language model characterized by economical training and effective inference. DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research introduces DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language model that attains performance equivalent to GPT-4 Turbo in code-specific tasks.

Interesting occasions

- Hong Kong University reproduces R1 results (Jan 25, '25).