1 Understanding DeepSeek R1
Audra Ricketts edited this page 2025-02-09 23:40:11 +08:00


DeepSeek-R1 is an open-source language design developed on DeepSeek-V3-Base that's been making waves in the AI neighborhood. Not only does it match-or even surpass-OpenAI's o1 design in lots of criteria, however it likewise includes completely MIT-licensed weights. This marks it as the first non-OpenAI/Google design to deliver strong reasoning capabilities in an open and available manner.

What makes DeepSeek-R1 particularly amazing is its openness. Unlike the less-open methods from some industry leaders, DeepSeek has released a detailed training method in their paper. The design 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 models required more information and calculate. While that's still legitimate, designs like o1 and R1 demonstrate an alternative: inference-time scaling through thinking.

The Essentials

The DeepSeek-R1 paper provided numerous models, but main among them were R1 and R1-Zero. Following these are a series of distilled models that, while interesting, I will not talk about here.

DeepSeek-R1 uses 2 significant concepts:

1. A multi-stage pipeline where a small set of cold-start information kickstarts the design, followed by massive RL. 2. Group Relative Policy Optimization (GRPO), a reinforcement learning technique that depends on comparing several design outputs per prompt to avoid the requirement for photorum.eclat-mauve.fr a separate critic.

R1 and R1-Zero are both reasoning designs. This essentially indicates they do Chain-of-Thought before answering. For the R1 series of models, addsub.wiki this takes type as believing within a tag, before responding to 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 used to enhance the model's policy to maximize benefit. R1-Zero attains exceptional precision but in some cases produces complicated outputs, such as blending multiple languages in a single response. R1 repairs that by including limited monitored fine-tuning and several RL passes, which improves both accuracy and readability.

It is fascinating how some languages may reveal certain concepts much better, which leads the design to select the most meaningful language for the job.

Training Pipeline

The training pipeline that DeepSeek released in the R1 paper is tremendously interesting. It showcases how they produced such strong reasoning models, and what you can expect from each stage. This includes the problems that the resulting designs from each phase have, and how they resolved it in the next stage.

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

The normal training method: Pretraining on large dataset (train to anticipate next word) to get the base design → supervised fine-tuning → choice 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 decent starting point. This offers an excellent model to start RL. First RL Stage: Apply GRPO with rule-based rewards to enhance reasoning correctness and formatting (such as forcing chain-of-thought into thinking tags). When they were near merging in the RL process, they transferred to the next step. The result of this action is a strong reasoning design but with weak general abilities, e.g., poor formatting and language blending. Rejection Sampling + general data: Create brand-new SFT data through rejection sampling on the RL checkpoint (from action 2), integrated with monitored information from the DeepSeek-V3-Base design. They collected around 600k high-quality thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k thinking + 200k basic jobs) for wider abilities. This action resulted in a strong reasoning design with general capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to improve the last model, in addition to the thinking benefits. The outcome is DeepSeek-R1. They also did model distillation for a number of Qwen and Llama designs on the thinking traces to get distilled-R1 models.

Model distillation is a technique where you utilize an instructor design to improve a trainee model by producing training data for the trainee design. The instructor is normally a bigger design than the trainee.

Group Relative Policy Optimization (GRPO)

The basic idea behind utilizing support knowing for LLMs is to tweak the model's policy so that it naturally produces more precise and beneficial responses. They utilized a reward system that checks not just for accuracy however also for appropriate format and language consistency, so the model gradually finds out to prefer actions that fulfill these quality requirements.

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

What makes their technique particularly intriguing is its reliance on straightforward, rule-based reward functions. Instead of depending on expensive external models or human-graded examples as in conventional RLHF, the RL utilized for R1 uses simple requirements: it might provide a higher benefit if the response is appropriate, tandme.co.uk if it follows the anticipated/ format, and if the language of the response matches that of the prompt. Not counting on a benefit design likewise implies you do not need to spend time and effort training it, and engel-und-waisen.de it does not take memory and calculate away from your main design.

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

1. For each input timely, the model produces different reactions. 2. Each reaction receives a scalar reward based on elements like precision, format, and language consistency. 3. Rewards are changed relative to the group's performance, essentially measuring just how much better each reaction is compared to the others. 4. The design updates its strategy a little to favor reactions with higher relative benefits. It only makes small adjustments-using methods like clipping and a KL penalty-to ensure the policy doesn't stray too far from its original habits.

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

While DeepSeek utilized GRPO, you could use alternative methods rather (PPO or PRIME).

For those aiming to dive deeper, Will Brown has composed rather a nice application of training an LLM with RL using GRPO. GRPO has actually likewise 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 approaches they've presented in their paper, I want to highlight a passage from the DeepSeekMath paper, based upon a point Yannic Kilcher made in his video.

These findings indicate that RL boosts the design's total efficiency by rendering the output distribution more robust, in other words, it seems that the improvement is associated to boosting the proper action from TopK instead of the improvement of basic abilities.

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

This recommends that reinforcement knowing on LLMs is more about refining and "shaping" the existing circulation of responses rather than endowing the design with completely new abilities. Consequently, while RL methods such as PPO and GRPO can produce considerable performance gains, there appears to be a fundamental 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 milestone. I'm thrilled to see how it unfolds!

Running DeepSeek-R1

I've used DeepSeek-R1 by means of the main chat interface for various problems, which it seems to solve all right. The additional search performance makes it even better to use.

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

I likewise rented a single H100 via Lambda Labs for $2/h (26 CPU cores, valetinowiki.racing 214.7 GB RAM, 1.1 TB SSD) to run some experiments. The main goal was to see how the model would carry out when released on a single H100 GPU-not to extensively check the design's abilities.

671B via 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 through 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 regional video gaming setup. Digital Spaceport wrote a full guide on how to run Deepseek R1 671b fully 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 manageable for any serious work, however it's fun to run these big models on available hardware.

What matters most to me is a combination of effectiveness and time-to-usefulness in these models. Since thinking designs require to believe before responding to, their time-to-usefulness is generally greater than other designs, however their usefulness is likewise normally higher. We need to both make the most of usefulness and lessen time-to-usefulness.

70B by means of 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 via Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a completely local "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 structure that merges multimodal understanding and generation. It can both understand and generate images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source reasoning model that matches the efficiency of OpenAI's o1. It presents a detailed methodology for training such designs utilizing large-scale reinforcement learning strategies. DeepSeek-V3 Technical Report (December 2024) This report discusses the application of an FP8 blended precision training framework validated on a very large-scale model, attaining both sped up training and decreased GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper digs into scaling laws and presents findings that facilitate the scaling of massive designs in open-source configurations. It introduces the DeepSeek LLM task, dedicated to advancing open-source language models with a long-term perspective. DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research study introduces the DeepSeek-Coder series, a variety 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 job to enhance code generation and infilling. DeepSeek-V2: A Strong, Economical, and bahnreise-wiki.de Efficient Mixture-of-Experts Language Model (May 2024) This paper provides DeepSeek-V2, a Mixture-of-Experts (MoE) language design defined by cost-effective 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 efficiency equivalent to GPT-4 Turbo in code-specific tasks.

Interesting events

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

  • Huggingface reveals huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to duplicate R1, totally open source (Jan 25, '25).
  • OpenAI scientist validates the DeepSeek team separately discovered and used some core ideas the OpenAI team utilized on the way to o1

    Liked this post? Join the newsletter.