DeepSeek-R1, developed by the Chinese AI company DeepSeek, has generated significant excitement within the AI community. Often compared to OpenAI's leading models, DeepSeek-R1 distinguishes itself by being open-source, allowing users to download and run it locally. This article provides a comprehensive guide on how to set up DeepSeek-R1 on your local machine using Ollama, a valuable tool for local AI model deployment.
DeepSeek-R1 offers several compelling advantages:
Ollama is a free and open-source tool designed to simplify the process of running Natural Language Processing (NLP) models locally. It streamlines the installation, configuration, and management of language models, making it an ideal platform for deploying DeepSeek-R1. Using Ollama, you can easily download and run DeepSeek-R1 without complex setups.
Ollama supports various parameter sizes of DeepSeek-R1, allowing you to choose one that fits your hardware capabilities. Available versions include 1.5b, 7b, 8b, 14b, 32b, 70b, and 671b, with hardware requirements increasing alongside parameter size. For this tutorial, we will focus on the 7b model.
Open your terminal after installing Ollama.
Execute the following command to download the DeepSeek-R1 7b model:
ollama run deepseek-r1:7b
This command instructs Ollama to download the model. The download time will depend on your internet speed.
Run the following command in your terminal:
ollama list
If the installation was successful, you should see deepseek-r1:7b
in the list of available models.
Start the model by entering the following command:
ollama run deepseek-r1:7b
This command launches DeepSeek-R1 locally, allowing you to interact with it directly from your terminal.
Once the model is running, you can start posing queries. DeepSeek-R1 is particularly adept at chain-of-thought reasoning and coding tasks.
To further explore the capabilities of DeepSeek-R1, consider building a Retrieval Augmented Generation (RAG) application. This involves combining DeepSeek-R1 with a vector database like SingleStore to create an application that can retrieve and generate information based on custom documents.
qa_chain = RetrievalQA.from_chain_type(
llm=client,
chain_type="stuff",
retriever=docsearch.as_retriever(search_kwargs={"k": 3}),
return_source_documents=True
)
Query the System: Ask a question to the RAG system.
query = "What India's GDP growth is projected to be?"
result = qa_chain.invoke({"query": query})
Display Results: Show the answer and sources.
print("Answer:", result["result"])
print("\nSources:")
for doc in result["source_documents"]:
print(f"- Page {doc.metadata['page']}: {doc.page_content[:100]}...")
By following this guide, you can successfully set up and run DeepSeek-R1 locally, opening up new possibilities for local AI integration. Experiment with DeepSeek-R1 and explore the potential of local AI models in various applications.