In today's rapidly evolving AI landscape, creating intelligent agents that can access and utilize vast amounts of information is crucial. This article guides you through setting up DeepSeek and a Dify knowledge base locally, allowing you to build powerful and secure AI agents. This local setup offers unparalleled data privacy and control, making it ideal for businesses and individuals concerned about data security.
Before diving into the setup, ensure you have the following:
Ollama simplifies the process of running large language models like DeepSeek locally.
Install Ollama:
Verify Installation: Open your terminal and run ollama -v
. This command should display the installed Ollama version.
Install DeepSeek Model: Use Ollama to download and run the DeepSeek-r1 model:
ollama run deepseek-r1:7b
For a less restricted version:
ollama run huihui_ai/deepseek-r1-abliterated:7b
Note: Choose the appropriate DeepSeek model size based on your machine's specifications. A 7B model requires approximately 4.7GB of data.
Test DeepSeek: Once the installation is complete, ask the model a question in the terminal. You should receive a response from the DeepSeek model.
Dify provides a user-friendly platform for building AI applications. Here's how to deploy the community edition:
Download the Code:
git clone https://github.com/langgenius/dify.git
Navigate to the Docker Directory: Open your terminal and navigate to the dify/docker
directory within the downloaded Dify folder.
Copy the Configuration File:
cp .env.example .env
Configure Docker Proxy (Optional): If you're behind a proxy, configure Docker to use it. For example edit /etc/docker/daemon.json
and add these lines:
{
"registry-mirrors": [
"https://dockerpull.org",
"https://docker.1panel.dev",
"https://docker.foreverlink.love",
...
]
}
Run Dify with Docker Compose:
docker compose up -d
This command will download the necessary Docker images and start the Dify application in detached mode.
Now that both DeepSeek and Dify are running, let's connect them:
Access Dify: Open your web browser and navigate to http://127.0.0.1
. You should be greeted with the Dify setup page.
Initialize Admin Information: Create an administrator account for your Dify instance.
Configure the Model Provider:
Set Model Information: Configure the DeepSeek model details:
deepseek-r1:7b
http://<your_machine_ip>:11434
(If using containerized Dify, use host.docker.internal
or your machine's IP instead of 127.0.0.1
).32768
Create a Knowledge Base:
Create an Agent: Design your AI agent by defining its purpose, instructions, and the knowledge base it should use.
Dataset
and create one, then upload your documents that will compose the knowledge base.Application
and create a new Agent that will use the previously created Dataset.By following these steps, you can successfully set up a local DeepSeek and Dify knowledge base. This setup empowers you to build intelligent AI agents that offer enhanced privacy, security, and customization. Embrace the power of local AI and unlock new possibilities for your projects and businesses.
Further Reading: