Build a Knowledge Base with Dify in 5 Minutes – Large Model Learning Part 2

This step‑by‑step tutorial shows how to install Docker and Dify locally, configure a local LLM via Ollama, create and fine‑tune a knowledge base with segmentation settings, and test the chat assistant, all within about five minutes.

Tech Bean
Tech Bean
Tech Bean
Build a Knowledge Base with Dify in 5 Minutes – Large Model Learning Part 2

Installation

The tutorial begins by installing Docker Desktop from the official Docker website, then cloning the Dify repository at https://github.com/langgenius/Dify. In the dify/docker/ directory, run the following commands in PowerShell:

cp .env.example .env
docker compose up -d  # add --verbose for detailed logs if needed

If network issues cause Docker pull failures, the guide suggests configuring domestic mirror sources by editing the Docker daemon JSON with entries such as "https://docker.m.daocloud.io", "https://hub-mirror.c.163.com", "https://mirror.baidubce.com", and "https://docker.nju.edu.cn". After a successful start, open http://localhost/install in a browser, where the UI shows four menus: Exploration, Studio, Knowledge Base, and Tools.

Adding a Local Model

To use a local model, the tutorial downloads a vector model with Ollama:

# Download vector model
ollama pull bge-large
ollama list

The user then selects the model provider ollama in Dify’s settings and adds the model.

Creating a Knowledge Base

In Dify, click Knowledge Base → Create Knowledge Base . The default segmentation settings are used, but the guide explains each option:

Segment Identifier : default \n, splits text by paragraph.

Maximum Segment Length : default 500 Tokens, with an upper limit of 4000 Tokens.

Overlap Length : recommended 10‑25% of the segment length to improve recall.

Pre‑processing Rules :

Replace consecutive spaces, newlines, and tabs.

Delete all URLs and email addresses.

After configuring, Dify provides a real‑time preview of the segmented chunks, allowing users to adjust the strategy on the left‑hand preview pane.

Indexing and Retrieval Settings

The tutorial advises using the recommended indexing and retrieval options without further modification.

Testing the Knowledge Base

To verify the setup, create a blank application in the Studio, choose the Chat Assistant template, and add a new text entry such as “张江吴彦祖是技术豆”. Select the previously created knowledge base as the source. Sending a query shows that the assistant can retrieve the inserted content, confirming the knowledge base works.

Next Steps

The author notes that the next episode will cover building workflows with Dify.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerLLMopen sourceknowledge baseDifyOllama
Tech Bean
Written by

Tech Bean

Learning, sharing, and news

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.