🕸️

Meta Knowledge for Retrieval Augmented Large Language Models を読んだ

に公開

こんにちは、初めましての方は初めまして。株式会社 Fusicです。最近お腹がめちゃくちゃゆるいせいか、いきなり 2kg ほど痩せました。「2kg も減って大丈夫なのか!?」という心配と「2kg 減って嬉しい!」という喜びがずっと心の中で戦っています(今はまだ嬉しさの方が勝っています)

最近記事がサボりがちになっていたのですが、久しぶりに論文を読んだのでメモを書いておこうと思います。今回この記事で紹介するのは Meta Knowledge for Retrieval Augmented Large Language Models という論文で、AWS が出したものとなります(2024 年の論文なのでちょっと古いかもしれません)GitHub などは公開されていないので、とりあえず記載されている文面から読み取れる内容をこの記事ではまとめています(若干意訳している部分もあるので、内容がおかしい部分があればコメントなどで教えていただけると幸いです)

概要


全体の構成図(論文図1より引用)

一言でまとめると、「ドキュメントに対してメタデータと擬似的な質問応答のペアを作って、メタデータに基づいた要約(Meta Knowledge Summary: MK Summary)を作成してそれを検索対象とすることで回答の精度を向上させる」ものとなります。メタデータを作成して活用することでクエリにより関連した情報を取得しやすく、かつ要約を検索対象とすることでより少ないトークン数に多くの情報を詰め込めることがメリットとなります。


提案手法の結果(論文図2より引用)

結果は上の図のようになっており、これまでの手法と比較してどの観点でも向上していることが分かります。特に Breadth(質問に関連する側面や領域を包括的にとらえ、完璧な概要を提供しているかを評価)や Depth(最終的な回答が、そのテーマの詳細な分析や洞察を通して十分な理解を提供しているかを評価)の観点では従来手法を大きく上回っており、回答の際に考慮する情報を増やすことに成功していることが確認できます。

提案手法

この論文では今までの "retrieve-then-read" というパイプラインではなく "prepare-then-rewrite-then-retrieve-then-read" というパイプラインを新しく採用し、そのための MK Summary という方法を提案しています。

新しくパイプラインに組み込まれている "prepare-then-rewrite" というプロセスについて、これは上の全体の構成図の "Offline Document Preprocessing" と "Metadata-based clusters of documents" の部分にあたります。それぞれを下で詳しく見ていきましょう。

Offline Document Preprocessing

ここでは LLM を用いたメタデータの付与と QA ペアの生成を前処理として行っています。これにより、「ドキュメントには質問のような文は一般的に含まれておらず、ユーザーの質問との類似度を計算する際に関連するドキュメントの検索が難しい」という問題を解決しています。また、メタデータの付与を行うことで検索対象を絞り込むことが出来るので、より関連のある検索結果を返せるようにもなるのだと思います(こちらに関しては特に記述がないのですが、RAG の精度を向上させる Advanced RAG on AWS の道標を拝見するとメタデータによるフィルタリングも有効な解決策であるらしいので、その流れで入れているんじゃないかと思っています)

次にこのパイプラインで使用されているプロンプトを見てみましょう(長いのトグルにしています)

プロンプト(論文 Appendix A より引用)
You are an helpful research assistant, preprocessing { document_types } for { users_types } to use later on.
You are provided with a document and a list of questions that aims at extracting key knowledge from this document. Please stricly follow the format below to answer (no introduction or finishing sentences).

First, answer the following questions with a single Yes or No only:
1. The paper can be clearly categorized into one or multiple research field (s) ( exclusively from : { text_categories }), yes or no ?:
2. The paper is mostly an applied research paper ( versus mostly theoric ), yes or no ?:
3. The paper is referencing a Github repository, yes or no?
4. The paper contains mathematical reasoning, yes or no ?:
5. The paper mentions a specific application to an industry company, yes or no ?:
6. The paper uses evaluations metrics to benchmark their methods, yes or no ?:

Answer the following questions with a python list only, or return an empty python list :
1. If the paper can be clearly categorized into one or multiple research fields, list the fields (3 max):
2. If the paper is mostly an applied research paper, list the application fields (3 max):
3. If the paper references one or more Github repository, list their urls (2 max):
4. If the paper contains mathematical reasoning, list the name (s) of the theorem (s) being used (3 max):
5. If the paper mentioned a specific application to an industry company, list the companies (3 max):
6. If the paper use evaluations metrics to benchmark their methods, list the names of the metrics (5 max):

Your answer must look like the following (no introduction sentence):
1. Yes
2. No
etc.

1. ['a','b']
2. []
etc.

Then , please act as an expert scientists and formulate both general ( general understanding ) and precise questions ( incl. specific findings or limitations ) from the content of the document to assess the knowledge of other highly knowledgeable scientists about the topic of this document.

Scientists that will answer the questions do not know the document. Please do not explicitly refer to "the text" or the name of the document in the questions.
Each questions and answers pairs must be self - contained ( make sure to give enough context ) and independent from other pairs.

Please formulate as many questions as possible covering as much content as possible , and avoid bullet points within answers.

Stricly follow the format of the final questions and answers below, presenting all responses , lists , questions , then all answers:

Questions :
1. ...
2. ...
etc.

Answers :
1. ...
2. ...
etc.

Please find below the text , for which the title is { doc_title }:

[ Text ]
{ doc_content }
[/ Text ]

論文では「Chain-of-Thoughts を使用してガイド付きの QA を生成させた」とあるように、まず初めにそもそもメタデータがあるかどうかの判定をさせて、あるのであればそのメタデータを回答させてから QA の生成をしています。これにより、LLM がメタデータ(=カテゴリ)を踏まえた QA を生成できるようになっています。このようにしてメタデータと QA を生成して、前処理は終わりです。

Metadata-based clusters of documents

ここでは Meta データと作成した QA を活用した検索結果の向上を目的とします。ここらへんの記述が若干曖昧なので、憶測も含んでいることに注意してください。

ここではメタデータと作成した Q(恐らく A は使っていない)に基づいて要約を生成することで MK Summary を作成します。この MK Summary を使用してクエリ拡張を行い、最終的な回答を生成させています。こうすることで「よりユーザーの質問に類似したドキュメントの情報」が取得でき、かつ「関連したカテゴリの情報」が取得出来ているのだと思います。回答生成時にはユーザーの質問、拡張した質問、検索した QA、および Few-shot prompt を用いています。

結果


提案手法の結果(論文図2より引用)

結果のグラフを再掲します。提案手法によって全体的に数値が向上していますが、特に論文で議論されている点を以下にまとめておきます(数値は LLM-as-a-judge によって算出されています)

  • Precision の効果は限定的:どのような検索手法であってもまったく無関係なドキュメントは存在しないため、手法間による差は小さい。
  • Breadth と Depth の大幅な向上:MK Summary によって回答に必要な情報がより多く付与できるため、結果として数値が向上している。

Breadth は特に、普通の検索だと網にかからなかったようなドキュメントも拾えるようになったことによって上がっています。Depth についてもおそらく同じ理由で、LLM が「より詳細な情報捉えてるね!」と判断しているのかなと思います。

まとめ

この記事では MK Summary について紹介しました。文書を(しっかりと情報が含まれるように)コンパクトにまとめることで LLM に渡せる情報が増やせるので、結果として回答が良くなるというのがこの論文から分かるかと思います。特にこの手法は検索時には特別な処理がほとんど必要ないため回答速度を落とすことなく検索性能を大幅に向上できる部分が魅力的です。

一方で、QA の生成部分の良さがかなり精度に影響しそうです。例えば LLM の知識がないようなデータに対してこの手法を適用させた場合は一般的な Q しか生成できないと思うので、ユーザーの質問の分布と乖離するんじゃないかなという気もしています。つまり、検索しても意味のない検索結果しか取得できないんじゃないかなーと(これってどうやって確かめるのがいいですかね…?)

GitHubで編集を提案
Fusic 技術ブログ

Discussion