# How to Run Deepseek Locally This guide explains how to run the Deepseek model locally using Ollama as your server. Follow these steps to set up and use the model. ## Prerequisites Ensure you have Ollama installed on your machine. If not, follow the installation instructions for Windows at: [Ollama Installation Guide](https://ollama.com/download/windows) ## Getting Started with Deepseek Model ### Step 1: Pull the Deepseek Model To use models in Ollama, start by downloading the desired model using the `pull` command. Open your terminal and run: ```bash ollama pull ``` ### Step 2: Run the Model After downloading, you can start the model with the following command: ```bash ollama run ``` This command activates the model, allowing you to enter queries or instructions, and receive responses. ### Step 3: Using the Model with OpenAI API Specifications Ollama is now compatible with the OpenAI Chat Completions API. This allows you to use additional tooling and applications with Ollama locally. Here's how to set it up: ```python from openai import OpenAI model_name = "" # Initialize the OpenAI client client = OpenAI( base_url = 'http://localhost:11434/v1', api_key='ollama', # This is required but unused ) # Create chat completions response = client.chat.completions.create( model=model_name, messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who won the world series in 2020?"}, {"role": "assistant", "content": "The LA Dodgers won in 2020."}, {"role": "user", "content": "Where was it played?"} ] ) # Print the response print(response.choices[0].message.content) ``` ### Step 4: Configuring WSL2 for Local Server Access If you are using WSL2 and wish to access the Ollama server running on your Windows machine, you need to configure WSL2 with mirror mode to share localhost between WSL2 and Windows. For more details, see: [Network Configuration Guide](network.md)