Installing and Running Ollama with Deepseek-R 1.5B
This guide walks through installing Ollama and running the Deepseek-R 1.5B model on your local machine.
Prerequisites
- A Linux, macOS, or Windows system with WSL2
- At least 8GB RAM (16GB recommended)
- 4GB free disk space
- NVIDIA GPU recommended but not required
Installing Ollama
Linux
curl -fsSL https://ollama.com/install.sh | sh
macOS
Download and install from https://ollama.com/download
Windows
- Install WSL2 if not already installed
- Follow Linux installation instructions within WSL2
Getting Started
- Start the Ollama service:
systemctl start ollama # Linux with systemd
ollama serve # macOS or manual start
- Pull the Deepseek-R 1.5B model:
ollama pull deepseek-coder:1.5b
Running the Model
Command Line Interface
ollama run deepseek-coder:1.5b
API Usage
Start making requests to the local API endpoint:
curl -X POST http://localhost:11434/api/generate -d '{
"model": "deepseek-coder:1.5b",
"prompt": "Write a Python function to calculate fibonacci numbers"
}'
Common Parameters
Adjust these parameters when running the model:
- Temperature (creativity):
--temperature 0.7
- Context length:
--ctx-size 2048
- System prompt:
--system "You are a helpful coding assistant"
Example with parameters:
ollama run deepseek-coder:1.5b --temperature 0.7 --ctx-size 2048
Troubleshooting
If the model fails to load:
- Check available system memory
- Ensure GPU drivers are up to date (if using GPU)
- Verify model was downloaded successfully
If you get API connection errors:
- Confirm Ollama service is running
- Check if port 11434 is available
- Verify firewall settings
Resources
Additional Tips
- Use
ctrl+c
to exit the chat interface
- Use
ollama list
to see installed models
- Use
ollama rm deepseek-coder:1.5b
to remove the model
sadfsafd
private processPrompt(userMessage: string): string {
const selectedCode = this.getSelectedCode();
const systemPrompt = `You are an expert programming assistant. Format your responses using these rules:
1. Use markdown formatting with proper code blocks
2. Separate explanations and code with clear headings using markdown (##)
3. Keep explanations concise and focused
4. Structure complex responses in sections
`;
const prompt = `
${selectedCode ? `**Context (Selected Code):** \`\`\` ${selectedCode} \`\`\`\n` : ''}
**User Query:** ${userMessage}
**Task:** Provide a clear, well-structured response that directly addresses the query. Include relevant code examples where appropriate.
`;
return prompt;
// const response = await this.getResponseText(prompt);
// return response;
}