1 Understanding DeepSeek R1
tiffanysolomon edited this page 2025-02-28 10:39:45 +02:00


DeepSeek-R1 is an open-source language design 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, however it also features completely MIT-licensed weights. This marks it as the first non-OpenAI/Google model to deliver strong thinking capabilities in an open and wiki.vst.hs-furtwangen.de available manner.

What makes DeepSeek-R1 particularly exciting is its transparency. Unlike the less-open approaches from some market leaders, DeepSeek has published a detailed training methodology in their paper. The design is also incredibly 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 wisdom was that better designs needed more information and calculate. While that's still legitimate, models like o1 and R1 demonstrate an alternative: inference-time scaling through thinking.

The Essentials

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

DeepSeek-R1 uses two major concepts:

1. A multi-stage pipeline where a little set of cold-start information kickstarts the model, followed by massive RL. 2. Group Relative Policy Optimization (GRPO), a support knowing method that depends on comparing numerous design outputs per timely to prevent the requirement for a separate critic.

R1 and R1-Zero are both thinking models. This basically means they do Chain-of-Thought before answering. For the R1 series of models, this takes kind as believing within a tag, before answering 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 used to optimize the design's policy to optimize reward. R1-Zero attains outstanding accuracy but often produces confusing outputs, such as mixing numerous languages in a single reaction. R1 repairs that by incorporating limited supervised fine-tuning and several RL passes, which enhances both accuracy and readability.

It is fascinating how some languages may express certain ideas much better, which leads the design to pick the most expressive language for the job.

Training Pipeline

The training pipeline that DeepSeek published in the R1 paper is immensely intriguing. It showcases how they created such strong reasoning designs, 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 fascinating that their training pipeline varies from the typical:

The usual training method: Pretraining on large dataset (train to predict next word) to get the base model → supervised fine-tuning → choice tuning by means of RLHF R1-Zero: vmeste-so-vsemi.ru 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 process has a decent starting point. This provides a good design to begin RL. First RL Stage: Apply GRPO with rule-based rewards to improve reasoning accuracy and format (such as requiring chain-of-thought into thinking tags). When they were near convergence in the RL process, they relocated to the next step. The result of this action is a strong reasoning model however with weak general abilities, e.g., poor format and language blending. Rejection Sampling + general information: Create brand-new SFT data through rejection sampling on the RL checkpoint (from step 2), setiathome.berkeley.edu integrated with monitored data from the DeepSeek-V3-Base model. They collected around 600k high-quality thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k thinking + 200k general jobs) for more comprehensive abilities. This step led to a strong thinking model with general capabilities. Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to refine the final design, in addition to the reasoning benefits. The result is DeepSeek-R1. They likewise did model distillation for a number of Qwen and Llama designs on the reasoning traces to get distilled-R1 designs.

Model distillation is a strategy where you utilize a teacher model to enhance a trainee design by producing training information for the trainee model. The teacher is generally a larger design than the trainee.

Group Relative Policy Optimization (GRPO)

The fundamental concept behind utilizing reinforcement knowing for LLMs is to fine-tune the model's policy so that it naturally produces more precise and beneficial answers. They used a benefit system that examines not just for correctness but likewise for correct formatting and language consistency, so the design slowly discovers to prefer reactions that satisfy these quality requirements.

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

What makes their approach particularly intriguing is its reliance on straightforward, rule-based reward functions. Instead of depending upon pricey external models or human-graded examples as in conventional RLHF, the RL utilized for R1 utilizes basic requirements: it may provide a greater reward if the answer is right, if it follows the anticipated/ formatting, and if the language of the response matches that of the timely. Not depending on a reward model likewise means you do not have to invest time and effort training it, and it does not take memory and setiathome.berkeley.edu compute away from your main design.

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

1. For each input prompt, the model generates various reactions. 2. Each action gets a scalar reward based upon aspects like precision, format, and language consistency. 3. Rewards are adjusted relative to the group's efficiency, essentially measuring just how much better each reaction is compared to the others. 4. The design updates its strategy somewhat to favor responses with higher relative benefits. It only makes slight adjustments-using strategies like clipping and a KL penalty-to make sure the policy does not stray too far from its initial behavior.

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

While DeepSeek used GRPO, you might utilize alternative approaches rather (PPO or asteroidsathome.net PRIME).

For those aiming to dive much deeper, Will Brown has composed quite a good application of training an LLM with RL using GRPO. GRPO has actually likewise already been added to the Transformer Reinforcement Learning (TRL) library, which is another great 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 last note on explaining DeepSeek-R1 and the methods they have actually presented in their paper, 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 overall efficiency by rendering the output circulation more robust, simply put, it appears that the enhancement is credited to increasing the proper response from TopK rather than the enhancement of basic capabilities.

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

This recommends that reinforcement learning on LLMs is more about refining and "forming" the existing circulation of responses instead of endowing the design with completely new capabilities. Consequently, while RL strategies such as PPO and GRPO can produce significant performance gains, there appears to be an intrinsic ceiling figured out by the 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 delighted to see how it unfolds!

Running DeepSeek-R1

I have actually utilized DeepSeek-R1 via the main chat user interface for various problems, which it appears to resolve well enough. The additional search functionality makes it even nicer to use.

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

I also 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 design would perform when released on a single H100 GPU-not to extensively test the design's capabilities.

671B by means of 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), fakenews.win running by means of llama.cpp:

29 layers appeared to be the sweet area offered this configuration.

Performance:

A r/localllama user explained that they were able to overcome 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their local video gaming setup. Digital Spaceport wrote a full guide on how to run Deepseek R1 671b fully 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, the tokens/s isn't quite manageable for any severe work, but it's fun to run these large designs on available hardware.

What matters most to me is a combination of effectiveness and time-to-usefulness in these models. Since reasoning designs require to think before responding to, their time-to-usefulness is normally higher than other designs, however their usefulness is also generally higher. We require to both maximize effectiveness and reduce time-to-usefulness.

70B via Ollama

70.6 b params, 4-bit KM quantized DeepSeek-R1 running via 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 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 replicate 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 an unique autoregressive framework that unifies multimodal understanding and generation. It can both understand and create images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models via Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source thinking model that equals the performance of OpenAI's o1. It provides a detailed approach for training such designs utilizing large-scale support knowing techniques. DeepSeek-V3 Technical Report (December 2024) This report talks about the application of an FP8 mixed precision training framework validated on an exceptionally massive design, attaining both accelerated training and minimized GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper explores scaling laws and presents findings that help with the scaling of large-scale models in open-source configurations. It introduces the DeepSeek LLM project, devoted to advancing open-source language models with a long-lasting point of view. 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 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 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 efficient 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 design that attains efficiency similar to GPT-4 Turbo in code-specific jobs.

Interesting occasions

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

  • OpenAI researcher confirms the DeepSeek group separately discovered and used some core ideas the OpenAI team used en route to o1

    Liked this post? Join the newsletter.