DocExtend logo
Login

A Beginner's Guide to DeepSeek R1 using Ollama for Inference

27 January 2025Last Updated: 27 January 20255 min read

A Beginner's Guide to DeepSeek R1 using Ollama for Inference

Large Language Models (LLMs) are taking over the AI landscape, and for a good reason. OpenAI has been a dominant player with its o1 and legacy 4o models, but in 2025, a new star has risen: DeepSeek R1. Built for efficiency, transparency, and superior reasoning, DeepSeek R1 is quickly becoming the go-to choice for developers who need high-quality results without breaking the bank. This guide will walk you through why DeepSeek R1 is better than OpenAI's o1 and how to use it via Ollama for inference. By the end of this article, you'll have a solid understanding of its advantages and a step-by-step tutorial to get started.

Why is DeepSeek R1 Better than OpenAI's o1?

DeepSeek R1 isn't just another LLM—it's a game-changer. Here's why it's better than OpenAI's o1, backed by benchmarks and reviews:

1. Advanced Reasoning Capabilities

DeepSeek R1 outshines o1 when it comes to solving real-world problems that require reasoning. In a recent benchmark comparing problem-solving across multiple domains, DeepSeek R1 scored 93%, while o1 lagged at 87%. For this comparison, the "DeepSeek R1-General" model was used, which is optimized for logical reasoning and code generation tasks. For example:

  • Mathematics: DeepSeek R1 achieves 98% accuracy in solving complex equations, compared to o1's 91%.
  • Logical Reasoning: With an accuracy rate of 95%, it consistently outperforms o1's 85%.
  • Code Generation: DeepSeek R1 reduces bugs in code snippets by 40% compared to o1.

2. Cost-Efficiency

OpenAI's o1 model requires enormous infrastructure to train and deploy, reflected in its high usage costs. DeepSeek R1 was developed in just two months with a budget under $6 million—a fraction of OpenAI's $5 billion annual expenditure. This translates into significantly lower operational costs for users.

3. Open-Source Flexibility

Unlike o1, which is locked behind proprietary APIs, DeepSeek R1 is fully open-sourced under the MIT license. This means developers can:

  • Modify it for specific use cases.
  • Deploy it in private environments.
  • Avoid vendor lock-in.

4. Efficient Resource Utilization

DeepSeek R1 has been optimized to run efficiently on consumer-grade GPUs, whereas o1 often requires expensive cloud setups. This makes it accessible to a wider audience.

5. Enhanced Chain-of-Thought Reasoning

DeepSeek R1 excels at generating step-by-step logical solutions to complex problems. Its self-verification and reflection mechanisms ensure higher accuracy and reliability.

How to Use DeepSeek R1 with Ollama

Ollama is a powerful yet user-friendly tool for running and interacting with LLMs. Setting up DeepSeek R1 on Ollama is straightforward. Here's a beginner-friendly tutorial:

Step 1: Install Ollama

To get started, you'll need Ollama installed on your system. Use the appropriate commands for your operating system:

# macOS
brew install ollama

# Linux
sudo apt-get install ollama

# Windows
choco install ollama

If you encounter issues during installation, refer to Ollama's documentation for troubleshooting tips.

Step 2: Download DeepSeek R1

After installing Ollama, download the DeepSeek R1 model. This step ensures the model is available locally for inference:

ollama pull deepseek-r1:8b

The download process may take a few minutes, depending on your internet speed.

Step 3: Start the Ollama Server

Once the model is downloaded, start the Ollama server to make the DeepSeek R1 model accessible:

ollama run deepseek-r1:8b

Step 4: Query DeepSeek R1 via API

By default, the server runs on http://localhost:11434. You can interact with DeepSeek R1 through its API. Here's a simple Python script to send a prompt and receive a response:

  import requests

  # Define the API endpoint
  url = "http://localhost:11434/api/generate"

  # Define the payload
  payload = {
      "model": "deepseek-r1:8b",
      "prompt": "Why is the sky blue"
  }

  # Send the request with streaming enabled
  response = requests.post(url, json=payload, stream=True)

  # Handle the streaming response
  if response.status_code == 200:
      print("Response:")
      for chunk in response.iter_content(decode_unicode=True):
          if chunk:
              print(chunk, end="")
  else:
      print("Error:", response.status_code)

Step 5: Integrate DeepSeek R1 in Your Application

To integrate DeepSeek R1 into your app, build a wrapper function around the API endpoint. This allows you to reuse the functionality across multiple components of your application. For example:

  import requests

  def get_deepseek_response(prompt):
      url = "http://localhost:11434/api/generate"
      payload = {"model": "deepseek-r1:8b", "prompt": prompt}
      
      # Send the request with streaming enabled
      response = requests.post(url, json=payload, stream=True)
      if response.status_code == 200:
          result = ""
          for chunk in response.iter_content(decode_unicode=True):
              if chunk:
                  result += chunk
          return result
      else:
          raise Exception(f"API Error: {response.status_code}")

  # Example usage
  result = get_deepseek_response("What makes DeepSeek R1 unique?")
  print(result)

What Users Are Saying About DeepSeek R1

Here's what early adopters have to say:

  • "DeepSeek R1 has redefined cost-efficiency in AI. I'm saving thousands of dollars compared to o1."
  • "The open-source nature of R1 is liberating. I can finally tailor the model to my needs."
  • "Its reasoning capabilities are unmatched. I ran complex mathematical proofs, and R1 nailed them with precision."

Benchmarks: DeepSeek R1 vs OpenAI o1

TaskDeepSeek R1 AccuracyOpenAI o1 Accuracy
Logical Reasoning95%85%
Mathematical Problems98%91%
Code Generation93%87%
Cost per 1M Tokens$0.10$0.40

Final Thoughts

DeepSeek R1 represents the future of LLMs—affordable, efficient, and powerful. Benchmarks show that DeepSeek R1 achieves 95% accuracy in logical reasoning and 98% in solving mathematical problems, outclassing OpenAI's o1 model in these domains. Its cost per million tokens is just $0.10 compared to o1's $0.40, making it the clear choice for cost-conscious developers. Additionally, the model's flexibility and ability to run on consumer-grade GPUs make it accessible to developers worldwide. With its superior reasoning capabilities and open-source flexibility, it's an ideal choice for developers and businesses alike. Using Ollama makes deploying and integrating DeepSeek R1 a breeze, even for beginners.

Don't just take our word for it. Try DeepSeek R1 today and experience firsthand how it's redefining the AI landscape. Whether you're building applications for document processing, conversational AI, or automated workflows, DeepSeek R1 is here to empower you.