Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • P pecanchoice
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 61
    • Issues 61
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Adrienne Angles
  • pecanchoice
  • Issues
  • #34

Closed
Open
Created Feb 14, 2025 by Adrienne Angles@adrienneanglesMaintainer

Understanding DeepSeek R1


DeepSeek-R1 is an open-source language design developed on DeepSeek-V3-Base that's been making waves in the AI neighborhood. Not just does it match-or even surpass-OpenAI's o1 design in many criteria, however it likewise features totally MIT-licensed weights. This marks it as the first non-OpenAI/Google design to deliver strong reasoning abilities in an open and available way.

What makes DeepSeek-R1 especially 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 economical, with input tokens costing simply $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 much better models required more data and compute. While that's still legitimate, designs like o1 and R1 demonstrate an option: inference-time scaling through thinking.

The Essentials

The DeepSeek-R1 paper presented multiple models, however main amongst them were R1 and R1-Zero. Following these are a series of distilled models that, while intriguing, I won't go over here.

DeepSeek-R1 uses 2 significant ideas:

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

R1 and R1-Zero are both reasoning designs. This essentially suggests they do Chain-of-Thought before responding to. For the R1 series of models, this takes type as believing within a tag, before addressing with a final 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 benefit. R1-Zero attains excellent precision but sometimes produces complicated outputs, such as blending numerous languages in a single response. R1 repairs that by integrating minimal supervised fine-tuning and multiple RL passes, historydb.date which enhances both accuracy and readability.

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

Training Pipeline

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

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

The typical training technique: Pretraining on large dataset (train to anticipate next word) to get the base design → monitored fine-tuning → choice tuning through 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 ensure the RL procedure has a good starting point. This provides an excellent model to begin RL. First RL Stage: Apply GRPO with rule-based benefits to improve reasoning accuracy and formatting (such as forcing chain-of-thought into thinking tags). When they were near merging in the RL process, they transferred to the next step. The result of this step is a strong thinking design however with weak basic capabilities, e.g., bad formatting and language blending. Rejection Sampling + general information: Create brand-new SFT information through rejection tasting on the RL checkpoint (from step 2), integrated with supervised information from the DeepSeek-V3-Base model. They gathered around 600k premium thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k thinking + 200k basic tasks) for wider abilities. This step resulted in a strong reasoning model with basic abilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to refine the final model, in addition to the reasoning benefits. The result is DeepSeek-R1. They likewise did model distillation for several Qwen and Llama models on the reasoning traces to get distilled-R1 designs.

Model distillation is a technique where you utilize a teacher design to enhance a trainee design by creating training data for the trainee model. The teacher is typically a larger model than the trainee.

Group Relative Policy Optimization (GRPO)

The basic idea behind using support learning for LLMs is to fine-tune the model's policy so that it naturally produces more precise and helpful responses. They utilized a benefit system that inspects not only for correctness but also for correct formatting and language consistency, so the model gradually finds out to favor responses that meet these quality requirements.

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

What makes their technique particularly fascinating is its dependence on straightforward, rule-based benefit functions. Instead of depending upon costly external designs or human-graded examples as in conventional RLHF, the RL utilized for R1 uses simple criteria: it may provide a higher benefit if the answer is right, if it follows the anticipated/ format, and if the language of the response matches that of the timely. Not counting on a benefit model likewise implies you don't need to hang out and effort training it, and it does not take memory and compute far from your main model.

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

1. For each input timely, the design creates different actions. 2. Each response receives a scalar benefit based on aspects like precision, formatting, 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 design updates its technique slightly to prefer reactions with higher relative benefits. It just makes small adjustments-using methods like clipping and a KL penalty-to guarantee the policy does not wander off too far from its initial habits.

A cool aspect of GRPO is its versatility. You can use simple rule-based reward functions-for instance, awarding a bonus offer when the design properly utilizes the syntax-to guide the training.

While DeepSeek used GRPO, you could utilize alternative approaches instead (PPO or PRIME).

For those aiming to dive deeper, Will Brown has written rather a good application of training an LLM with RL using GRPO. GRPO has actually also already been added to the Transformer Reinforcement Learning (TRL) library, which is another great 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 last note on explaining DeepSeek-R1 and the methodologies they have actually presented 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 boosts the design's overall efficiency by rendering the output circulation more robust, to put it simply, it appears that the improvement is credited to boosting the proper action from TopK instead of the enhancement of basic capabilities.

In other words, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are most likely to be right, despite the fact that the total ability (as measured by the diversity of proper answers) is mainly present in the pretrained design.

This suggests that support knowing on LLMs is more about refining and "forming" the existing distribution of actions instead of enhancing the design with entirely brand-new abilities. Consequently, while RL techniques such as PPO and GRPO can produce considerable performance gains, vmeste-so-vsemi.ru there appears to be an intrinsic ceiling figured out by the underlying model's 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 thrilled to see how it unfolds!

Running DeepSeek-R1

I have actually used DeepSeek-R1 by means of the main chat user interface for various issues, which it seems to solve well enough. The additional search performance makes it even better to use.

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

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

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 by means of llama.cpp:

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

Performance:

A r/localllama user explained that they had the ability to overcome 2 tok/sec with DeepSeek R1 671B, without using their GPU on their regional gaming setup. Digital Spaceport wrote 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 rather manageable for any major work, but it's enjoyable to run these big designs on available hardware.

What matters most to me is a mix of usefulness and time-to-usefulness in these designs. Since thinking models require to think before addressing, their time-to-usefulness is typically greater than other designs, but their usefulness is likewise typically higher. We require to both take full advantage of usefulness and reduce time-to-usefulness.

70B by means of Ollama

70.6 b params, 4-bit KM quantized DeepSeek-R1 running via 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 totally local "deep scientist" with DeepSeek-R1 - YouTube). DeepSeek R1's dish 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 a novel autoregressive structure that unifies 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 thinking design that equals the efficiency of OpenAI's o1. It provides a detailed approach for training such designs using large-scale reinforcement knowing methods. DeepSeek-V3 Technical Report (December 2024) This report talks about the execution of an FP8 combined precision training framework verified on an exceptionally massive design, attaining both sped up training and minimized GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper digs into scaling laws and provides findings that help with 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 viewpoint. DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research presents the DeepSeek-Coder series, a series 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 use a fill-in-the-blank task to boost code generation and infilling. DeepSeek-V2: A Strong, Economical, accc.rcec.sinica.edu.tw and Efficient Mixture-of-Experts Language Model (May 2024) This paper presents DeepSeek-V2, users.atw.hu a Mixture-of-Experts (MoE) language model defined by cost-effective training and effective 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 performance comparable to GPT-4 Turbo in code-specific jobs.

Interesting occasions

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

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

    Liked this post? Join the newsletter.
Assignee
Assign to
Time tracking