Create an Application Integrated with Knowledge Base
A “Knowledge Base” can be used as an external information source to provide precise answers to user questions via LLM. You can associate an existing knowledge base with any application type in Dify. Taking a chat assistant as an example, the process is as follows:- Go to Knowledge — Create Knowledge — Upload file
- Go to Studio — Create Application — Select Chatbot
- Enter Context, click Add, and select one of the knowledge base created
- Use Metadata Filtering to refine document search in your knowledge base
- In Context Settings — Retrieval Setting, configure the Retrieval Setting
- Enable Citation and Attribution in Add Features
- In Debug and Preview, input user questions related to the knowledge base for debugging
- After debugging, click Publish button to make an AI application based on your own knowledge!
Connect Knowledge and Set Retrieval Mode
In applications that utilize multiple knowledge bases, it is essential to configure the retrieval mode to enhance the precision of retrieved content. To set the retrieval mode for the knowledge bases, navigate to Context — Retrieval Settings — Rerank Setting.Retrieval Setting
The retriever scans all knowledge bases linked to the application for text content relevant to the user’s question. The results are then consolidated. Below is the technical flowchart for the Multi-path Retrieval mode:

- Semantic Value of 1 This mode activates semantic retrieval only. By utilizing the Embedding model, the search depth can be enhanced even if the exact words from the query do not appear in the knowledge base, as it calculates vector distances to return the relevant content. Furthermore, when dealing with multilingual content, semantic retrieval can capture meanings across different languages, yielding more accurate cross-language search results.
- Keyword Value of 1 This mode activates keyword retrieval only. It matches the user’s input text against the full text of the knowledge base, making it ideal for scenarios where the user knows the exact information or terminology. This method is resource-efficient, making it suitable for quickly retrieving information from large document repositories.
- Custom Keyword and Semantic Weights In addition to enabling only semantic or keyword retrieval modes, we offer flexible custom Weight Score. You can determine the best weight ratio for your business scenario by continuously adjusting the weights of both.

- TopK: Determines how many text chunks, deemed most similar to the user’s query, are retrieved. It also automatically adjusts the number of chunks based on the chosen model’s context window. The default value is 3, and higher numbers will recall more text chunks.
- Score Threshold: Sets the minimum similarity score required for a chunk to be retrieved. Only chunks exceeding this score are retrieved. The default value is 0.5. Higher thresholds demand greater similarity and thus result in fewer chunks being retrieved.
Metadata Filtering
Chatflow/Workflow
The Knowledge Retrieval node allows you to filter documents using metadata fields.Steps
-
Select Filter Mode:
- Disabled (Default): No metadata filtering.
- Automatic: Filters auto-configure from query variables in the Knowledge Retrieval node.
Note: Automatic Mode requires model selection for document retrieval.

- Manual: Configure filters manually.

-
For Manual Mode, follow these steps:
- Click Conditions to open the configuration panel.

- Click +Add Condition:
- Select metadata fields within your chosen knowledge base from the dropdown list.
Note: When multiple knowledge bases are selected, only common metadata fields are shown in the list.
- Use the search box to find specific fields.

- Click +Add Condition to add more fields.

- Configure filter conditions:
- Add filter values:
- Variable: Select from existing Chatflow/Workflow variables.

- Constant: Enter specific values.
Time-type fields can only be filtered by constants The date picker is for time-type fields.

Filter values are case-sensitive and require exact matches. Example: a filter
starts with "App" or contains "App" will match “Apple” but not “apple” or “APPLE”.- Set logic operators:
AND: Match all conditionsOR: Match any condition

- Click outside the panel to save your settings.
Chatbot
Access Metadata Filtering below Knowledge (bottom-left). Configuration steps are the same as in Chatflow/Workflow.
View Linked Applications in the Knowledge Base
On the left side of the knowledge base, you can see all linked Apps. Hover over the circular icon to view the list of all linked apps. Click the jump button on the right to quickly browser them.
Frequently Asked Questions
- How should I choose Rerank settings in multi-recall mode?
- What should I do if I encounter issues finding the “Weight Score” or the requirement to configure a Rerank model?

- What should I do if I cannot adjust the “Weight Score” when referencing multiple knowledge bases and an error message appears?
- Why can’t I find the “Weight Score” option in multi-recall mode, and only see the Rerank model?