# RAG Knowledge Base Retrieval System

Utilizing external databases or knowledge bases for retrieval, and combining retrieval results with large language models to generate more precise and contextually relevant responses.

The core of RAG technology is combining the language capabilities of generative AI with knowledge retrieval capabilities, enabling models to not only rely on internal training data when answering questions, but also dynamically obtain the latest and more specialized information from external databases and incorporate this information into generated responses.

<figure><img src="/files/TdldL8wshLPoFGNscnHC" alt=""><figcaption><p>RAG Flow</p></figcaption></figure>

## High-Precision RAG System

{% hint style="info" %}
While RAG knowledge base retrieval systems can be quickly implemented using Vector Search and released as a basic version, improving their response accuracy further presents challenges. Response accuracy is crucial for user experience as it directly affects users' trust and satisfaction with system responses. If response accuracy is insufficient, users may doubt the system's answers, reducing their willingness to use it.
{% endhint %}

According to data from the 2023 OpenAI Developer Conference, RAG systems using only simple vector similarity search (Vector Search) and selecting the correct embedding model can achieve 45% accuracy. Adding HyDE Retrieval, FT Embeddings, and Chunk/Embedding Experiments can achieve 65% response accuracy.

MaiAgent RAG not only includes the RAG technologies mentioned at the OpenAI Developer Conference but also combines various classic NLP algorithms and proprietary retrieval technologies. Through internal datasets compared with OpenAI RAG's response accuracy, both can achieve 95% response accuracy.

<figure><img src="/files/u8qLGcGHOpLH0DzckeNU" alt="" width="561"><figcaption><p>MaiAgent RAG Response Accuracy</p></figcaption></figure>

The MaiAgent platform provides two types of RAG: MaiAgent RAG and OpenAI RAG. Here's a comparison table of various aspects:

|                            | MaiAgent RAG                                                                                  | OpenAI RAG                                                                                                     |
| -------------------------- | --------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| Model Support              | Supports all models👍                                                                         | Only supports OpenAI models                                                                                    |
| Environment Support        | Supports cloud and on-premises👍                                                              | Cloud only, data must be sent to OpenAI                                                                        |
| Response Accuracy          | Very high👍                                                                                   | Very high👍                                                                                                    |
| Supported File Formats     | Supports all common formats👍 doc, docx, xls, xlsx, csv, ppt, pptx, pdf, txt, json, jsonl, md | <p>No support for xlsx, csv<br>No support for jsonl<br>No support for legacy Office files (doc, xlsx, ppt)</p> |
| Image Support in Documents | Yes (currently experimental)👍                                                                | No                                                                                                             |
| Table Support in Documents | Yes (currently experimental)👍                                                                | No                                                                                                             |
| Attachment Upload Support  | Supported👍                                                                                   | Supported👍                                                                                                    |
| Data Slice Transparency    | Visualized👍                                                                                  | Black box                                                                                                      |
| Debug Difficulty           | Normal👍                                                                                      | Black box, cannot debug                                                                                        |
| Top K Adjustment           | Enterprise version customization👍                                                            | None                                                                                                           |
| Embedding Model Switch     | Enterprise version customization👍                                                            | None                                                                                                           |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.maiagent.ai/tech/maiagent-tech-en/quickstart/rag.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
