Here's a step-by-step guide to load and use the DeepSeek-R1-0528-Qwen3-8B-Q4_0.gguf model in Ollama, tailored for beginners:
Prerequisites
-
Install Ollama:
Open your terminal and run:
curl -fsSL https://ollama.com/install.sh | sh
Follow the on-screen instructions to complete the installation.
-
Ensure Your System Meets Requirements:
- GPU (recommended for faster inference) with CUDA drivers.
- The model is quantized to 4-bit (Q4_0), so it should run on most modern GPUs or even CPUs (though slower).
Step 1: Prepare the Model Files
-
Create a Directory for the Model:
Navigate to where you downloaded the .gguf file and create a folder for it:
mkdir ~/ollama_models/deepseek_qwen3_8b
mv DeepSeek-R1-0528-Qwen3-8B-Q4_0.gguf ~/ollama_models/deepseek_qwen3_8b/
-
(Optional) Add Tokenizer Files:
If the model requires a tokenizer (e.g., vocab.json, tokenizer.model, etc.), download them from the Hugging Face model page and place them in the same directory.
Step 2: Add the Model to Ollama
-
Run the ollama add Command:
Use the following command to register the model with Ollama. Adjust paths as needed:
ollama add deepseek-qwen3-8b ~/ollama_models/deepseek_qwen3_8b/DeepSeek-R1-0528-Qwen3-8B-Q4_0.gguf \
--model-type=llama2 \
--quantize=q4_0 \
--tokenizer=DeepSeek/DeepSeek-R1-0528-Qwen3-8B # Specify tokenizer if needed
--model-type=llama2: Assumed architecture (if unsure, try llama2 or qwen).
--quantize=q4_0: Matches your model’s quantization.
--tokenizer: If the tokenizer is hosted on Hugging Face, use its repo name (e.g., DeepSeek/DeepSeek-R1-0528-Qwen3-8B).
-
Check the Model is Added:
ollama list
Ensure deepseek-qwen3-8b appears in the list.
Step 3: Test the Model
Basic Usage (No Thinking Mode)
To get a direct response without intermediate steps:
ollama run deepseek-qwen3-8b "What is the capital of France?"
Thinking Mode (Step-by-Step Reasoning)
To see the model’s thought process (if supported by the model’s configuration):
ollama run deepseek-qwen3-8b --stream "Explain quantum computing in simple terms"
Advanced Configuration (Optional)
If the model doesn’t work, tweak these parameters in the ollama add command:
-
Specify Architecture:
If unsure about --model-type, try --model-type=qwen or omit it (Ollama might auto-detect).
-
Tokenizer Path:
If the tokenizer is in the same directory:
--tokenizer=~/ollama_models/deepseek_qwen3_8b
-
Context Length:
Adjust maximum context length (e.g., 2048):
--context-length=2048
Troubleshooting
-
Error: "Model not found":
Double-check the path to your .gguf file and model name spelling.
-
Error: "Unsupported model type":
Try --model-type=llama or --model-type=qwen.
-
Slow Performance:
Ensure you’re using a GPU by running:
ollama run --gpu deepseek-qwen3-8b "Your query"
Using the Model in Apps
Once added, you can use the model via Ollama’s API in apps like:
- Chat UI:
ollama serve deepseek-qwen3-8b
- VS Code: Use the Ollama extension.
- Custom Scripts:
import requests
response = requests.post(
"http://localhost:11434/generate",
json={
"model": "deepseek-qwen3-8b",
"prompt": "Tell me a joke about AI.",
"max_tokens": 100
}
)
print(response.json()["response"])
You’re now ready to use the DeepSeek-R1-0528-Qwen3-8B model with Ollama! Let me know if you encounter any issues. 😊