Welcome to MicroROS V2 Robot Car repository
5. RAG Knowledge Base Deployment
RAG Knowledge Base Deployment
RAG Knowledge Base Deployment1. Course Content2. Start the Dify Service3. View the Preset Knowledge Bases4. Extend the RAG Knowledge Base4.1 Economy Mode Knowledge Base4.2 High-Quality Mode Knowledge Base4.3 Recall Testing
1. Course Content
Master the workflow and methods for locally deploying, debugging, and testing a RAG knowledge base.
Master the method of extending the RAG knowledge base according to your own task scenarios.
Tip
The RAG knowledge base helps general-purpose AI large models gain reference knowledge in vertical domains, avoiding hallucinated replies from AI large models and increasing the model's ability to reply with vertical domain knowledge.
The RAG knowledge base can help the robot quickly extend its generalization capability in different task scenarios.
2. Start the Dify Service
Connect to the vehicle via VNC or SSH, and enter the command in the terminal:
sh ~/bringup_dify.sh

Check the IP address of the virtual machine by clicking "Robot Information" on the left side of the desktop.

3. View the Preset Knowledge Bases
Click the "Knowledge" page on the homepage. Dify comes with two preset RAG knowledge bases at the factory, with the same content but different languages.
Tip
The preset knowledge bases here provide training samples for some task scenarios, helping AI models quickly master the relevant skills.

Open a knowledge base. There are two preset files:
Intent MappingandDecision-Layer Sample Library, where:Intent mapping: stores user intents and the corresponding tasks the robot needs to execute.
Decision-layer sample library: stores some preset reference samples for task scenarios.

4. Extend the RAG Knowledge Base
If you need to extend a new knowledge base, click "Create Knowledge".

Here, importing local data is used as the data source example.
Click "Import from file" —> "Browse" —> "Next".

Then enter the knowledge base configuration page. Click the preview block to view the chunking effect of the file. Here, the index mode is set to "Economy".
Tip
For beginners, it is recommended to first use Economy mode for learning and testing. The difference between the two index modes:
Economy: retrieves content in the knowledge base through keywords, cannot perform extended retrieval by similar semantics, and the way of retrieving knowledge chunks is relatively rigid.
High-quality mode: requires an embedding model that consumes extra tokens and requires a rerank model, achieving more accurate similar-semantic chunk retrieval.
4.1 Economy Mode Knowledge Base
After selecting the following configuration, click "Save & Process".

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

When the knowledge base is normal, the status will show "Available". Then click on the knowledge base's files.

Then we can see the chunks of the split knowledge base. The small text below each chunk is the automatically split keywords of that chunk (only available in Economy mode).

If the keywords do not accurately describe the knowledge chunk, click "Edit" on the right side of the chunk to edit the chunk content or keywords individually. The figure below shows modified keywords, and then click "Save".


4.2 High-Quality Mode Knowledge Base
If you need to use a high-quality knowledge base later, refer to the tutorial in this section.
The knowledge base creation and file import process is the same as before.
Here, select "High Quality" as the index method, choose any retrieval method, here "Hybrid Search" is used as an example, and finally click "Save & Process".

4.3 Recall Testing
Recall testing tests the actual effect of the knowledge base recalling relevant knowledge chunks based on input, helping tune for better AI model reply effects.
Open a knowledge base and click "Retrieval Testing" on the left.

Enter test content in the source text (simulating the user input content in actual use), then click "Test".
The recalled chunks and knowledge bases related to the input content will appear on the right. The knowledge base tested here is the Economy mode knowledge base, which retrieves the knowledge base based on keywords.
Tip
The default reference knowledge base at the factory is in High-quality mode.
For the High-quality mode knowledge base, recalled chunks will have a
SCORErating. The higher the score, the better the chunk matches the input content. High-quality mode knowledge bases can perform associative retrieval of similar semantics, but also consume tokens.
