Python deepseek locally

the living tribunal

Moderator
Staff member
moderator
Step 1: Install Ollama
Ollama is a platform that allows you to run AI models offline on your computer. Here’s how you can install it on Windows:

  1. Visit Ollama's official website.
  2. Download the Windows executable file (.exe) from the website.
  3. Double-click the downloaded file to start the installation process.
  4. Follow the on-screen prompts to complete the installation.

Step 2: Download the DeepSeek R1 Model
Once Ollama is installed, download the DeepSeek R1 model.

  1. Open Command Prompt on your Windows machine.
  2. Run the following command to pull the DeepSeek R1 model:
    Code:
    ollama pull deepseek-r1:1.5b

Step 3: Set Up Python Environment
Now, let's set up the Python environment to use DeepSeek.

  1. Make sure you have Python installed. You can download it from Python's official website.
  2. Install necessary packages using pip. Open Command Prompt and run:
    Code:
    pip install ollama

Step 4: Run the DeepSeek R1 Model
Now that everything is set up, you can use DeepSeek in your Python scripts.

Here’s an example script to interact with DeepSeek:
Python:
import ollama

# Initialize the model
model = ollama.Model("deepseek-r1:1.5b")

# Define a query
query = "Explain quantum computing in simple terms"

# Get the response from the model
response = model.generate(query)
print(response)

Step 5: Execute the Script
Save the script as deepseek_example.py and run it using Command Prompt:
Code:
python deepseek_example.py

This will execute your script and display the response from the DeepSeek model.
 
Top