Welcome to DOFBOT SE repository
6. Deploy the RAG knowledge base
Deploy the RAG Knowledge Base
Deploy the RAG Knowledge BaseCourse ContentStart DifyView Preset Knowledge BasesExpand RAG Knowledge BaseEconomic Mode Knowledge BaseHigh-Quality Mode Knowledge BaseRecall Test
Course Content
Master the local deployment, debugging, and testing processes and methods for RAG knowledge bases
Master methods for expanding RAG knowledge bases based on your own task scenarios
Tip
RAG knowledge bases help general-purpose AI large models provide reference knowledge in vertical domains, avoiding AI large model hallucination responses and improving the model's response capability in vertical domain knowledge.
RAG knowledge bases can help robots quickly expand generalization capabilities across different task scenarios.
Start Dify
Open the terminal. The yellow text shows the current virtual machine's IP address, or enter ifconfig in the terminal to check.

View Preset Knowledge Bases
Click the Knowledge page on the homepage. Dify has 2 preset RAG knowledge bases at the factory. The content is the same, just in different languages.
Tip
The preset knowledge bases here provide some training samples for task scenarios to help AI models quickly master related skills.
Open a knowledge base. Inside is the
Decision Layer Sample Librarypreset file, where:Decision Layer Sample Library: Stores preset reference samples related to specific task scenarios.

Expand RAG Knowledge Base
If you need to expand a new knowledge base, click Create Knowledge Base.

Here, taking importing local data as an example,
Click "Import from file" -> Browse -> Next

Then enter the knowledge base configuration page. Click the preview block to check the chunking effect of the file. Here, select "Economical" for the indexing mode.
Tip
For beginners, it is recommended to first use the economic mode for learning and testing. The differences between the two indexing modes are:
Economic: Retrieves content from the knowledge base through keywords. Cannot perform extended semantic similarity retrieval. The retrieval method for knowledge fragments is relatively rigid.
High-Quality mode: Requires embedding models to consume additional tokens and needs a rerank model. Can achieve more accurate similar semantic fragment retrieval.
The factory default knowledge base mode is high-quality mode knowledge base.
Economic Mode Knowledge Base
After selecting the following configuration, click "Save & Process".

Then wait for the embedding to complete and click "Go to the document".

When the knowledge base is normal, the status will show as available. Then click the knowledge base's file.

Then we can see the knowledge base fragments that have been segmented. Each fragment has small text below indicating the automatically segmented keywords for that chunk (only the economic mode has this).

If the keywords do not accurately describe the knowledge fragment, click "Edit" on the right side of the fragment to edit the content or keywords of that fragment. The image below shows the modified keywords, then click save.

High-Quality Mode Knowledge Base
If you need to use the high-quality knowledge base later, refer to this section's tutorial.
The knowledge base creation and file import are the same as above.
Here, select "High-Quality" for the indexing method. Choose any for the retrieval method. Here we take "Hybrid Retrieval" as an example. Finally, save and process.

Recall Test
Recall testing tests the actual effectiveness of retrieving relevant knowledge snippets from the knowledge base based on the input, helping to optimize the AI model's response performance.
After opening a knowledge base, click on "Recall Test" on the left side.

Enter the test content in the source text (simulating user input during actual use), and then click "Test".
The retrieved paragraphs and the knowledge base related to the input content will appear on the right. The knowledge base tested here is the economic model knowledge base, which retrieves information based on keywords.

If it's a high-quality mode knowledge base, the retrieved snippets will have a
SCORErating. A higher score indicates a higher relevance between the snippet and the input content. High-quality mode knowledge bases can perform associative retrieval of similar semantics, but also consume tokens.

This case is for reference only. The USB camera has no depth data. Removing height anomaly codes will cause the machine to be unable to run.