How to Run DeepSeek Locally

Run DeepSeek Locally Using Ollama

Introduction

Running DeepSeek locally using Ollama allows you to leverage powerful language models on your machine without relying on cloud-based APIs. This guide will walk you through the installation, setup, and usage of DeepSeek R1 with Ollama for local inference.


1. Install Ollama

Ollama is a tool designed to run large language models (LLMs) locally. First, install it based on your operating system:

๐Ÿ”น Windows / Mac / Linux

Download and install Ollama from: ๐Ÿ‘‰ https://ollama.com/download

After installation, verify that Ollama is working:

ollama --version

If the version is displayed, Ollama is installed successfully.


2. Download and Run DeepSeek

Ollama provides a simple way to fetch and run models.

There are many model variants of deepseek-r1 which you can find in deepseek-r1.
The ‘b’ in the model name refers to ‘Billion’ parameters, indicating the model’s scale.

To download and run, follow the below step:

๐Ÿ”น Pull and run the DeepSeek Model

ollama run deepseek-r1:7b

This will pull the model from ollama and then launches an interactive terminal where you can start chatting with the model. You can also pull and then run.


3. Using DeepSeek via Local API

Ollama exposes a local API at http://localhost:11434, allowing you to interact with the model programmatically.

๐Ÿ”น Test API with curl

curl -X POST "http://localhost:11434/api/generate" \
     -H "Content-Type: application/json" \
     -d '{
           "model": "deepseek-r1:7b",
           "prompt": "Explain LLMs in simple terms."
         }'

In Powershell

Invoke-RestMethod -Uri "http://localhost:11434/api/generate" -Method Post -Body (@{
>>     model = "deepseek-r1:7b";
>>     prompt = "Explain LLMs in simple terms."
>> } | ConvertTo-Json) -ContentType "application/json"

This allows you to integrate DeepSeek into your applications.


4. Customizing and Fine-Tuning DeepSeek (Optional)

Ollama does not support fine-tuning directly. However, you can:

  • Convert DeepSeek to Hugging Face format.
  • Fine-tune using LoRA (Low-Rank Adaptation).
  • Convert it back to Ollama format.

Would you like a guide on fine-tuning DeepSeek? Let me know in the comments!


Conclusion

Running DeepSeek locally with Ollama gives you privacy, speed, and full control over your AI models. Whether for coding, chat applications, or automation, this setup is a powerful alternative to cloud-based LLMs.

๐Ÿš€ Start experimenting today and unleash the power of DeepSeek on your local machine!

Categories:

Leave a Reply

Your email address will not be published. Required fields are marked *