> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/tech/maiagent-tech-ja/quickstart/rag.md).

# RAG ナレッジベース検索システム

外部のデータベースやナレッジベースを用いて検索を行い、その検索結果を大規模言語モデルと組み合わせることで、より正確で文脈に即した回答を生成します。

RAG 技術の核心は、生成 AI の言語能力とナレッジ検索能力を組み合わせる点にあります。これにより、モデルは質問に回答する際、内部の学習データに依存するだけでなく、外部データベースから最新かつ専門性の高い情報を動的に取得し、それらの情報を生成する回答に反映させることができます。

<figure><img src="/files/ZMVu3I8vS44MG30jJPta" 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="/files/15tF9kdDS8jfwKH2CpFv" alt="" width="561"><figcaption><p>MaiAgent RAG の回答精度</p></figcaption></figure>

MaiAgent プラットフォームでは、MaiAgent RAG と OpenAI RAG の 2 種類の 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
