1 Understanding DeepSeek R1
Adrianne Foveaux edited this page 2025-02-11 05:53:05 +01:00


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 many standards, but it likewise features totally MIT-licensed weights. This marks it as the first non-OpenAI/Google model to deliver strong reasoning abilities in an open and available way.

What makes DeepSeek-R1 particularly interesting is its openness. Unlike the less-open methods from some industry leaders, DeepSeek has published a detailed training approach in their paper. The model is also extremely affordable, 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 common knowledge was that better models needed more data and compute. While that's still legitimate, designs like o1 and R1 demonstrate an option: inference-time scaling through reasoning.

The Essentials

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

DeepSeek-R1 utilizes two significant concepts:

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

R1 and R1-Zero are both reasoning designs. This basically implies they do Chain-of-Thought before responding to. For the R1 series of models, this takes kind as believing within a tag, before addressing 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 used to enhance the design's policy to optimize reward. R1-Zero attains exceptional accuracy however sometimes produces complicated outputs, such as blending several languages in a single reaction. R1 repairs that by incorporating restricted monitored fine-tuning and multiple RL passes, which improves both correctness and readability.

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

Training Pipeline

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

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

The normal training method: Pretraining on large dataset (train to forecast next word) to get the base model → supervised fine-tuning → preference tuning through RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with several SFT and RL phases

Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a couple of thousand Chain-of-Thought (CoT) samples to ensure the RL procedure has a good beginning point. This gives a good design to begin RL. First RL Stage: Apply GRPO with rule-based rewards to improve thinking correctness and formatting (such as forcing chain-of-thought into believing tags). When they were near merging in the RL procedure, they transferred to the next step. The outcome of this action is a strong thinking model but with weak general capabilities, e.g., poor format and language mixing. Rejection Sampling + general information: Create brand-new SFT data through rejection sampling on the RL checkpoint (from action 2), integrated with supervised data 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 thinking + 200k basic tasks) for broader abilities. This step led to a strong thinking model with basic abilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to fine-tune the final design, in addition to the reasoning rewards. The result is DeepSeek-R1. They likewise did model distillation for several Qwen and Llama designs on the reasoning traces to get distilled-R1 models.

Model distillation is a method where you utilize an instructor model to enhance a trainee design by creating training data for the trainee design. The instructor is normally a bigger model than the trainee.

Group Relative Policy Optimization (GRPO)

The fundamental concept behind utilizing reinforcement knowing for LLMs is to tweak the model's policy so that it naturally produces more precise and helpful responses. They used a benefit system that inspects not just for accuracy however also for appropriate formatting and language consistency, so the design gradually discovers to favor responses that satisfy these quality criteria.

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

What makes their technique particularly fascinating is its dependence on straightforward, rule-based reward functions. Instead of depending upon pricey external models or annunciogratis.net human-graded examples as in standard RLHF, the RL utilized for R1 uses easy requirements: it might give a greater benefit if the answer is appropriate, trade-britanica.trade if it follows the anticipated/ formatting, and if the language of the response matches that of the timely. Not depending on a benefit model likewise implies you don't need to hang out and effort training it, and it doesn't take memory and compute away from your main model.

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

1. For each input timely, fishtanklive.wiki the model creates different reactions. 2. Each action receives a scalar benefit based on elements like accuracy, formatting, and language consistency. 3. Rewards are adjusted relative to the group's efficiency, basically determining how much better each response is compared to the others. 4. The model updates its technique slightly to prefer reactions with greater relative benefits. It just makes slight adjustments-using strategies 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 flexibility. You can use easy rule-based benefit functions-for circumstances, granting a benefit when the model properly uses the syntax-to guide the training.

While DeepSeek utilized GRPO, you could utilize alternative approaches rather (PPO or PRIME).

For valetinowiki.racing those aiming to dive deeper, Will Brown has composed rather a nice execution of training an LLM with RL using GRPO. GRPO has actually also already been contributed to the Transformer Reinforcement Learning (TRL) library, which is another excellent resource. Finally, Yannic Kilcher has a great 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 methodologies they've presented in their paper, I want to highlight a passage from the DeepSeekMath paper, based on a point Yannic Kilcher made in his video.

These findings suggest that RL enhances the model's total efficiency by rendering the output distribution more robust, in other words, it appears that the enhancement is attributed to improving the right reaction from TopK instead of the improvement of fundamental abilities.

Simply put, RL fine-tuning tends to form the output circulation so that the highest-probability outputs are more likely to be correct, despite the fact that the overall ability (as measured by the variety of right answers) is mainly present in the pretrained model.

This suggests that support learning on LLMs is more about refining and "forming" the existing circulation of reactions instead of endowing the design with totally brand-new abilities. Consequently, while RL strategies such as PPO and GRPO can produce significant efficiency gains, there appears to be an intrinsic 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 huge milestone. I'm delighted to see how it unfolds!

Running DeepSeek-R1

I have actually utilized DeepSeek-R1 through the main chat user interface for numerous problems, which it appears to fix all right. The extra search performance makes it even nicer to utilize.

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

I also 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 goal was to see how the model would carry out when deployed on a single H100 GPU-not to thoroughly evaluate the design's abilities.

671B through 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 working on the GPU), running via llama.cpp:

29 layers seemed 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 using their GPU on their regional gaming setup. Digital Spaceport composed a full guide on how to run Deepseek R1 671b totally 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 major work, however it's enjoyable to run these big models on available hardware.

What matters most to me is a combination of effectiveness and time-to-usefulness in these designs. Since reasoning designs require to think before addressing, their time-to-usefulness is normally higher than other designs, but their usefulness is also normally greater. We need to both make the most of effectiveness and minimize time-to-usefulness.

70B via Ollama

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

GPU usage shoots up 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 through Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a totally local "deep scientist" with DeepSeek-R1 - YouTube). DeepSeek R1's dish to duplicate o1 and the future of reasoning LMs. The Illustrated DeepSeek-R1 - by Jay Alammar. Explainer: What's R1 & Everything Else? - Tim Kellogg. DeepSeek R1 Explained to your grandma - 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 create 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 reasoning model that rivals the efficiency of OpenAI's o1. It presents a detailed approach for training such models utilizing large-scale reinforcement knowing techniques. DeepSeek-V3 Technical Report (December 2024) This report goes over the application of an FP8 blended precision training structure validated on an exceptionally massive design, attaining both accelerated training and reduced GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and presents findings that help with the scaling of massive designs in open-source setups. It introduces the DeepSeek LLM task, committed to advancing open-source language models with a long-lasting viewpoint. 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 models trained from scratch on 2 trillion tokens. The designs are pre-trained on a top quality project-level code corpus and use 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 defined by economical training and efficient 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 comparable to GPT-4 Turbo in code-specific jobs.

Interesting events

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

  • Huggingface reveals huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to replicate R1, totally open source (Jan 25, '25).
  • OpenAI researcher verifies the DeepSeek team independently found and used some core ideas the OpenAI team utilized on the way to o1

    Liked this post? Join the newsletter.