https://youtu.be/AHGyGeEhRZs?si=6kWou7t4phzMa0BN

<aside> 👉 These are the steps as described in the YouTube video, as of January 2025

</aside>

Running the model

  1. Download and install Ollama
  2. Find the right model in Ollama’s model page
  3. Run the command listed in the model page ollama run deepseek-r1:7b
    1. This will install the model the first time you run
  4. Start chatting
    1. /bye when you want to leave
    2. ollama stop deepseek-r1:7b if you want to stop the model
  5. Run a different model ollama run deepseek-r1:1.5b

Calling the model from Python

  1. Create a new environment in your project folder python -m venv .venv
  2. Activate the environment source ./.venv/bin/activate
  3. Install Ollama library pip install ollama
  4. Create a new file, e.g. touch ask_deepseek.py
  5. Paste this code in the file
import ollama

response = ollama.chat(
    model="deepseek-r1:1.5b",
    messages=[
        {"role": "user", "content": "Why is the sky blue?"}
    ],
    options={"temperature": 0.7}
)

print(response["message"]["content"])

<aside> 👉 Ollama is also OpenAI API compatible and you can change the base url on your application to http://localhost:11434/v1

</aside>

<aside> 👉

To call DeepSeek’s largest model, see https://api-docs.deepseek.com/

</aside>