# RAG 知識庫檢索系統

利用外部資料庫或知識庫進行檢索，並將檢索結果與大型語言模型結合，生成內容更加精準且上下文相關的回應。

RAG 技術的核心是將生成式 AI 的語言能力與知識檢索能力結合，使模型在回答問題時，不僅依賴於內部訓練數據，還能動態地從外部資料庫中獲取最新且更具專業性的資訊，並將這些資訊融入到生成的回應中。

<figure><img src="https://527168072-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F38pkhhqHl1oA6yyE9R2n%2Fuploads%2Fgit-blob-0ce05108866ecded0daa5a9fb3cd8b9137ffef26%2F2%20(1).png?alt=media" alt=""><figcaption><p>RAG 流程</p></figcaption></figure>

## 高精準度的 RAG 系統

{% hint style="info" %}
RAG 知識庫檢索系統雖然能夠快速使用向量搜尋（Vector Search）來實現，並推出基礎版本，但要進一步提升其回覆精準度卻具有挑戰性。回覆精準度對於使用者體驗至關重要，因為它直接影響到使用者對系統回應的信任度與滿意度。如果回覆精準度不足，使用者可能會對系統的答案產生懷疑，從而降低使用意願。
{% endhint %}

根據 2023 OpenAI 開發者大會資料顯示，RAG 系統若僅作單純的向量相似度搜尋（Vector Search）並且選擇正確的內嵌模型（Embedding Model），能夠達到 45%。加上 HyDE Retrieval, FT Embeddings, Chunk/Embedding Experiments 可以達到 65% 的回覆精準度。

MaiAgent RAG 除了包含 OpenAI 開發者大會中所提到的 RAG 技術以外，亦結合各種經典 NLP 演算法與獨家的檢索技術。透過內部資料集與 OpenAI RAG 的回覆正確性相比，兩者皆能達到 95% 的回覆精準度。

<figure><img src="https://527168072-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F38pkhhqHl1oA6yyE9R2n%2Fuploads%2Fgit-blob-6fd9eacb0dfc5dd2c1245505296717d272468f11%2Fimage%20(19).png?alt=media" alt="" width="561"><figcaption><p>MaiAgent RAG 回覆精準度</p></figcaption></figure>

MaiAgent 平台提供兩種 RAG，分別是 MaiAgent RAG 與 OpenAI RAG，以下為各面向的比較表：

|                 | MaiAgent RAG                                                               | OpenAI RAG                                                           |
| --------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| 模型支援度           | 支援所有模型👍                                                                   | 僅支援 OpenAI 模型                                                        |
| 環境支援度           | 支援雲端、地端👍                                                                  | 僅支援雲端，資料需要送至 OpenAI                                                  |
| 回覆精準度           | 超高👍                                                                       | 超高👍                                                                 |
| 支援檔案格式          | 支援所有常見格式👍 doc, docx, xls, xlsx, csv, ppt, pptx, pdf, txt, json, jsonl, md | <p>不支援 xlsx, csv<br>不支援 jsonl<br>不支援舊版 Office 檔案（doc, xlsx, ppt）</p> |
| 支援文件中的圖片        | 有（目前為實驗性功能）👍                                                              | 無                                                                    |
| 支援文件中的表格        | 有（目前為實驗性功能）👍                                                              | 無                                                                    |
| 支援對話中的附件上傳      | 支援👍                                                                       | 支援👍                                                                 |
| 資料切片透明度         | 可視化👍                                                                      | 黑盒子                                                                  |
| Debug 難度        | 一般👍                                                                       | 黑盒子，無法 Debug                                                         |
| Top K 調整        | 企業版客製化功能👍                                                                 | 無                                                                    |
| 切換 Embedding 模型 | 企業版客製化功能👍                                                                 | 無                                                                    |


---

# 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/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.
