Home > Technology peripherals > AI > body text

Why is the delayed interaction model standard for the next generation of RAG?

WBOY
Release: 2024-08-05 20:15:22
Original
1011 people have browsed it
Why is the delayed interaction model standard for the next generation of RAG?
The AIxiv column is a column where this site publishes academic and technical content. In the past few years, the AIxiv column of this site has received more than 2,000 reports, covering top laboratories from major universities and companies around the world, effectively promoting academic exchanges and dissemination. If you have excellent work that you want to share, please feel free to contribute or contact us for reporting. Submission email: liyazhou@jiqizhixin.com; zhaoyunfeng@jiqizhixin.com

Zhang Yingfeng: co-founder of Infra, with many years of experience in search, AI, and Infra infrastructure development, he is currently working on the construction of the next generation of RAG core products.

In the development of RAG system, a good Reranker model is an indispensable link and is always used in various evaluations. This is because queries represented by vector search will face low hit rate. Therefore, an advanced Reranker model is needed to remedy the problem, which constitutes a two-stage sorting architecture using vector search as rough screening and Reranker model as fine sorting.

There are currently two main types of architectures for ranking models:

1. Dual encoders. Taking the BERT model as an example, it encodes queries and documents separately, and finally passes through a Pooling layer so that the output contains only one vector. In the Ranking stage of query, you only need to calculate the similarity of two vectors, as shown in the figure below. Dual encoders can be used in both the Ranking and Reranking stages, and vector search is actually this ranking model. Since the dual encoder encodes the query and the document separately, it cannot capture the complex interactive relationship between the query and the document's tokens, which will cause a lot of semantic loss. However, since only vector search is needed to complete the sorting and scoring calculation, the execution efficiency is improved very high.

Why is the delayed interaction model standard for the next generation of RAG?

2. Cross Encoder. Cross-Encoder uses a single encoder model to encode queries and documents simultaneously. It can capture the complex interaction between queries and documents, so it can provide more accurate search ranking results. Cross-Encoder does not output the vector corresponding to the Token of the query and document, but adds a classifier to directly output the similarity score of the query and document. Its disadvantage is that since each document and query need to be jointly encoded at query time, which makes the sorting very slow, Cross-Encoder can only be used to reorder the final results. For example, reordering the Top 10 of the preliminary screening results still takes seconds to complete.

Why is the delayed interaction model standard for the next generation of RAG?

Since this year, another type of work represented by ColBERT [Reference 1] has attracted widespread attention in the RAG development community. As shown in the figure below, it has some characteristics that are significantly different from the above two types of ranking models. :

Firstly, compared to Cross Encoder, ColBERT still uses a dual encoder strategy, encoding the query and the document with independent encoders. Therefore, the query Token and the document Token do not affect each other during encoding. This separation This allows document encoding to be processed offline, and only the Query encoding is used when querying, so the processing speed is much higher than Cross Encoder;

Secondly, compared to dual encoders, ColBERT outputs multiple vectors instead of single vectors. This is because The final output layer of Transformer is obtained directly, while the dual encoder converts multiple vectors into one vector output through a Pooling layer, thus losing some semantics.

During the sorting calculation, ColBERT introduced a delayed interactive calculation similarity function and named it maximum similarity (MaxSim). The calculation method is as follows: for each query Token vector, it must be compared with the vectors corresponding to all document Tokens. Similarity is calculated and the maximum score of each query token is tracked. The total score for the query and document is the sum of these maximum cosine scores. For example, for a query with 32 Token vectors (the maximum query length is 32) and a document with 128 Tokens, 32*128 similarity operations need to be performed, as shown in the figure below.

So in comparison, Cross Encoder can be called Early Interaction Model, while the work represented by ColBERT can be called Late Interaction Model.

Why is the delayed interaction model standard for the next generation of RAG?

次の図は、パフォーマンスと並べ替え品質の観点から上記の並べ替えモデルを比較しています。遅延対話モデルは、並べ替えプロセス中にクエリとドキュメント間の複雑な対話をキャプチャする機能を満たし、ドキュメント トークンのエンコードのオーバーヘッドも回避するため、優れた並べ替え効果を保証できるだけでなく、より高速な並べ替えパフォーマンスも実現できます。同じデータ規模でも、ColBERT の効率は Cross Encoder の 100 倍を超える可能性があります。したがって、遅延相互作用モデルは非常に有望なソート モデルです。自然なアイデアは次のとおりです。 遅延相互作用モデルを RAG で直接使用して、ベクトル検索 + ファイン ソートなどの 2 段階ソート アーキテクチャを置き換えることはできますか?

Why is the delayed interaction model standard for the next generation of RAG?

この目的のために、ColBERT エンジニアリングにおけるいくつかの問題を考慮する必要があります:

1. ColBERT の MaxSim 遅延相互作用類似度関数は、Cross Encoder よりもはるかに高い計算効率を持っていますが、通常のベクトル検索と比較すると、計算オーバーヘッドがまだ非常に大きい: クエリとドキュメント間の類似度は複数ベクトル計算であるため、MaxSim のコストは通常​​のベクトル類似度計算の M * N 倍になります (M はクエリ内のトークンの数、N はトークンの数です)文書内のトークンの数)。これらに応えて、ColBERT の作者は 2021 年に ColBERT v2 をリリースしました [参考 2]。これは、Cross Encoder とモデル蒸留によって生成される Embedding の品質を向上させ、生成されたドキュメント ベクトルを量子化する圧縮技術を使用して、 MaxSim のパフォーマンス。 ColBERT v2 ラッパーに基づくプロジェクト RAGatouille [参考文献 3] は、高品質の RAG ソートのソリューションになります。ただし、ColBERT v2 は単なるアルゴリズム ライブラリであり、エンタープライズ レベルの RAG システムでエンドツーエンドで使用することは依然として困難です。

2. ColBERT は事前トレーニングされたモデルであり、トレーニング データは検索エンジンのクエリから取得され、結果が返されるため、これらのテキスト データは大きくありません。たとえば、クエリ トークンの数は 32、ドキュメント トークンの数は大きくありません。は 128 で、これは一般的な長さの制限です。したがって、ColBERT を実際のデータに使用すると、制限を超える長さは切り捨てられるため、長い文書の検索には適していません。

上記の問題に基づいて、オープンソース AI ネイティブ データベース Infinity は、最新バージョンで Tensor データ型を提供し、エンドツーエンドの ColBERT ソリューションをネイティブに提供します。 Tensor をデータ型として使用すると、ColBERT エンコーディングによって出力された複数のベクトルを 1 つの Tensor に直接格納できるため、Tensor 間の類似性から MaxSim スコアを直接導き出すことができます。 MaxSim の大量の計算の問題に対応して、Infinity は 2 つの最適化ソリューションを提供しました。1 つはバイナリ量子化です。これは、元の Tensor の空間を元のサイズの 1/32 のみにすることができますが、相対的な順序は変更しません。 MaxSim の計算結果。このソリューションは、前段階の粗いスクリーニングの結果に基づいて対応する Tensor を抽出する必要があるため、主に Reranker に使用されます。もう 1 つは Tensor Index です。ColBERTv2 は、実際には ColBERT の作成者によって開始された Tensor Index 実装です。これは、主に量子化とプレフィルタリング技術、および SIMD によって ColBERT v2 を改良したものと見なされます。導入を迅速化するために主要な操作に関する指示が導入されています。 Tensor Index は、Reranker ではなく Ranker にサービスを提供するためにのみ使用できます。さらに、トークン制限を超える長いテキストのために、Infinity は Tensor Array タイプを導入します:

Why is the delayed interaction model standard for the next generation of RAG?

ColBERT 制限を超えるドキュメントは複数の段落に分割され、それぞれ Tensor をエンコードして生成した後、保存されます。オリジナルのドキュメントを 1 行追加します。 MaxSim を計算する場合、クエリとこれらの段落は別々に計算され、その最大値が文書全体のスコアとして採用されます。以下の図に示すように:

Why is the delayed interaction model standard for the next generation of RAG?

したがって、Infinity を使用すると、遅延インタラクション モデルをエンドツーエンドで導入して、高品質の RAG を提供できます。では、ColBERT はランカーまたはリランカーとして使用する必要がありますか?以下では、Infinity を使用して実際のデータセットの評価を実行します。 Infinity の最新バージョンは史上最も包括的なハイブリッド検索ソリューションを実装しているため、リコール方法にはベクトル検索、全文検索、スパース ベクトル検索、上記の Tensor、およびこれらの方法の組み合わせが含まれ、さまざまな Reranker メソッドが提供されます。 、RRF、ColBERT Reranker など、ハイブリッド検索と Reranker のさまざまな組み合わせをレビューに含めます。

評価には MLDR データセットを使用します。 MLDR は、MTEB [参考文献 5] が Embedding モデルの品質を評価するために使用するベンチマーク セットです。MLDR は、Multi Long Document Retrieval と呼ばれるデータ セットの 1 つで、合計 200,000 件の長いテキスト データが含まれています。評価では、埋め込みモデルとして BGE-M3 [参考文献 6]、Tensor の生成に Jina-ColBERT [参考文献 7] を使用し、評価スクリプトも Infinity ウェアハウス [参考文献 8] に配置されます。

評価1:ColBERTはリランカーとして有効か? BGE-M3 を使用して 200,000 の MLDR データから密ベクトルと疎ベクトルを生成し、それらを Infinity データベースに挿入します。データベースには 4 つの列が含まれており、それぞれ元のテキスト、ベクトル、疎ベクトル、テンソルが格納され、対応する完全なベクトルが構築されます。テキストインデックス、スパースベクトルインデックス。評価には、以下に示すように、シングル チャネル リコール、デュアル チャネル リコール、および 3 チャネル リコールを含むすべてのリコールの組み合わせが含まれます:

Why is the delayed interaction model standard for the next generation of RAG?

評価指標は nDCG@10 を使用します。その他のパラメーター: RRF Reranker を使用する場合、粗いスクリーニングによって返される上位 N = 1000、クエリの総数は 800、平均クエリ長は約 10 トークンです。

Why is the delayed interaction model standard for the next generation of RAG?

図からわかるように、ColBERT Reranker を使用した後、すべてのリコール ソリューションの結果が大幅に改善されました。遅延インタラクション モデルである ColBERT は、MTEB の Reranker リーダーボードの上位に匹敵するランキング品質を提供しますが、パフォーマンスは 100 倍であり、より大規模な再ランキングを実行できます。図に示した結果はTop 100 Rerankerに基づいており、Top 1000はColBERTリランキングに使用されますが、値は大きく変化せず、パフォーマンスが大幅に低下するため推奨されません。従来、Cross Encoder に基づく外部リランカーを使用すると、トップ 10 に 2 番目のレベルの遅延が発生します。しかし、Infinity は、トップ 100 またはトップ 1000 が並べ替えられた場合でも、内部的に高性能の ColBERT リランカーを実装します。ユーザーエクスペリエンスには影響しませんが、再現範囲が大幅に増加するため、最終的なランキング効果が大幅に向上します。さらに、この ColBERT Reranker 計算は純粋な CPU アーキテクチャ上でのみ実行する必要があるため、導入コストも大幅に削減されます。

評価 2: 比較は、リランカーではなくランカーとしての ColBERT に基づいています。 したがって、データの Tensor 列の Tensor インデックスを構築する必要があります。同時に、Tensor Index によってもたらされた精度の損失を評価するために、総当たり検索も実行されました。

Why is the delayed interaction model standard for the next generation of RAG?

Reranker と比較すると、精度を損なうことなく総当たり検索を使用しても大きな改善はなく、Tensor Index に基づくソート品質は Reranker を使用する場合よりもさらに低いことがわかります。ただし、ランカーとしてのクエリ時間ははるかに遅くなります。MLDR データ セットには 200,000 のドキュメント データが含まれており、Jina-ColBERT を使用して Tensor データに変換すると、そのサイズは 320G にもなります。データ型はドキュメントです。ドキュメントの各トークンに対応するベクトルを保存する必要があります。ColBERT モデルの次元は 128 次元であるため、Tensor インデックスが構築された場合でも、デフォルトのデータ量は 2 桁増加します。大量のデータをクエリするには平均 7 秒かかりますが、これ以上の結果は得られません。

つまり、ColBERT はランカーとしてよりもリランカーとしての方がはるかに収益性が高いことは明らかです。現在の最良の RAG 検索ソリューションは、3 方向ハイブリッド検索 (全文検索 + ベクトル + スパース ベクトル) と ColBERT Reranker に基づいています。 ColBERT Reranker を使用するには、別の Tensor 列を追加する必要があり、その列は元のデータ セットと比較して 2 桁も拡張されるのですが、それだけの価値があるのか​​と質問するパートナーもいるかもしれません。まず第一に、Infinity は Tensor にバイナリ量子化メソッドを提供します。これは Reranker としてソート結果にはあまり影響しませんが、最終的なデータは元の Tensor の 1/32 にしかならない可能性があります。第二に、たとえそうであっても、このオーバーヘッドが高すぎると考える人もいるでしょう。ただし、ユーザーの観点からすると、より高い並べ替え品質とより低いコストと引き換えに、より多くのストレージを使用することには依然として非常に価値があります (並べ替えプロセスには GPU は必要ありません)。最後に、データ インフラストラクチャとして、パフォーマンスはわずかに低下しますが、ストレージのオーバーヘッドが大幅に削減されたレイト インタラクション モデルが間もなく開始されると考えています。これらの変更は透過的であり、これらのトレードオフをユーザーに引き渡すのが賢明な選択です。

上記は、MLDR データセットでの Infinity の多方向リコール評価に基づいています。他のデータセットでの評価結果は異なる場合がありますが、全体的な結論は変わりません - 3 方向ハイブリッド検索 + Tensor ベースの並べ替え。現在、最高品質の検索結果が得られるリコール方法です。

ColBERT とその遅延インタラクション モデルは RAG シナリオで大きな応用価値があることがわかります。最近では、遅延インタラクション モデルがマルチモーダル シナリオでも使用されています。これは ColPali [参考文献 9] で、以下に示すように RAG ワークフローを変更します。

RAG 複雑な形式のドキュメントに直面した場合、現在の SOTA はドキュメント認識モデルを使用してドキュメントのレイアウトを識別し、図表や写真などの部分構造に対応するモデルを呼び出して変換します。対応するテキストは、RAG サポート データベースにさまざまな形式で保存されます。 ColPali はこれらの手順を省略し、マルチモーダル モデルを直接使用して埋め込みコンテンツを生成します。質問するときは、ドキュメント内のグラフに基づいて直接答えることができます:

Why is the delayed interaction model standard for the next generation of RAG?

ColPali モデルのトレーニングは ColBERT に似ており、クエリとドキュメントのページ ペアの形式を使用してクエリ間のセマンティクスをキャプチャすることもできます。マルチモーダルデータの関連付けを文書化するには、PaliGemma [参考文献 10] を使用してマルチモーダル埋め込みを生成するだけです。 Late Interaction 機構を使用せず、PaliGemma を使用して Embedding を生成する BiPali と比較した場合、nDCG@5 の評価指標の比較は 81.3 対 58.8 であり、この差が「優れている」と「まったく動作しない」の差となります。

Why is the delayed interaction model standard for the next generation of RAG?

したがって、ColBERT が登場してから 4 年が経ちますが、RAG における Late Interaction モデルの適用は間違いなく始まり、マルチモダリティを含む複雑な RAG シナリオを提供します。質の高い意味的想起。 Infinity はすでにエンドツーエンド アプリケーションの準備が整っており、Star Infinity (https://github.com/infiniflow/infinity) に注目してください。最高の AI ネイティブ データベースになるよう取り組んでいます。

参考文献

1. Colbert: bert を介した文脈化された遅延インタラクションによる効率的かつ効果的なパッセージ検索、SIGIR 2020。

2. 軽量な遅延インタラクションによる効果的かつ効率的な検索。 iv :2112.01488、2021。ビットベクトルを使用した効率的なマルチベクトル高密度検索、ECIR 2024。

5. https://huggingface.co/mteb

6. /BAAI/bge-m3

7. https://huggingface.co /jinaai/jina-colbert-v1-en

8. /tree/main/python/benchmark/mldr_benchmark

9. ColPali: ビジョン言語モデルを使用した効率的なドキュメント検索、arXiv:2407.01449、2024.

10. / google-research/big_vision/tree/main/big_vision/configs/proj/paligemma

The above is the detailed content of Why is the delayed interaction model standard for the next generation of RAG?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jiqizhixin.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!