Clone
1
Understanding DeepSeek R1
Aaron Barbosa edited this page 2025-02-10 01:38:31 +02:00


DeepSeek-R1 is an open-source language design developed on DeepSeek-V3-Base that's been making waves in the AI neighborhood. Not just does it match-or even surpass-OpenAI's o1 design in many benchmarks, but it also comes with fully MIT-licensed weights. This marks it as the very first non-OpenAI/Google model to provide strong thinking abilities in an open and available manner.

What makes DeepSeek-R1 especially interesting is its openness. Unlike the less-open methods from some market leaders, DeepSeek has actually published a detailed training approach in their paper. The design is also remarkably economical, with input tokens costing simply $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 common wisdom was that much better models required more data and calculate. While that's still legitimate, designs like o1 and R1 demonstrate an option: inference-time scaling through thinking.

The Essentials

The DeepSeek-R1 paper provided several models, however main among them were R1 and R1-Zero. Following these are a series of distilled models that, while fascinating, I will not go over here.

DeepSeek-R1 uses 2 significant ideas:

1. A multi-stage pipeline where a small set of cold-start information kickstarts the model, followed by massive RL. 2. Group Relative Policy Optimization (GRPO), a support learning approach that relies on comparing multiple design outputs per prompt to avoid the need for a separate critic.

R1 and R1-Zero are both thinking models. This essentially means they do Chain-of-Thought before addressing. For the R1 series of models, this takes type as believing within a tag, before responding to with a last summary.

R1-Zero vs R1

R1-Zero uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no monitored fine-tuning (SFT). RL is utilized to optimize the model's policy to maximize reward. R1-Zero attains outstanding accuracy but often produces confusing outputs, such as mixing several languages in a single reaction. R1 repairs that by including limited supervised fine-tuning and multiple RL passes, which improves both correctness and oke.zone readability.

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

Training Pipeline

The training pipeline that DeepSeek published in the R1 paper is tremendously interesting. It showcases how they produced such strong thinking designs, and what you can expect from each phase. This consists of the issues that the resulting designs from each phase have, and how they solved it in the next stage.

It's interesting that their training pipeline varies from the usual:

The normal training technique: Pretraining on big dataset (train to anticipate next word) to get the base model → monitored fine-tuning → choice tuning through RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with numerous SFT and RL stages

Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a couple of thousand Chain-of-Thought (CoT) samples to guarantee the RL process has a good beginning point. This offers an excellent model to start RL. First RL Stage: Apply GRPO with rule-based rewards to enhance thinking correctness and format (such as forcing chain-of-thought into believing tags). When they were near merging in the RL procedure, they relocated to the next step. The outcome of this action is a strong thinking model however with weak basic abilities, e.g., bad format and language mixing. Rejection Sampling + basic data: Create new SFT information through rejection sampling on the RL checkpoint (from action 2), integrated with monitored data from the DeepSeek-V3-Base model. They collected around 600k high-quality thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k basic jobs) for more comprehensive capabilities. This action resulted in a strong reasoning design with general capabilities. Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to fine-tune the last model, in addition to the reasoning benefits. The outcome is DeepSeek-R1. They likewise did design distillation for numerous Qwen and Llama designs on the to get distilled-R1 models.

Model distillation is a strategy where you use an instructor model to improve a trainee model by producing training information for the trainee design. The instructor is typically a larger design than the trainee.

Group Relative Policy Optimization (GRPO)

The basic concept behind using reinforcement knowing for LLMs is to tweak the model's policy so that it naturally produces more accurate and helpful answers. They used a benefit system that examines not only for correctness but also for appropriate formatting and language consistency, so the model gradually discovers to favor reactions that fulfill these quality requirements.

In this paper, they motivate the R1 design to generate chain-of-thought thinking through RL training with GRPO. Instead of including a different module at inference time, the training procedure itself nudges the model to produce detailed, detailed outputs-making the chain-of-thought an emerging behavior of the enhanced policy.

What makes their approach especially intriguing is its dependence on straightforward, rule-based benefit functions. Instead of depending on costly external models or human-graded examples as in standard RLHF, the RL used for R1 utilizes easy criteria: it might provide a greater benefit if the answer is appropriate, if it follows the expected/ formatting, and if the language of the answer matches that of the timely. Not counting on a reward model likewise suggests you don't need to hang out and effort training it, wiki-tb-service.com and it does not take memory and compute far from your main model.

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

1. For each input timely, the model generates different reactions. 2. Each response receives a scalar reward based on factors like precision, formatting, and language consistency. 3. Rewards are adjusted relative to the group's efficiency, basically measuring just how much better each response is compared to the others. 4. The model updates its method slightly to prefer reactions with higher relative advantages. It only makes small adjustments-using methods like clipping and a KL penalty-to guarantee the policy doesn't wander off too far from its initial behavior.

A cool aspect of GRPO is its versatility. You can use easy rule-based benefit functions-for circumstances, granting a bonus offer when the design properly uses the syntax-to guide the training.

While DeepSeek utilized GRPO, you might use alternative techniques rather (PPO or PRIME).

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

Is RL on LLMs the path to AGI?

As a last note on explaining DeepSeek-R1 and the approaches they've provided in their paper, I desire to highlight a passage from the DeepSeekMath paper, based on a point Yannic Kilcher made in his video.

These findings show that RL enhances the design's general performance by rendering the output distribution more robust, to put it simply, it seems that the improvement is credited to boosting the right action from TopK rather than the improvement of fundamental abilities.

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

This suggests that support knowing on LLMs is more about refining and "shaping" the existing circulation of reactions instead of enhancing the model with completely new abilities. Consequently, while RL methods such as PPO and GRPO can produce considerable efficiency gains, there seems an inherent ceiling identified by the underlying design's pretrained knowledge.

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

Running DeepSeek-R1

I have actually utilized DeepSeek-R1 by means of the main chat user interface for numerous problems, which it seems to resolve well enough. The extra search performance makes it even nicer to use.

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

I likewise rented 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 model would carry out when deployed on a single H100 GPU-not to thoroughly test the model's abilities.

671B via Llama.cpp

DeepSeek-R1 1.58-bit (UD-IQ1_S) quantized model by Unsloth, with a 4-bit quantized KV-cache and partial GPU offloading (29 layers running on the GPU), historydb.date running through llama.cpp:

29 layers appeared to be the sweet spot provided this setup.

Performance:

A r/localllama user explained that they were able to get over 2 tok/sec with DeepSeek R1 671B, without using their GPU on their local gaming setup. Digital Spaceport wrote a complete 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 quite bearable for any serious work, but it's enjoyable to run these large models on available hardware.

What matters most to me is a combination of effectiveness and time-to-usefulness in these designs. Since reasoning models need to believe before answering, their time-to-usefulness is normally greater than other models, however their effectiveness is also normally greater. We need to both optimize usefulness and lessen time-to-usefulness.

70B via Ollama

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

GPU usage soars here, as anticipated 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 totally 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 a novel autoregressive framework that merges multimodal understanding and generation. It can both comprehend and generate images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models via Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source reasoning design that equals the performance of OpenAI's o1. It presents a detailed approach for training such designs utilizing massive support learning strategies. DeepSeek-V3 Technical Report (December 2024) This report goes over the application of an FP8 combined precision training framework confirmed on an extremely large-scale design, attaining both accelerated training and decreased GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper explores scaling laws and provides findings that facilitate the scaling of large-scale models in open-source configurations. It presents the DeepSeek LLM project, dedicated to advancing open-source language models with a long-term point of view. DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research study presents the DeepSeek-Coder series, a series of open-source code designs trained from scratch on 2 trillion tokens. The models are pre-trained on a premium project-level code corpus and utilize a fill-in-the-blank task to enhance 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 efficient inference. DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research presents DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language model that attains efficiency comparable to GPT-4 Turbo in code-specific tasks.

Interesting occasions

- Hong Kong University replicates R1 results (Jan 25, '25). - Huggingface reveals huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to replicate R1, completely open source (Jan 25, '25).

  • OpenAI researcher validates the DeepSeek team separately discovered and utilized some core ideas the OpenAI group utilized on the way to o1

    Liked this post? Join the newsletter.