Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Submit feedback
    • Contribute to GitLab
  • Sign in
S
sheiksandwiches
  • Project
    • Project
    • Details
    • Activity
    • Cycle Analytics
  • Issues 153
    • Issues 153
    • 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
  • Adela Baine
  • sheiksandwiches
  • Issues
  • #118

Closed
Open
Opened Feb 12, 2025 by Adela Baine@adelabaine0415
  • 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 model in numerous benchmarks, but it likewise includes totally MIT-licensed weights. This marks it as the first non-OpenAI/Google design to deliver strong thinking abilities in an open and available manner.

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

The Essentials

The DeepSeek-R1 paper presented numerous models, however main among them were R1 and bybio.co R1-Zero. Following these are a series of distilled models that, while intriguing, I will not go over here.

DeepSeek-R1 uses 2 significant ideas:

1. A multi-stage pipeline where a small set of cold-start information kickstarts the model, followed by large-scale RL. 2. Group Relative Policy Optimization (GRPO), a reinforcement learning method that depends on comparing numerous model outputs per prompt to prevent the need for a different critic.

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

R1-Zero vs R1

R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base without any monitored fine-tuning (SFT). RL is utilized to enhance the design's policy to take full advantage of reward. R1-Zero attains exceptional accuracy however often produces complicated outputs, such as mixing numerous languages in a single reaction. R1 repairs that by including limited supervised fine-tuning and numerous RL passes, which enhances both accuracy and readability.

It is interesting how some languages may express certain concepts much better, which leads the model to select the most expressive language for the task.

Training Pipeline

The training pipeline that DeepSeek released in the R1 paper is immensely intriguing. It showcases how they developed such strong thinking models, and what you can anticipate from each stage. This includes the problems that the resulting designs from each stage have, and how they fixed it in the next phase.

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

The typical training strategy: Pretraining on large dataset (train to anticipate next word) to get the base design → monitored fine-tuning → choice tuning via RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with several SFT and RL stages

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 good starting point. This provides an excellent design to start RL. First RL Stage: Apply GRPO with rule-based rewards to improve thinking 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 step is a strong thinking design but with weak basic abilities, e.g., bad formatting and language blending. Rejection Sampling + general data: Create new SFT data through rejection tasting on the RL checkpoint (from action 2), combined with monitored information from the DeepSeek-V3-Base model. They collected around 600k premium reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k basic tasks) for wider abilities. This action resulted in a strong reasoning model with general capabilities. Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to fine-tune the final model, wiki.vst.hs-furtwangen.de in addition to the reasoning benefits. The result is DeepSeek-R1. They also did design distillation for several Qwen and Llama models on the reasoning traces to get distilled-R1 designs.

Model distillation is a technique where you use a teacher design to improve a trainee model by producing training data for the trainee design. The instructor is generally a bigger design than the trainee.

Group Relative Policy Optimization (GRPO)

The standard idea behind utilizing support learning for LLMs is to tweak the design's policy so that it naturally produces more accurate and helpful answers. They used a reward system that checks not just for accuracy however likewise for proper format and language consistency, so the model gradually discovers to favor actions that satisfy these quality requirements.

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

What makes their approach particularly fascinating is its dependence on straightforward, rule-based reward functions. Instead of depending upon expensive external designs or human-graded examples as in traditional RLHF, the RL utilized for R1 uses basic criteria: it might provide a higher reward if the answer is appropriate, if it follows the anticipated/ formatting, and if the language of the response matches that of the prompt. Not depending on a benefit design also indicates you do not need to spend time and visualchemy.gallery effort training it, and it does not take memory and calculate away from your main model.

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

1. For each input prompt, the model produces different reactions. 2. Each reaction receives a scalar reward based upon elements like precision, formatting, and language consistency. 3. Rewards are adjusted relative to the group's efficiency, basically measuring how much better each response is compared to the others. 4. The model updates its technique a little to prefer reactions with greater relative benefits. It just makes slight adjustments-using techniques like clipping and a KL penalty-to guarantee the policy doesn't stray too far from its original habits.

A cool aspect of GRPO is its flexibility. You can utilize easy rule-based reward functions-for instance, granting a perk when the model correctly uses the syntax-to guide the training.

While DeepSeek used GRPO, you might use alternative methods rather (PPO or PRIME).

For those aiming to dive deeper, Will Brown has composed quite a nice application of an LLM with RL using GRPO. GRPO has likewise currently been included to the Transformer Reinforcement Learning (TRL) library, which is another excellent 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 methods they have actually provided in their paper, I desire to highlight a passage from the DeepSeekMath paper, based on a point Yannic Kilcher made in his video.

These findings show that RL improves the design's general efficiency by rendering the output distribution more robust, in other words, it appears that the enhancement is credited to improving the right response from TopK instead of the enhancement of fundamental abilities.

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

This suggests that support learning on LLMs is more about refining and "shaping" the existing distribution of reactions rather than endowing the design with entirely new capabilities. Consequently, while RL strategies such as PPO and GRPO can produce significant performance gains, there appears to be an inherent ceiling identified 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 turning point. I'm thrilled to see how it unfolds!

Running DeepSeek-R1

I have actually utilized DeepSeek-R1 through the main chat interface for numerous problems, which it appears to fix all right. The extra search functionality makes it even better to utilize.

Interestingly, o3-mini(-high) was launched as I was composing this post. From my preliminary screening, R1 seems 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 carry out when released on a single H100 GPU-not to extensively check the model's abilities.

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

29 layers seemed to be the sweet area provided this setup.

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 complete 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 rather manageable for any major work, however it's enjoyable to run these big models on available hardware.

What matters most to me is a mix of usefulness and time-to-usefulness in these designs. Since reasoning models need to think before answering, their time-to-usefulness is generally greater than other designs, however their usefulness is also normally higher. We need to both maximize usefulness and minimize time-to-usefulness.

70B through Ollama

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

GPU usage 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 fully local "deep scientist" 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 unifies multimodal understanding and wiki.lafabriquedelalogistique.fr generation. It can both comprehend and generate images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through 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 massive support knowing methods. DeepSeek-V3 Technical Report (December 2024) This report talks about the execution of an FP8 mixed precision training framework confirmed on an exceptionally massive design, attaining both sped up training and reduced GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper dives into scaling laws and presents findings that help with the scaling of massive models in open-source configurations. It presents the DeepSeek LLM task, devoted to advancing open-source language models with a long-term viewpoint. DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research study presents 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 premium project-level code corpus and use 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 presents DeepSeek-V2, a Mixture-of-Experts (MoE) language model characterized by economical training and efficient inference. DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research presents DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language design that attains efficiency comparable to GPT-4 Turbo in code-specific jobs.

Interesting occasions

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

  • OpenAI researcher confirms the DeepSeek group independently discovered and used some core concepts the OpenAI team utilized on the method 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: adelabaine0415/sheiksandwiches#118