1 Understanding DeepSeek R1
sonya41i296212 edited this page 2025-02-09 18:25:49 +03: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 o1 design in numerous benchmarks, however it likewise features totally MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to deliver strong reasoning abilities in an open and available manner.

What makes DeepSeek-R1 particularly exciting is its openness. Unlike the less-open techniques from some market leaders, DeepSeek has released a detailed training method in their paper. The model is likewise remarkably 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 typical knowledge was that better models needed more information and calculate. While that's still legitimate, archmageriseswiki.com designs like o1 and R1 show an alternative: inference-time scaling through thinking.

The Essentials

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

DeepSeek-R1 uses 2 major ideas:

1. A multi-stage pipeline where a little set of cold-start data kickstarts the design, followed by large-scale RL. 2. Group Relative Policy Optimization (GRPO), a reinforcement knowing approach that relies on comparing numerous model outputs per timely to avoid the requirement for a separate critic.

R1 and R1-Zero are both reasoning 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 addressing with a final summary.

R1-Zero vs R1

R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no supervised fine-tuning (SFT). RL is used to enhance the design's policy to optimize reward. R1-Zero attains exceptional accuracy but sometimes produces complicated outputs, such as blending numerous languages in a single action. R1 repairs that by integrating restricted supervised fine-tuning and shiapedia.1god.org numerous RL passes, which improves both correctness and readability.

It is fascinating how some languages might express certain concepts much better, which leads the model to pick the most expressive language for the task.

Training Pipeline

The training pipeline that DeepSeek published in the R1 paper is exceptionally intriguing. It showcases how they produced such strong thinking models, and what you can get out of each phase. This includes the problems that the resulting designs from each phase have, and how they solved it in the next phase.

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

The typical training strategy: Pretraining on big dataset (train to predict next word) to get the base design → supervised fine-tuning → preference tuning via 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 couple of thousand Chain-of-Thought (CoT) samples to make sure the RL process has a good beginning point. This offers an excellent design to begin RL. First RL Stage: Apply GRPO with rule-based benefits to improve thinking accuracy and formatting (such as forcing chain-of-thought into thinking tags). When they were near convergence in the RL process, gratisafhalen.be they transferred to the next action. The result of this step is a strong thinking design however with weak basic abilities, e.g., bad format and language blending. Rejection Sampling + basic information: Create brand-new SFT data through rejection sampling on the RL checkpoint (from step 2), combined with monitored information from the DeepSeek-V3-Base model. They gathered around 600k top quality reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k basic tasks) for broader capabilities. This action resulted in a strong thinking model with general capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to improve the last design, in addition to the reasoning benefits. The result is DeepSeek-R1. They likewise did design distillation for online-learning-initiative.org several Qwen and Llama models on the thinking traces to get distilled-R1 models.

Model distillation is a technique where you use an instructor design to enhance a trainee design by producing training data for the trainee model. The instructor is typically a larger design than the trainee.

Group Relative Policy Optimization (GRPO)

The basic idea behind using reinforcement learning for LLMs is to fine-tune the model's policy so that it naturally produces more precise and helpful answers. They utilized a benefit system that checks not just for accuracy but also for correct formatting and language consistency, so the design slowly discovers to favor actions that meet these quality criteria.

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

What makes their method particularly intriguing is its reliance on straightforward, rule-based reward functions. Instead of depending on pricey external models or human-graded examples as in traditional RLHF, the RL utilized for R1 uses simple requirements: it may offer a greater benefit if the answer is right, if it follows the expected/ format, and if the language of the answer matches that of the prompt. Not relying on a benefit model likewise suggests you don't have to spend time and effort training it, and it doesn't take memory and calculate far from your main design.

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

1. For each input prompt, the design generates various responses. 2. Each response receives a scalar benefit based upon elements like accuracy, format, and language consistency. 3. Rewards are changed relative to the group's performance, basically determining how much better each response is compared to the others. 4. The design updates its method a little to favor reactions with higher relative advantages. It just makes small adjustments-using methods like clipping and a KL penalty-to make sure the policy doesn't wander off too far from its original habits.

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

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

For those aiming to dive much deeper, Will Brown has composed quite a nice execution of training an LLM with RL using GRPO. GRPO has also currently 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 course to AGI?

As a last 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 indicate that RL enhances the model's overall performance by rendering the output distribution more robust, in other words, it seems that the enhancement is credited to enhancing the right response from TopK instead of the enhancement of essential capabilities.

In other words, RL fine-tuning tends to shape the output circulation so that the highest-probability outputs are more most likely to be appropriate, although the overall capability (as determined by the diversity of right answers) is mainly present in the pretrained design.

This recommends that support learning on LLMs is more about refining and "forming" the existing circulation of reactions rather than enhancing the design with totally new abilities. Consequently, while RL techniques such as PPO and GRPO can produce substantial efficiency gains, there seems a fundamental ceiling figured out by the underlying design's pretrained understanding.

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 interface for various issues, which it appears to resolve well enough. The additional search performance makes it even better to utilize.

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

I likewise leased a single H100 via 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 extensively evaluate the model'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 running on the GPU), running by means of llama.cpp:

29 layers seemed to be the sweet spot given this setup.

Performance:

A r/localllama user explained that they were able to get over 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their regional gaming setup. Digital Spaceport composed 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 severe work, however it's fun to run these large designs on available hardware.

What matters most to me is a mix of usefulness and time-to-usefulness in these designs. Since thinking designs need to believe before responding to, their time-to-usefulness is typically higher than other designs, but their usefulness is likewise normally greater. We require to both maximize usefulness and decrease time-to-usefulness.

70B by means of Ollama

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

GPU utilization shoots up 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 through Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a fully regional "deep researcher" with DeepSeek-R1 - YouTube). DeepSeek R1's recipe to reproduce 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 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 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 design that matches the performance of OpenAI's o1. It provides a detailed methodology for utahsyardsale.com training such designs utilizing large-scale reinforcement knowing techniques. DeepSeek-V3 Technical Report (December 2024) This report talks about the application of an FP8 blended precision training structure confirmed on an exceptionally large-scale model, attaining both accelerated training and minimized GPU memory usage. DeepSeek LLM: links.gtanet.com.br Scaling Open-Source Language Models with Longtermism (January 2024) This paper explores scaling laws and provides findings that assist in the scaling of large-scale designs in open-source configurations. It introduces the DeepSeek LLM job, devoted 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 introduces the DeepSeek-Coder series, a variety of open-source code designs trained from scratch on 2 trillion tokens. The designs are pre-trained on a premium project-level code corpus and use 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 presents DeepSeek-V2, a Mixture-of-Experts (MoE) language model characterized by affordable training and efficient reasoning. 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 jobs.

Interesting events

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

  • Huggingface reveals huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to replicate R1, totally open source (Jan 25, '25).
  • OpenAI scientist validates the DeepSeek team individually discovered and utilized some core ideas the OpenAI team used en route to o1

    Liked this post? Join the newsletter.