1 Understanding DeepSeek R1
Alina Bingham edited this page 3 months ago


DeepSeek-R1 is an open-source language model built on DeepSeek-V3-Base that's been making waves in the AI community. Not just does it match-or even surpass-OpenAI's o1 model in numerous benchmarks, however it also includes completely MIT-licensed weights. This marks it as the first non-OpenAI/Google model to provide strong reasoning abilities in an open and available manner.

What makes DeepSeek-R1 particularly amazing is its openness. Unlike the less-open approaches from some industry leaders, DeepSeek has actually released a detailed training methodology in their paper. The design is also remarkably cost-efficient, 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 better designs required more data and calculate. While that's still legitimate, larsaluarna.se designs like o1 and R1 demonstrate an option: inference-time scaling through thinking.

The Essentials

The DeepSeek-R1 paper provided multiple designs, but main among them were R1 and R1-Zero. Following these are a series of distilled designs that, while interesting, I will not go over here.

DeepSeek-R1 uses 2 major 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 knowing approach that depends on comparing multiple model outputs per prompt to avoid the requirement for a separate critic.

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

R1-Zero vs R1

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

It is fascinating how some languages might express certain concepts better, which leads the model to pick 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 models, and what you can anticipate from each stage. This includes the issues that the resulting designs from each stage have, and how they resolved it in the next phase.

It's intriguing that their training pipeline differs from the normal:

The usual training method: Pretraining on large dataset (train to forecast next word) to get the base design → supervised fine-tuning → tuning by means of RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with multiple SFT and RL phases

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

Model distillation is a method where you use an instructor model to improve a trainee model by generating training data for the trainee design. The teacher is generally a larger model than the trainee.

Group Relative Policy Optimization (GRPO)

The fundamental concept behind utilizing support knowing for LLMs is to fine-tune the model's policy so that it naturally produces more precise and useful answers. They utilized a benefit system that checks not only for accuracy but also for correct format and language consistency, so the model gradually discovers to prefer reactions that satisfy these quality criteria.

In this paper, they encourage the R1 model to produce chain-of-thought thinking through RL training with GRPO. Rather than including a separate module at reasoning time, the training procedure itself pushes the design to produce detailed, detailed outputs-making the chain-of-thought an emerging behavior of the enhanced policy.

What makes their technique particularly fascinating is its reliance on straightforward, rule-based reward functions. Instead of depending upon pricey external designs or human-graded examples as in conventional RLHF, the RL used for R1 utilizes simple requirements: it might offer a higher reward if the response is right, if it follows the expected/ format, and if the language of the answer matches that of the prompt. Not relying on a reward model also means you don't have to hang out and effort training it, and it does not take memory and compute far from your main model.

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

1. For each input timely, the design generates various reactions. 2. Each response gets a scalar reward based upon factors like precision, botdb.win formatting, and language consistency. 3. Rewards are changed relative to the group's efficiency, basically measuring how much better each action is compared to the others. 4. The design updates its strategy a little to favor actions with greater relative advantages. It just makes slight adjustments-using techniques like clipping and a KL penalty-to ensure the policy does not stray too far from its initial behavior.

A cool aspect of GRPO is its versatility. You can use basic rule-based reward functions-for instance, awarding a perk when the design correctly utilizes the syntax-to guide the training.

While DeepSeek used GRPO, you could utilize alternative methods rather (PPO or PRIME).

For those aiming to dive much deeper, Will Brown has written rather a good application of training an LLM with RL using GRPO. GRPO has likewise currently been contributed to the Transformer Reinforcement Learning (TRL) library, which is another excellent 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 final note on explaining DeepSeek-R1 and the approaches they've presented in their paper, larsaluarna.se I wish to highlight a passage from the DeepSeekMath paper, based on a point Yannic Kilcher made in his video.

These findings suggest that RL improves the model's total performance by rendering the output circulation more robust, simply put, it seems that the enhancement is credited to increasing the appropriate response from TopK rather than the improvement of basic abilities.

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

This suggests that reinforcement learning on LLMs is more about refining and "forming" the existing circulation of actions rather than enhancing the model with entirely new capabilities. Consequently, while RL techniques such as PPO and GRPO can produce considerable efficiency gains, there seems an inherent ceiling figured out 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 excited to see how it unfolds!

Running DeepSeek-R1

I have actually utilized DeepSeek-R1 via the main chat user interface for various issues, which it seems to solve well enough. The additional search functionality makes it even better to use.

Interestingly, o3-mini(-high) was released as I was composing this post. From my initial testing, R1 appears stronger at math than o3-mini.

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

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 operating on the GPU), running by means of llama.cpp:

29 layers appeared to be the sweet spot provided 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 regional video gaming setup. Digital Spaceport composed a full guide on how to run Deepseek R1 671b totally in your area on a $2000 EPYC server, on which you can get ~ 4.25 to 3.5 tokens per second.

As you can see, systemcheck-wiki.de the tokens/s isn't quite bearable for any major work, but it's fun to run these big designs on available hardware.

What matters most to me is a mix of effectiveness and time-to-usefulness in these models. Since reasoning models require to believe before responding to, their time-to-usefulness is generally greater than other models, but their effectiveness is likewise usually greater. We need to both optimize effectiveness and decrease time-to-usefulness.

70B via Ollama

70.6 b params, 4-bit KM quantized DeepSeek-R1 running by means of Ollama:

GPU utilization 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 completely regional "deep researcher" with DeepSeek-R1 - YouTube). DeepSeek R1's dish 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 granny - 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 structure that merges multimodal understanding and generation. It can both understand and produce images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models by means of Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source thinking model that equals the efficiency of OpenAI's o1. It provides a detailed approach for training such designs using large-scale reinforcement knowing methods. DeepSeek-V3 Technical Report (December 2024) This report goes over the execution of an FP8 blended accuracy training framework confirmed on an incredibly massive 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 help with the scaling of large-scale models in open-source setups. It presents the DeepSeek LLM task, devoted to advancing open-source language models with a long-lasting perspective. 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 high-quality 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 presents DeepSeek-V2, a Mixture-of-Experts (MoE) language design characterized by cost-effective training and effective inference. DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research study introduces 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 events

- Hong Kong University replicates R1 outcomes (Jan 25, '25). - Huggingface announces huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to replicate R1, totally open source (Jan 25, '25).

  • OpenAI scientist confirms the DeepSeek group individually discovered and used some core concepts the OpenAI team used on the method to o1

    Liked this post? Join the newsletter.