Welcome to DOFBOT SE repository
2.RAG retrieval enhancement and model training samples
RAG Retrieval Enhancement and Model Training Samples
Course Content
This section introduces three key concepts: LLM hallucination, RAG retrieval enhancement, and model training samples. This provides the theoretical foundation for subsequent hands-on operations and facilitates deeper understanding of the procedures.
What is LLM Hallucination? Why Does LLM Hallucination Occur?
The primary purpose of RAG retrieval enhancement and model training samples is to reduce LLM hallucination. Let us first understand what LLM hallucination means.
LLM hallucination refers to situations where the model outputs content that is inconsistent with real-world facts or logic when understanding the environment, generating instructions, or planning actions. This can cause the robot to make incorrect decisions or result in significant deviation from the user's expected outcomes.
Why does LLM hallucination occur? LLMs are essentially probability prediction systems trained on massive amounts of text. In certain specific domains or scenarios, training data may lack sufficient samples, causing the model to "fabricate" content to fill gaps.
RAG Retrieval Enhancement and Training Samples
RAG Retrieval Enhancement
RAG (Retrieval-Augmented Generation) is an architecture that combines retrieval systems (Retrieval) with generation models (Generation). It aims to address the limitations of traditional generation models when handling open-domain knowledge Q&A, real-time information queries, and other scenarios. These limitations include outdated knowledge, factual hallucination, and long-text dependency. The core logic is: retrieve relevant knowledge and incorporate it into the Prompt, allowing the LLM to reference corresponding knowledge, thereby achieving "retrieve first, then generate".

Training Samples
Training samples are contained within the RAG knowledge base. The robot comes pre-configured with two knowledge bases from the factory: the action function library and training samples. The training samples include scenarios from course cases, providing the LLM with decision-making reference for specific scenarios. The chapter [2.AI Model Basics - 5. Configuring AI Model] will explain how to configure and expand proprietary knowledge bases and training samples.
Functions of RAG Retrieval Enhancement and Training Samples on Robots
Reducing LLM Hallucination
When the LLM encounters domains it has never been exposed to or special user requirements, it will provide possible results based on existing training data. However, these results may differ from what the user expects or fail to meet the requirements of specific scenarios.
Enhancing Robot Scenario Generalization Capability
The robot comes pre-configured with training samples related to course cases from the factory (detailed explanation will be provided in the configuring LLM course). These training samples provide the LLM with reference information for specific scenarios. Users can also add their own training samples to customize their robot for different application domains.
Reducing Model Prompt Tokens
If the number of training samples and knowledge base entries is relatively small, they can be placed directly in the LLM prompt. The prompt contains role settings, requirements, and other information that users need to communicate to the LLM in advance. If you need to add your own training scenarios and the robot action function library, as the knowledge base grows larger, an overly long prompt will consume more token quota. Therefore, RAG retrieval enhancement was introduced to uniformly manage the robot action function library and training samples.
Facilitating Expansion and Management of Robot Capabilities
The Alibaba Bailian LLM platform (also known as TongYi QianWen platform) provides online management for knowledge bases and training samples, enabling users to conveniently manage and expand their data. Domestic users default to using the Alibaba Bailian LLM platform to manage the action function library and training samples. International users manage knowledge base content using locally deployed Dify.