Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Submit feedback
    • Contribute to GitLab
  • Sign in
B
bonilash
  • Project
    • Project
    • Details
    • Activity
    • Cycle Analytics
  • Issues 1
    • Issues 1
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Create a new issue
  • Jobs
  • Issue Boards
  • Eleanore Collee
  • bonilash
  • Issues
  • #1

Closed
Open
Opened Feb 12, 2025 by Eleanore Collee@eleanorecollee
  • Report abuse
  • New issue
Report abuse New issue

Understanding DeepSeek R1


DeepSeek-R1 is an open-source language design developed on DeepSeek-V3-Base that's been making waves in the AI community. Not only does it match-or even surpass-OpenAI's o1 design in many standards, but it likewise includes completely MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to provide strong reasoning capabilities in an open and available way.

What makes DeepSeek-R1 particularly amazing is its transparency. Unlike the less-open techniques from some industry leaders, DeepSeek has published a detailed training methodology in their paper. The design is likewise incredibly cost-effective, 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 data and compute. While that's still valid, models like o1 and R1 demonstrate an alternative: inference-time scaling through reasoning.

The Essentials

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

DeepSeek-R1 uses 2 major ideas:

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 depends on comparing multiple model outputs per timely to avoid the need for a different critic.

R1 and R1-Zero are both reasoning designs. This basically suggests they do Chain-of-Thought before addressing. For the R1 series of designs, this takes kind as believing within a tag, before responding to with a last summary.

R1-Zero vs R1

R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base without any supervised fine-tuning (SFT). RL is used to enhance the model's policy to take full advantage of reward. R1-Zero attains excellent precision but sometimes produces confusing outputs, such as mixing several languages in a single response. R1 repairs that by integrating minimal monitored fine-tuning and numerous RL passes, which enhances both correctness and readability.

It is intriguing how some languages may express certain ideas better, which leads the model to choose the most expressive language for the task.

Training Pipeline

The training pipeline that DeepSeek published in the R1 paper is exceptionally fascinating. It showcases how they developed such strong thinking models, and what you can get out of each phase. This consists of the issues that the resulting models from each stage have, and smfsimple.com how they resolved it in the next stage.

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

The usual training strategy: Pretraining on big dataset (train to anticipate next word) to get the base design → monitored fine-tuning → preference tuning by means of RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with several SFT and surgiteams.com RL phases

Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a couple of thousand Chain-of-Thought (CoT) samples to guarantee the RL process has a good beginning point. This provides a great design to begin RL. First RL Stage: Apply GRPO with rule-based rewards to improve reasoning accuracy and format (such as forcing chain-of-thought into believing tags). When they were near merging in the RL process, they relocated to the next action. The outcome of this step is a strong reasoning design but with weak general capabilities, e.g., poor format and language mixing. Rejection Sampling + general information: Create brand-new SFT data through rejection tasting on the RL checkpoint (from step 2), integrated with monitored information from the DeepSeek-V3-Base design. They collected around 600k premium reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k thinking + 200k general jobs) for asteroidsathome.net more comprehensive capabilities. This step resulted in a strong thinking model with basic abilities. Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to fine-tune the final model, in addition to the thinking rewards. The outcome is DeepSeek-R1. They also did design distillation for several Qwen and Llama models on the thinking traces to get distilled-R1 designs.

Model distillation is a strategy where you utilize an instructor design to improve a trainee design by creating training information for the trainee model. The instructor is normally a larger model than the trainee.

Group Relative Policy Optimization (GRPO)

The fundamental concept behind using support knowing for LLMs is to tweak the model's policy so that it naturally produces more accurate and helpful answers. They used a benefit system that checks not only for accuracy but also for correct format and language consistency, so the design slowly learns to prefer responses that meet these quality requirements.

In this paper, they motivate the R1 model to generate chain-of-thought thinking through RL training with GRPO. Instead of adding a different module at inference time, the training process itself pushes the design to produce detailed, detailed outputs-making the chain-of-thought an emergent habits of the optimized policy.

What makes their method particularly interesting is its dependence on straightforward, rule-based reward functions. Instead of depending upon expensive external designs or human-graded examples as in conventional RLHF, the RL utilized for R1 utilizes basic requirements: it might give a greater reward if the answer is appropriate, if it follows the expected/ formatting, and if the language of the response matches that of the prompt. Not counting on a benefit model likewise implies you do not need to hang out and effort training it, and it doesn't take memory and calculate away from your main model.

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

1. For each input timely, the model produces various responses. 2. Each reaction receives a scalar reward based upon elements like precision, format, and language consistency. 3. Rewards are changed relative to the group's performance, essentially measuring just how much better each action is compared to the others. 4. The model updates its technique slightly to favor actions with higher relative benefits. It just makes minor 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 reward when the design properly uses the syntax-to guide the training.

While DeepSeek utilized GRPO, you could utilize alternative techniques instead (PPO or PRIME).

For those aiming to dive much deeper, Will Brown has actually written rather a nice application of training an LLM with RL utilizing GRPO. GRPO has likewise currently been included to the Transformer Reinforcement Learning (TRL) library, which is another excellent resource. Finally, Yannic Kilcher has a fantastic 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 provided 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 suggest that RL enhances the design's total performance by rendering the output distribution more robust, in other words, it seems that the improvement is associated to enhancing the correct action from TopK rather than 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 correct, despite the fact that the general ability (as determined by the diversity of appropriate answers) is mainly present in the pretrained model.

This suggests that reinforcement learning on LLMs is more about refining and "forming" the existing circulation of actions instead of endowing the design with entirely new capabilities. Consequently, while RL methods such as PPO and GRPO can produce significant performance gains, there appears to be an inherent ceiling determined 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 turning point. I'm excited to see how it unfolds!

Running DeepSeek-R1

I have actually used DeepSeek-R1 via the main chat user interface for numerous issues, which it seems to solve all right. The additional search performance makes it even nicer to utilize.

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

I also rented 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 goal was to see how the design would perform when deployed on a single H100 GPU-not to extensively test the model's abilities.

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

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

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 regional 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, on which you can get ~ 4.25 to 3.5 tokens per second.

As you can see, the tokens/s isn't rather bearable for any severe work, however it's fun to run these large models on available hardware.

What matters most to me is a mix of usefulness and time-to-usefulness in these designs. Since thinking models need to think before addressing, their time-to-usefulness is typically higher than other designs, but their usefulness is likewise generally higher. We need to both maximize effectiveness and lessen time-to-usefulness.

70B by means of Ollama

70.6 b params, 4-bit KM quantized DeepSeek-R1 running via 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 via 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 thinking LMs. The Illustrated DeepSeek-R1 - by Jay Alammar. Explainer: What's R1 & Everything Else? - Tim Kellogg. DeepSeek R1 Explained to your granny - 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 combines multimodal understanding and generation. It can both understand and generate 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 efficiency of OpenAI's o1. It provides a detailed approach for training such designs utilizing large-scale reinforcement knowing strategies. DeepSeek-V3 Technical Report (December 2024) This report discusses the execution of an FP8 mixed precision training structure validated on an extremely massive model, attaining both accelerated training and memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and provides findings that assist in the scaling of massive models in open-source setups. It introduces the DeepSeek LLM project, committed to advancing open-source language models with a long-term point of view. DeepSeek-Coder: historydb.date When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research study presents 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 high-quality project-level code corpus and utilize a fill-in-the-blank job 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 model characterized by cost-effective training and effective 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 similar to GPT-4 Turbo in code-specific jobs.

Interesting events

- Hong Kong University replicates R1 outcomes (Jan 25, '25). - Huggingface reveals huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to duplicate R1, fully open source (Jan 25, '25).

  • OpenAI researcher verifies the DeepSeek team independently discovered and utilized some core concepts the OpenAI group utilized en route to o1

    Liked this post? Join the newsletter.
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
No due date
0
Labels
None
Assign labels
  • View project labels
Reference: eleanorecollee/bonilash#1