1 Understanding DeepSeek R1
Athena Bulcock edited this page 2025-02-10 01:12:32 +08:00


DeepSeek-R1 is an open-source language model built on DeepSeek-V3-Base that's been making waves in the AI neighborhood. Not just does it match-or even surpass-OpenAI's o1 model in numerous criteria, however it likewise features fully MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to provide strong thinking capabilities in an open and available manner.

What makes DeepSeek-R1 especially amazing is its transparency. Unlike the less-open approaches from some market leaders, DeepSeek has actually released a detailed training approach in their paper. The design is also extremely 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 common wisdom was that much better models needed more information and compute. While that's still valid, models like o1 and R1 show an alternative: inference-time scaling through thinking.

The Essentials

The DeepSeek-R1 paper presented several models, drapia.org but main among them were R1 and R1-Zero. Following these are a series of distilled designs that, while intriguing, I will not discuss here.

DeepSeek-R1 utilizes two significant concepts:

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

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

R1-Zero vs R1

R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no monitored fine-tuning (SFT). RL is utilized to optimize the model's policy to take full advantage of benefit. R1-Zero attains excellent accuracy however often produces confusing outputs, such as mixing multiple languages in a single response. R1 repairs that by including limited monitored fine-tuning and several RL passes, passfun.awardspace.us which improves both accuracy and readability.

It is intriguing how some languages may express certain concepts better, which leads the design to choose the most meaningful 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 anticipate from each stage. This consists of the issues that the resulting models from each stage have, and how they resolved it in the next stage.

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

The usual training technique: Pretraining on large dataset (train to forecast next word) to get the base model → supervised fine-tuningpreference tuning by means of RLHF R1-Zero: Pretrained → RL R1: PretrainedMultistage training pipeline with numerous SFT and RL stages

Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a few thousand Chain-of-Thought (CoT) samples to ensure the RL process has a decent beginning point. This gives an excellent model to begin RL. First RL Stage: Apply GRPO with rule-based rewards to improve reasoning correctness and format (such as forcing chain-of-thought into thinking tags). When they were near merging in the RL procedure, they moved to the next step. The result of this action is a strong reasoning model but with weak basic abilities, e.g., bad formatting and language mixing. Rejection Sampling + general information: Create new SFT information through rejection sampling on the RL checkpoint (from step 2), integrated with supervised information from the DeepSeek-V3-Base model. They collected around 600k premium thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k reasoning + 200k basic tasks) for broader capabilities. This step resulted in a strong thinking model with general capabilities. Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to fine-tune the last model, in addition to the thinking rewards. The outcome is DeepSeek-R1. They likewise did design distillation for a number of Qwen and Llama designs on the reasoning traces to get distilled-R1 designs.

Model distillation is a technique where you utilize an instructor design to improve a trainee design by generating training data for the trainee design. The instructor is generally a larger design than the trainee.

Group Relative Policy Optimization (GRPO)

The standard concept behind using support knowing for LLMs is to fine-tune the design's policy so that it naturally produces more accurate and helpful responses. They used a benefit system that inspects not just for correctness however also for correct format and language consistency, so the design slowly discovers to prefer responses that meet these quality criteria.

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

What makes their method particularly interesting is its dependence on straightforward, rule-based benefit functions. Instead of depending upon pricey external designs or human-graded examples as in conventional RLHF, the RL used for R1 utilizes easy criteria: it might offer a higher reward if the answer is correct, if it follows the anticipated/ format, and if the language of the answer matches that of the prompt. Not relying on a reward design likewise implies you don't have to invest time and effort training it, and it doesn't take memory and compute away from your main model.

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

1. For each input timely, the model produces various responses. 2. Each response receives a scalar reward based on elements like accuracy, formatting, and language consistency. 3. Rewards are changed relative to the group's performance, basically measuring just how much better each response is compared to the others. 4. The model updates its strategy slightly to prefer reactions with higher relative advantages. It only makes slight adjustments-using methods like clipping and a KL penalty-to ensure the policy does not stray too far from its initial habits.

A cool element of GRPO is its flexibility. You can utilize basic rule-based benefit functions-for circumstances, awarding a reward when the design properly utilizes the syntax-to guide the training.

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

For those aiming to dive deeper, Will Brown has actually composed rather a great application of training an LLM with RL utilizing GRPO. GRPO has actually also already been added 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 course to AGI?

As a final note on explaining DeepSeek-R1 and the methodologies they have actually presented 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 design's total performance by rendering the output distribution more robust, gratisafhalen.be to put it simply, it seems that the improvement is associated to enhancing the appropriate response from TopK instead of the improvement of .

Simply put, RL fine-tuning tends to shape the output circulation so that the highest-probability outputs are most likely to be appropriate, although the overall capability (as determined by the variety of proper answers) is mainly present in the pretrained design.

This recommends that support knowing on LLMs is more about refining and "shaping" the existing circulation of reactions rather than enhancing the model with totally brand-new abilities. Consequently, while RL methods such as PPO and GRPO can produce considerable performance gains, there appears to be an inherent ceiling determined by the underlying model's pretrained understanding.

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 used DeepSeek-R1 by means of the main chat user interface for different issues, which it appears to resolve all right. The additional search functionality makes it even better to utilize.

Interestingly, o3-mini(-high) was launched as I was composing this post. From my initial screening, R1 appears stronger at mathematics 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 perform when deployed on a single H100 GPU-not to extensively evaluate the design'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 working on the GPU), running via llama.cpp:

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

Performance:

A r/localllama user explained that they had the ability to overcome 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their local video gaming setup. Digital Spaceport composed a complete guide on how to run Deepseek R1 671b fully in your area on a $2000 EPYC server, astroberry.io 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 severe work, however it's fun to run these big designs on available hardware.

What matters most to me is a combination of usefulness and time-to-usefulness in these designs. Since thinking designs require to believe before addressing, their time-to-usefulness is normally greater than other models, however their usefulness is also generally greater. We need to both maximize usefulness and reduce time-to-usefulness.

70B through Ollama

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

GPU usage soars 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 by means of Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a fully regional "deep scientist" 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 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 an unique autoregressive structure that unifies multimodal understanding and generation. It can both comprehend and create images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models by means of Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source reasoning model that equals the performance of OpenAI's o1. It provides a detailed approach for training such models using massive support knowing techniques. DeepSeek-V3 Technical Report (December 2024) This report talks about the implementation of an FP8 blended accuracy training framework validated on an exceptionally massive model, attaining both accelerated training and lowered GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and provides findings that help with the scaling of large-scale designs in open-source setups. It presents the DeepSeek LLM task, devoted to advancing open-source language designs with a long-term 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 series of open-source code models 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 boost 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 design identified by cost-effective 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 design that attains performance equivalent to GPT-4 Turbo in code-specific tasks.

Interesting events

- Hong Kong University reproduces R1 results (Jan 25, '25). - Huggingface reveals huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to reproduce R1, fully open source (Jan 25, '25).