wiki:Deepseek

Deepseek

ref here
ref here
To run deepseek locally, we need to install ollama then deepseek-r1:1.5b, deepseek-r1:7b, or deepseek-r1:8b, 14b, 32b, 70b.
The deepseek-r1:14b model is likely a 14-billion-parameter model. The size of such models can vary depending on the precision (e.g., FP16, INT8, etc.), but as a rough estimate:

  • A 14B parameter model in FP16 precision typically requires around 28 GB of disk space (2 bytes per parameter).
  • If the model is quantized (e.g., INT8), it could be smaller, around 14 GB (1 byte per parameter).
~]$ docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
~]$ docker exec -it ollama ollama run deepseek-r1:8b
>>> /?
Available Commands:
  /set            Set session variables
  /show           Show model information
  /load <model>   Load a session or model
  /save <model>   Save your current session
  /clear          Clear session context
  /bye            Exit
  /?, /help       Help for a command
  /? shortcuts    Help for keyboard shortcuts

Use """ to begin a multi-line message.

>>> Send a message (/? for help)
>>> give me an example python code for TCP server listening on port 1234
>>> what is the answer of x from x^2 - 5x + 6 =0

Client test with http post

We write simple python3 code simplePrompt.py to ask what is the result of 1+1=?
The other example was to send data.csv file attached to the request query_data_csv.py to analyze the data. All files attached with in this page.

import requests

# Send a prompt to the Ollama API
def ask_ollama(prompt):
    try:
        # Ollama API endpoint
        url = "http://192.168.19.15:11434/api/generate"
        
        # Payload for the API request
        payload = {
            "model": "deepseek-r1:8b",  # Replace with the correct model name
            "prompt": prompt,
            "stream": False  # Set to True if you want streaming responses
        }
        
        # Send the request to the Ollama API
        response = requests.post(url, json=payload)
        
        # Check if the request was successful
        if response.status_code == 200:
            # Parse the JSON response
            result = response.json()
            return result.get("response", "No response from model")
        else:
            print(f"Error: {response.status_code} - {response.text}")
            return None
    except Exception as e:
        print(f"Error sending request to Ollama: {e}")
        return None

# Main function
if __name__ == "__main__":
    # Define the prompt
    prompt = "What is 1 + 1?"
    
    # Send the prompt to Ollama
    print(f"Sending prompt: {prompt}")
    response = ask_ollama(prompt)
    
    if response:
        print("Model Response:")
        print(response)
    else:
        print("Failed to get a response from the model.")

Last modified 2 weeks ago Last modified on 02/05/25 15:49:25

Attachments (3)

Download all attachments as: .zip