このドキュメントでは、ベクトル取得のための FalconSeek の高度な使用方法について説明します。HNSW や RabitQGraph などのアルゴリズムを選択して、大規模データのコスト効率の高いストレージや極端なパフォーマンス最適化など、特定のニーズに合わせてクエリを高速化する方法を解説します。このガイドでは、アルゴリズムの選択、パラメーター設定、インデックス管理、動的チューニング技術について説明し、効率的なベクトル取得を実装するための完全なコード例を提供します。
背景情報
FalconSeek は、Alibaba Cloud Elasticsearch (ES) の元のインデックス構造を強化し、新しい C++ ベースのベクトルエンジンインデックスを追加します。FalconSeek ベクトルインデックスは Alibaba によって開発され、Taobao、Tmall Search、Recommendation、Pailitao (画像検索) など、Alibaba Group 内の主要なサービスをサポートしています。FalconSeek カーネルに統合されたパフォーマンス専有型ベクトルインデックスを使用して、画像検索やセマンティック検索などの効率的な AI アプリケーションを構築できます。
FalconSeek ベクトルインデックスは、k-近傍法 (k-NN) 検索などのオープンソース ES ベクトルエンジン機能と完全に互換性があります。Alibaba Cloud ES インデックスで FalconSeek を使用するには、インデックス構成で index_options.type を havenask_native に設定します。高度なパラメーター設定の詳細については、以下の詳細な説明をご参照ください。
使用例
基本例
以下の例は、ベクトルデータを保存および取得するためのインデックスを作成する方法を示しています。インデックス名は my_falcon_seek_index です。これには、product_vector という名前の 128 ディメンションのベクトルフィールドが含まれており、HNSW アルゴリズムを使用します。
インデックスの作成
PUT /my_falcon_seek_index { "settings": { "number_of_shards": 1, "number_of_replicas": 0 }, "mappings": { "properties": { "product_vector": { "type": "dense_vector", "dims": 128, "index": true, "similarity": "l2_norm", "index_options": { "type": "havenask_native", "knn_type": "HNSW", "m": 32, "ef_construction": 400 } }, "category": { "type": "keyword" } } } }コアパラメーター
dense_vectorフィールドタイプは、密ベクトルデータを格納するために使用されます。mappingsでこのタイプのフィールドを定義する場合、次のコアプロパティを指定する必要があります:dims:ベクトルのディメンション。similarity:ベクトル間の類似度を計算する関数。index_options:アルゴリズムタイプや関連パラメーターなど、ベクトルインデックスの詳細な設定。
similarity関数は、2 つのベクトル間の類似度を測定するために使用されます。適切な関数を選択することは、取得パフォーマンスにとって重大です。関数
説明
シナリオ
l2_norm
ユークリッド距離。この関数は、多次元空間における 2 つのベクトル間の直線距離を計算します。距離が小さいほど、類似性が高くなります。
画像認識や顔認識などの一般的なシナリオ。
cosine
コサイン類似度。この関数は、2 つのベクトル方向間の角度のコサインを計算します。値が 1 に近いほど、類似性が高くなります。
テキストのセマンティック類似度分析。この関数はベクトルの長さに影響されません。
dot_product
内積。この関数は、2 つのベクトルのドット積を計算します。値が大きいほど、類似性が高くなります。
レコメンデーションシステムなど、ベクトルの大きさを考慮する必要があるシナリオに適しています。
max_inner_productdot_product と同じですが、ベクトルの正規化は不要です。
レコメンデーションシステムなど、ベクトルの大きさを考慮する必要があるシナリオに適しています。
データの書き込み。ベクトルと、プロダクトカテゴリなどのメタデータを含むドキュメントをインデックスに書き込むことができます。
product_vector配列の長さは、dims(128) で定義されたディメンションと同じでなければなりません。POST /my_falcon_seek_index/_doc/1 { "product_vector": [0.12, -0.05, 0.08, 0.24, -0.17, 0.31, 0.02, -0.19, 0.11, 0.28, -0.03, 0.15, 0.22, -0.11, 0.09, 0.33, -0.07, 0.14, 0.26, -0.21, 0.18, 0.29, -0.13, 0.06, 0.35, -0.08, 0.16, 0.23, -0.15, 0.12, 0.27, -0.22, 0.19, 0.32, -0.14, 0.07, 0.25, -0.18, 0.13, 0.30, -0.09, 0.17, 0.24, -0.16, 0.10, 0.34, -0.10, 0.20, 0.31, -0.23, 0.15, 0.28, -0.12, 0.11, 0.26, -0.19, 0.14, 0.29, -0.17, 0.08, 0.22, -0.20, 0.16, 0.27, -0.15, 0.09, 0.25, -0.21, 0.18, 0.30, -0.13, 0.07, 0.24, -0.22, 0.19, 0.32, -0.16, 0.10, 0.26, -0.18, 0.12, 0.28, -0.14, 0.06, 0.23, -0.19, 0.15, 0.29, -0.11, 0.05, 0.21, -0.17, 0.13, 0.27, -0.10, 0.04, 0.20, -0.15, 0.11, 0.25, -0.09, 0.03, 0.19, -0.13, 0.10, 0.24, -0.08, 0.02, 0.18, -0.12, 0.09, 0.23, -0.07, 0.01, 0.17, -0.11, 0.08, 0.22, 0.05, -0.06, 0.09, 0.23, -0.07, 0.01, 0.17, -0.11, 0.08, 0.22], "category": "clothes" } POST /my_falcon_seek_index/_doc/2 {"product_vector":[0.12, -0.05, 0.08, 0.24, -0.17, 0.31, 0.02, -0.19, 0.11, 0.28, -0.03, 0.15, 0.22, -0.11, 0.09, 0.33, -0.07, 0.14, 0.26, -0.21, 0.18, 0.29, -0.13, 0.06, 0.35, -0.08, 0.16, 0.23, -0.15, 0.12, 0.27, -0.22, 0.19, 0.32, -0.14, 0.07, 0.25, -0.18, 0.13, 0.30, -0.09, 0.17, 0.24, -0.16, 0.10, 0.34, -0.10, 0.20, 0.31, -0.23, 0.15, 0.28, -0.12, 0.11, 0.26, -0.19, 0.14, 0.29, -0.17, 0.08, 0.22, -0.20, 0.16, 0.27, -0.15, 0.09, 0.25, -0.21, 0.18, 0.30, -0.13, 0.07, 0.24, -0.22, 0.19, 0.32, -0.16, 0.10, 0.26, -0.18, 0.12, 0.28, -0.14, 0.06, 0.23, -0.19, 0.15, 0.29, -0.11, 0.05, 0.21, -0.17, 0.13, 0.27, -0.10, 0.04, 0.20, -0.15, 0.11, 0.25, -0.09, 0.03, 0.19, -0.13, 0.10, 0.24, -0.08, 0.02, 0.18, -0.12, 0.09, 0.23, -0.07, 0.01, 0.17, -0.11, 0.08, 0.22, 0.05, -0.06, 0.09, 0.23, -0.07, 0.01, 0.17, -0.11, 0.08, 0.22],"category": "clothes"}ベクトル取得 (k-NN)。指定されたクエリベクトルに基づいて、最も類似した 5 つのドキュメントを見つけることができます。
GET /my_falcon_seek_index/_search { "knn": { "field": "product_vector", "query_vector": [0.12, -0.05, 0.01, 0.24, -0.17, 0.31, 0.02, -0.19, 0.11, 0.28, -0.03, 0.15, 0.22, -0.11, 0.09, 0.23, -0.07, 0.14, 0.26, -0.21, 0.18, 0.29, -0.13, 0.06, 0.35, -0.18, 0.16, 0.23, -0.15, 0.12, 0.27, -0.22, 0.19, 0.32, -0.14, 0.87, 0.25, -0.18, 0.13, 0.30, -0.09, 0.17, 0.24, -0.16, 0.10, 0.64, -0.10, 0.20, 0.31, -0.23, 0.15, 0.28, -0.12, 0.11, 0.26, -0.19, 0.14, 0.29, -0.17, 0.08, 0.22, -0.20, 0.16, 0.27, -0.15, 0.09, 0.25, -0.21, 0.18, 0.30, -0.13, 0.07, 0.24, -0.22, 0.19, 0.52, -0.16, 0.10, 0.26, -0.18, 0.12, 0.28, -0.14, 0.06, 0.23, -0.19, 0.14, 0.29, -0.11, 0.05, 0.21, -0.17, 0.13, 0.27, -0.10, 0.04, 0.20, -0.15, 0.11, 0.25, -0.09, 0.03, 0.19, -0.13, 0.10, 0.24, -0.08, 0.02, 0.18, -0.12, 0.09, 0.23, -0.07, 0.01, 0.17, -0.11, 0.08, 0.22, 0.05, -0.06, 0.09, 0.23, -0.07, 0.01, 0.17, -0.11, 0.08, 0.12], "k": 5, "num_candidates": 100 } }コアパラメーター
knnクエリは、k-NN 検索を実行するために使用されます。field:クエリ対象のdense_vectorフィールドの名前。query_vector:クエリに使用するベクトル。そのディメンションはフィールド定義と一致する必要があります。k:返す最も類似した結果の数。num_candidates:アルゴリズムが各シャードで内部的に検索する候補セットのサイズ。この値はkより大きく、通常はkの倍数です。値が大きいほど取得率は向上しますが、クエリレイテンシも増加します。
フィルタリング付き取得。ベクトル取得中に結果をフィルタリングして、より複雑なビジネス要件を満たすことができます。次の例では、「shoes」
categoryで最も類似した 5 つのドキュメントを検索します。GET /my_falcon_seek_index/_search { "knn": { "field": "product_vector", "query_vector": [ 0.12, -0.05, 0.01, 0.24, -0.17, 0.31, 0.02, -0.19, 0.11, 0.28, -0.03, 0.15, 0.22, -0.11, 0.09, 0.23, -0.07, 0.14, 0.26, -0.21, 0.18, 0.29, -0.13, 0.06, 0.35, -0.18, 0.16, 0.23, -0.15, 0.12, 0.27, -0.22, 0.19, 0.32, -0.14, 0.87, 0.25, -0.18, 0.13, 0.30, -0.09, 0.17, 0.24, -0.16, 0.10, 0.64, -0.10, 0.20, 0.31, -0.23, 0.15, 0.28, -0.12, 0.11, 0.26, -0.19, 0.14, 0.29, -0.17, 0.08, 0.22, -0.20, 0.16, 0.27, -0.15, 0.09, 0.25, -0.21, 0.18, 0.30, -0.13, 0.07, 0.24, -0.22, 0.19, 0.52, -0.16, 0.10, 0.26, -0.18, 0.12, 0.28, -0.14, 0.06, 0.23, -0.19, 0.14, 0.29, -0.11, 0.05, 0.21, -0.17, 0.13, 0.27, -0.10, 0.04, 0.20, -0.15, 0.11, 0.25, -0.09, 0.03, 0.19, -0.13, 0.10, 0.24, -0.08, 0.02, 0.18, -0.12, 0.09, 0.23, -0.07, 0.01, 0.17, -0.11, 0.08, 0.22, 0.05, -0.06, 0.09, 0.23, -0.07, 0.01, 0.17, -0.11, 0.08, 0.12 ], "k": 5, "num_candidates": 100, "filter": { "term": { "category": "shoes" } } } }
拡張機能:tags_filter によるフィルタリング付き取得
tags_filter パラメーターは、HNSW および QGraph アルゴリズムに最適化された事前フィルタリングメカニズムを提供します。グラフ探索プロセスの早い段階で一致しないノードを除外するため、標準の bool filter よりも高いパフォーマンスを提供します。
シナリオ:この機能は、フィルタリングフィールドが一意の値の数が限られている場合 (カテゴリやブランド ID など) で、高いクエリパフォーマンスが要求される場合に使用できます。
この機能を有効にする方法:
mappingsのindex_optionsで、tagsパラメーターを使用してフィルタリングに使用するkeywordタイプフィールドを宣言できます。PUT /my_vector_index_with_tags { "mappings": { "properties": { "product_vector": { "type": "dense_vector", "dims": 128, "index_options": { "type": "havenask_native", "knn_type": "HNSW", "tags": ["category"] // tags_filter のために category フィールドを宣言 } }, "category": { "type": "keyword" // keyword タイプである必要があります } } } }knnクエリでは、tags_filterパラメーターを"field_name = value"構文で使用できます。このパラメーターは|(OR) および&(AND) ロジックをサポートします。GET /my_vector_index_with_tags/_search { "knn": { "field": "product_vector", "query_vector": [...], "k": 5, "tags_filter": "category = shoes | category = socks" } }
アルゴリズムの選択とパフォーマンスガイド
適切な knn_type アルゴリズムを選択することは、パフォーマンス、コスト、精度の最適なバランスを達成するために重大です。
アルゴリズムの比較と推奨事項
アルゴリズム | 取得率 | クエリ速度 | メモリ使用量 | シナリオと推奨事項 | 主な制限事項 |
HNSW | 高 | 速い | 中 | 汎用的な第一選択肢。 ほとんどのシナリオに適しており、取得率、パフォーマンス、リソース消費の最適なバランスを提供します。10 万から 1,000 万のドキュメントのデータセットで良好なパフォーマンスを発揮します。 | 特別な制限はありません。 |
RabitQGraph | 高 | 最速 | 最低 | 極端なパフォーマンスとコスト重視のシナリオ向け。 ミリ秒レベルのクエリレイテンシを必要とする、またはメモリコストに非常に敏感なデータセット、特に非常に大規模なデータセット (1,000 万ドキュメント以上) に適しています。 |
|
QGraph | 高 | 速い | 低 | 大規模でストレージコスト重視のシナリオ向け。 ベクトル量子化により、メモリとストレージの使用量を大幅に削減します。500 万ドキュメント以上のデータセットに適しています。 | 特別な制限はありません。 |
QC | 中 | 中 | 低 | 大規模でメモリに制約のあるシナリオ向け。構築時間は重要ではないが、実行時のメモリリソースが非常に厳しい場合に検討してください。100 万ドキュメント以上のデータセットに適しています。 | 構築時間が長くなります。 |
Linear | 最高 (100%) | 遅い | 低 | 小規模なデータセットや絶対的な精度が必要なシナリオ向け。 ドキュメントの総数が | 小規模なデータセットにのみ適しています。 |
シナリオベースの選択パス
始めたばかりの場合や、どのアルゴリズムを使用すればよいかわからない場合は、
HNSWを選択してください。データ量が増加し、パフォーマンスが低下した場合:
十分なメモリがあり、より高い QPS (秒間クエリ数) を達成したい場合は、`RabitQGraph` の要件を満たしていれば、
HNSWからRabitQGraphに移行できます。メモリまたはストレージのコストが懸念される場合は、
HNSWからQGraphに移行し、quantizerを構成できます。
1,000 万ドキュメントを超える非常に大規模なデータセットの場合:
非常に高いレイテンシ要件がある場合は、
RabitQGraphを選択してください。コストに敏感で、レイテンシ要件がわずかに低い場合は、
QGraphを選択してください。
インデックス管理 (マッピング)
インデックスを作成する際、すべてのベクトル関連の構成は mappings の index_options ブロック内で設定されます。
PUT /<your_index_name>
{
"mappings": {
"properties": {
"<your_vector_field>": {
"type": "dense_vector",
"dims": 768,
"similarity": "l2_norm",
"index_options": {
// --- 共通パラメーター ---
"type": "havenask_native",
"knn_type": "HNSW",
// --- アルゴリズム構築パラメーター ---
"m": 32,
"ef_construction": 400,
// --- 高度なパラメーター ---
"thread_count": 8
}
}
}
}
}共通パラメーター
パラメーター | 説明 | タイプ | 必須 | デフォルト |
| FalconSeek ベクトルインデックスエンジンを指定します。 | String | はい | なし |
| ベクトルインデックスアルゴリズムを指定します。オプションは | String | いいえ |
|
アルゴリズム構築パラメーター
以下のパラメーターはインデックス構築中に効果を発揮し、インデックスの構造と品質を決定します。
HNSW および QGraph の共通パラメーター
パラメーター | 説明 | タイプ | デフォルト | 推奨値と影響 |
| グラフ内の各ノードの最大近傍数。 | Integer |
| 影響:取得率とメモリ使用量に直接影響します。 |
| グラフ構築中の候補セット検索の幅。 | Integer |
| 影響:インデックス構築の品質と時間を決定します。 |
QGraph 固有のパラメーター
パラメーター | 説明 | タイプ | デフォルト | 推奨値と影響 |
| ベクトル量子化メソッド。ベクトルを圧縮してメモリとストレージの使用量を削減するために使用されます。 | String | なし | 影響:リソース使用量を大幅に削減しますが、わずかな精度低下を引き起こす可能性があります。 |
高度なパラメーター
パラメーター | 説明 | タイプ | デフォルト | 推奨値と影響 |
| インデックス構築中に使用される並列スレッドの数。 | Integer |
| 影響:構築プロセスを高速化します。 |
|
| Array |
| 影響:パフォーマンス専有型事前フィルタリングを有効にします。 |
| インデックス内のドキュメントの総数がこのしきい値を下回る場合、システムは自動的に | Integer |
| 影響:小規模データセットに対して複雑なインデックス構造を構築するのを回避します。 |
| 基盤となるエンジンのパラメーターのための構成インターフェイスで、高度なチューニングに使用されます。 | Object |
| 影響:構築およびクエリプロセスのあらゆる詳細を詳細にコントロールできます。 |
index_params パラメーターは、基盤となる proxima.* および param.* パラメーターへの直接アクセスを提供します。たとえば、トップレベルの m パラメーターは、基盤となる proxima.hnsw.builder.max_neighbor_count に対応します。この構成は、トップレベルのパラメーターで公開されていない詳細を調整する必要がある場合にのみ使用してください。
json
"index_options": { "knn_type": "HNSW", "m": 32, // これは以下の index_params によって上書きされます "index_params": { "proxima.hnsw.builder.max_neighbor_count": 48 // 最終的な有効値は 48 です }}knn クエリ本文
パラメーター | 説明 | タイプ | 必須 |
| k-NN 検索を実行する | String | はい |
| クエリに使用するベクトル。 | Array | はい |
| 返す最も類似した結果の数。 | Integer | はい |
| 各シャードの検索候補セットのサイズ。値を大きくすると取得率が向上しますが、クエリが遅くなります。 | Integer | いいえ (推奨) |
| (オプション) | String | いいえ |
| (オプション) 一時的なチューニングのために、クエリ時に一部の検索パラメーターを動的に調整します。 | Object | いいえ |
パラメーターの説明
HNSW
階層的ナビゲーラブルスモールワールド (HNSW) アルゴリズムのパラメーターは、proxima.hnsw. 名前空間を使用し、index_params を使用して設定できます。
HNSW Builder
パラメーター名 | タイプ | デフォルト | 説明 |
proxima.hnsw.builder.max_neighbor_count | uint32 | 100 | グラフ内の近傍の数。値を大きくするとグラフの精度が向上しますが、計算とストレージのオーバーヘッドが増加します。通常、特徴のディメンションを超えるべきではありません。最大値は 65535 です。 |
proxima.hnsw.builder.efconstruction | uint32 | 500 | グラフ構築の精度をコントロールします。値が大きいほど、より正確なグラフになりますが、構築に時間がかかります。 |
proxima.hnsw.builder.thread_count | uint32 | 0 | 構築中に使用するスレッドの数。0 に設定すると、CPU コアの数を使用します。 |
proxima.hnsw.builder.memory_quota | uint64 | 0 | 構築のための最大メモリを制限します。ディスクベースの構築は現在サポートされていません。この値を超えると、構築は失敗します。 |
proxima.hnsw.builder.scaling_factor | uint32 | 50 | グラフのレイヤー間のノードの比率。通常、変更する必要はありません。有効値は [5,1000] です。 |
proxima.hnsw.builder.neighbor_prune_ratio | float | 0.5 | 近傍テーブルでエッジの枝刈りを開始する近傍の数をコントロールします。通常、変更する必要はありません。 |
proxima.hnsw.builder.upper_neighbor_ratio | float | 0.5 | レイヤー 0 グラフに対するグラフの上位レイヤーの近傍の比率。通常、変更する必要はありません。 |
proxima.hnsw.builder.enable_adsampling | bool | false | デフォルトでは無効です。現在、fp32 データセットのユークリッド距離計算のみをサポートしています。256 未満のディメンションには推奨されません。 |
proxima.hnsw.builder.slack_pruning_factor | float | 1.0 | デフォルトは 1.0 です。[1.1, 1.2] の間が推奨されます。gist960 と sift128 の場合、1.1 が推奨されます。 |
HNSW Searcher
パラメーター名 | タイプ | デフォルト | 説明 |
proxima.hnsw.searcher.ef | uint32 | 500 | 取得精度をコントロールするために使用されます。値が大きいほど、より多くのドキュメントをスキャンし、取得率が向上します。 |
proxima.hnsw.searcher.max_scan_ratio | float | 0.1 | 取得中にスキャンするドキュメントの最大比率をコントロールします。ef 値が早期に収束した場合、この比率に達しないことがあります。 |
proxima.hnsw.searcher.neighbors_in_memory_enable | bool | false | 有効にすると、近傍テーブルをメモリ内に保持し、パフォーマンスが向上しますが、より多くのメモリを消費します。 |
proxima.hnsw.searcher.check_crc_enable | bool | false | インデックスの巡回冗長検査 (CRC) を実行するかどうかを指定します。これを有効にすると、ロード時間が増加します。 |
proxima.hnsw.searcher.visit_bloomfilter_enable | bool | false | 訪問済みグラフノードの重複排除コンテナーとしてブルームフィルターを使用します。これによりメモリが最適化されますが、パフォーマンスはわずかに低下します。 |
proxima.hnsw.searcher.visit_bloomfilter_negative_prob | float | 0.001 | ブルームフィルターの精度。値が小さいほど精度が高くなりますが、より多くのメモリを使用します。 |
proxima.hnsw.searcher.brute_force_threshold | int | 1000 | ドキュメントの総数がこの値未満の場合、線形探索が実行されます。 |
HNSW 構成例
// 基本的な HNSW 設定
PUT /hnsw_basic
{
"mappings": {
"properties": {
"vector": {
"type": "dense_vector",
"dims": 768,
"index": true,
"similarity": "cosine",
"index_options": {
"type": "havenask_native",
"knn_type": "HNSW"
}
}
}
}
}
// 高性能な HNSW 設定
PUT /hnsw_performance
{
"mappings": {
"properties": {
"vector": {
"type": "dense_vector",
"dims": 1024,
"index": true,
"similarity": "dot_product",
"index_options": {
"type": "havenask_native",
"knn_type": "HNSW",
"m": 48,
"ef_construction": 500,
"thread_count": 8,
"linear_build_threshold": 1000,
"is_embedding_saved": true,
"embedding_load_strategy": "ANN_INDEX_FILE",
"index_load_strategy": "MEM"
}
}
}
}
}
RabitQGraph
RabitQGraph Builder
パラメーター名 | タイプ | デフォルト | 説明 |
param.rabitQGraph.builder.neighbor_cnt | uint32 | 128 | 各ノードの近傍数で、グラフの接続性と検索精度に影響します。 |
param.rabitQGraph.builder.ef_construction | uint32 | 512 | 構築用の EF パラメーターで、構築中の候補ノードの数をコントロールします。 |
param.rabitQGraph.builder.prune_ratio | float | 0.5 | 近傍の枝刈り比率で、グラフ構造を最適化するために使用されます。 |
param.rabitQGraph.builder.cluster_count | uint32 | 64 | クラスターの重心の数で、ベクトル量子化に使用されます。 |
param.rabitQGraph.builder.quantized_bit_count | uint32 | 1 | 量子化のためのビット数。1、4、5、8、または 9 にのみ設定できます。 |
param.rabitQGraph.builder.slack_prune_factor | float | 1.0 | スラック枝刈り係数で、枝刈りポリシーをコントロールするために使用されます。 |
param.rabitQGraph.builder.repair_connectivity | bool | true | グラフの接続性を修復するかどうかを指定します。 |
param.rabitQGraph.builder.thread_count | uint32 | 0 | 構築中に使用するスレッドの数。0 に設定すると、CPU コアの数を使用します。 |
param.rabitQGraph.builder.ckpt_count | uint32 | 0 | チェックポイントの数で、増分ビルドに使用されます。 |
param.rabitQGraph.builder.ckpt_threshold | uint32 | 2000000 | チェックポイントのしきい値。 |
RabitQGraph Searcher
パラメーター名 | タイプ | デフォルト | 説明 |
param.rabitQGraph.searcher.ef | uint32 | 250 | 検索用の EF パラメーターで、検索精度とパフォーマンスに影響します。 |
param.rabitQGraph.searcher.max_scan_ratio | double | 0.05 | 最大スキャン比率で、検索するノードの割合を制限します。 |
param.rabitQGraph.searcher.check_crc_enable | bool | false | CRC チェックを有効にするかどうかを指定します。 |
param.rabitQGraph.searcher.thread_count | uint32 | 1 | 検索に使用するスレッドの数。 |
param.rabitQGraph.searcher.thread_safe_filter | bool | false | スレッドセーフなフィルタリングを有効にするかどうかを指定します。 |
RabitQGraph 構成例
// 高性能設定
{
"index_params": {
"param.rabitQGraph.builder.neighbor_cnt": 256,
"param.rabitQGraph.builder.ef_construction": 512,
"param.rabitQGraph.builder.quantized_bit_count": 8,
"param.rabitQGraph.builder.cluster_count": 128,
"param.rabitQGraph.builder.thread_count": 8,
"param.rabitQGraph.searcher.ef": 300,
"param.rabitQGraph.searcher.max_scan_ratio": 0.1
}
}
// メモリ最適化設定
{
"index_params": {
"param.rabitQGraph.builder.neighbor_cnt": 64,
"param.rabitQGraph.builder.ef_construction": 200,
"param.rabitQGraph.builder.quantized_bit_count": 1,
"param.rabitQGraph.builder.cluster_count": 32,
"param.rabitQGraph.searcher.ef": 150,
"param.rabitQGraph.searcher.max_scan_ratio": 0.03
}
}
// バランスの取れた設定
{
"index_params": {
"param.rabitQGraph.builder.neighbor_cnt": 128,
"param.rabitQGraph.builder.ef_construction": 400,
"param.rabitQGraph.builder.quantized_bit_count": 4,
"param.rabitQGraph.builder.cluster_count": 64,
"param.rabitQGraph.searcher.ef": 250
}
}
Linear
Linear アルゴリズムは線形の力まかせ探索を実行します。そのパラメーターは比較的単純で、proxima.linear. 名前空間を使用します。
Linear Builder/Searcher
パラメーター名 | タイプ | デフォルト | 説明 |
proxima.linear.builder.column_major_order | string | false | 構築中に特徴を row-major (false) または column-major (true) の順序で使用するかどうかを指定します。 |
proxima.linear.searcher.read_block_size | uint32 | 1048576 | 検索フェーズで一度にメモリに読み込むブロックのサイズ。推奨値は 1 MB です。 |
Linear 構成例
// 基本設定
{
"index_params": {
"proxima.linear.builder.column_major_order": "false",
"proxima.linear.searcher.read_block_size": 1048576
}
}
// 大容量メモリ設定
{
"index_params": {
"proxima.linear.builder.column_major_order": "true",
"proxima.linear.searcher.read_block_size": 2097152
}
}
QC
QC (量子化クラスタリング) アルゴリズムは、量子化クラスタリングインデックスを使用します。そのパラメーターは proxima.qc. 名前空間を使用します。
QC Builder
パラメーター名 | タイプ | デフォルト | 説明 |
proxima.qc.builder.train_sample_count | uint32 | 0 | トレーニングデータの量を指定します。0 の場合、すべてのデータが使用されます。 |
proxima.qc.builder.thread_count | uint32 | 0 | 構築中に使用するスレッドの数。0 に設定すると、CPU コアの数を使用します。 |
proxima.qc.builder.centroid_count | string | - | クラスター重心パラメーター。階層的クラスタリングをサポートします。レイヤーは「*」で区切ります。 |
proxima.qc.builder.cluster_class | string | OptKmeansCluster | クラスタリングメソッドを指定します。 |
proxima.qc.builder.cluster_auto_tuning | bool | false | セントロイド数の自動チューニングを有効にするかどうかを指定します。 |
proxima.qc.builder.optimizer_class | string | HcBuilder | 重心部分のオプティマイザーで、分類中の精度を向上させるために使用されます。 |
proxima.qc.builder.optimizer_params | IndexParams | - | 最適化メソッドに対応する構築および取得パラメーター。 |
proxima.qc.builder.converter_class | string | - | メジャーが InnerProduct の場合、Mips 変換が自動的に実行されます。 |
proxima.qc.builder.converter_params | IndexParams | - | converter_class の初期化パラメーター。 |
proxima.qc.builder.quantizer_class | string | - | 量子化器を構成します。オプションには Int8QuantizerConverter、Int4QuantizerConverter などがあります。 |
proxima.qc.builder.quantizer_params | IndexParams | - | 量子化器に関連するパラメーター。 |
proxima.qc.builder.quantize_by_centroid | bool | false | quantizer_class を使用する際に、セントロイドによって量子化するかどうかを指定します。 |
proxima.qc.builder.store_original_features | bool | false | 元の特徴を保存するかどうかを指定します。 |
QC Searcher
パラメーター名 | タイプ | デフォルト | 説明 |
proxima.qc.searcher.scan_ratio | float | 0.01 | max_scan_num を計算するために使用されます:ドキュメント総数 * scan_ratio。 |
proxima.qc.searcher.optimizer_params | IndexParams | - | 構築中に使用されたオプティマイザーに対応するオンライン取得パラメーターを指定します。 |
proxima.qc.searcher.brute_force_threshold | int | 1000 | ドキュメントの総数がこの値未満の場合、線形探索が実行されます。 |
QC 構成例
// 基本設定
{
"index_params": {
"proxima.qc.builder.thread_count": 4,
"proxima.qc.builder.centroid_count": "1000",
"proxima.qc.builder.cluster_class": "OptKmeansCluster",
"proxima.qc.searcher.scan_ratio": 0.02
}
}
// 階層的クラスタリング設定
{
"index_params": {
"proxima.qc.builder.thread_count": 8,
"proxima.qc.builder.centroid_count": "100*100",
"proxima.qc.builder.optimizer_class": "HnswBuilder",
"proxima.qc.builder.quantizer_class": "Int8QuantizerConverter",
"proxima.qc.searcher.scan_ratio": 0.01
}
}
// 高精度設定
{
"index_params": {
"proxima.qc.builder.thread_count": 12,
"proxima.qc.builder.centroid_count": "2000",
"proxima.qc.builder.train_sample_count": 100000,
"proxima.qc.builder.store_original_features": true,
"proxima.qc.searcher.scan_ratio": 0.05
}
}
QGraph
QGraph (量子化グラフ) アルゴリズムは、量子化グラフインデックスを使用します。HNSW のほとんどのパラメーターを継承し、量子化関連のパラメーターを追加します。
QGraph Builder
QGraph はすべての HNSW Builder パラメーターを継承し、以下を追加します:
パラメーター名 | タイプ | デフォルト | 説明 |
proxima.qgraph.builder.quantizer_class | string | - | 量子化器を設定します。オプションには Int8QuantizerConverter、Int4QuantizerConverter、HalfFloatConverter、DoubleBitConverter が含まれます。 |
proxima.qgraph.builder.quantizer_params | IndexParams | - | 量子化器に関連するパラメーターを設定します。 |
すべての proxima.hnsw.builder.* パラメーターも QGraph に適用されます。
QGraph Searcher
QGraph はすべての HNSW サーチャーパラメーターを継承します。
QGraph 構成例
// Int8 量子化設定
{
"index_params": {
"proxima.hnsw.builder.max_neighbor_count": 32,
"proxima.hnsw.builder.efconstruction": 400,
"proxima.hnsw.builder.thread_count": 4,
"proxima.qgraph.builder.quantizer_class": "Int8QuantizerConverter",
"proxima.qgraph.builder.quantizer_params": {},
"proxima.hnsw.searcher.ef": 300
}
}
// Int4 量子化設定 (よりメモリ効率が良い)
{
"index_params": {
"proxima.hnsw.builder.max_neighbor_count": 48,
"proxima.hnsw.builder.efconstruction": 500,
"proxima.hnsw.builder.thread_count": 6,
"proxima.qgraph.builder.quantizer_class": "Int4QuantizerConverter",
"proxima.qgraph.builder.quantizer_params": {},
"proxima.hnsw.searcher.ef": 400,
"proxima.hnsw.searcher.max_scan_ratio": 0.1
}
}
// HalfFloat 量子化設定 (高精度)
{
"index_params": {
"proxima.hnsw.builder.max_neighbor_count": 64,
"proxima.hnsw.builder.efconstruction": 600,
"proxima.hnsw.builder.thread_count": 8,
"proxima.qgraph.builder.quantizer_class": "HalfFloatConverter",
"proxima.qgraph.builder.quantizer_params": {},
"proxima.hnsw.searcher.ef": 500
}
}
search_params による動的パラメーター調整
インデックスを再構築することなく、特定の検索パラメーターを一時的に調整して、さまざまなシナリオで取得率とクエリレイテンシーのバランスを取ることができます。
たとえば、通常のオンラインクエリでは、デフォルトまたはより低い ef 値を使用して低レイテンシを確保できます。バッチ分析や高精度を必要とするタスクでは、search_params を使用して ef 値を一時的に増加させ、より高い取得率を得ることができます。
HNSW
{
"search_params": {
"proxima.hnsw.searcher.ef": "400",
"proxima.hnsw.searcher.max_scan_ratio": "0.15"
}
}
QGraph
{
"search_params": {
"proxima.hnsw.searcher.ef": "400",
"proxima.hnsw.searcher.max_scan_ratio": "0.15"
}
}
QC
{
"search_params": {
"proxima.qc.searcher.scan_ratio": "0.02"
}
}
RabitQGraph
{
"search_params": {
"param.rabitQGraph.searcher.ef": "300",
"param.rabitQGraph.searcher.max_scan_ratio": "0.08"
}
}
search_params 構成例
// HNSW の精度とパフォーマンスを動的に調整
GET vector_index/_search
{
"knn": {
"field": "vector",
"query_vector": [0.1, 0.2, 0.3],
"k": 10,
"num_candidates": 100,
"search_params": {
"proxima.hnsw.searcher.ef": "500",
"proxima.hnsw.searcher.max_scan_ratio": "0.2"
}
}
}
// QC のスキャン比率を動的に調整
GET vector_index/_search
{
"knn": {
"field": "vector",
"query_vector": [0.1, 0.2, 0.3],
"k": 10,
"num_candidates": 100,
"search_params": {
"proxima.qc.searcher.scan_ratio": "0.05"
}
}
}
// RabitQGraph の検索精度を動的に調整
GET vector_index/_search
{
"knn": {
"field": "vector",
"query_vector": [0.1, 0.2, 0.3],
"k": 10,
"num_candidates": 100,
"search_params": {
"param.rabitQGraph.searcher.ef": "400",
"param.rabitQGraph.searcher.max_scan_ratio": "0.1"
}
}
}
linear_build_threshold
このパラメーターはオプションの整数です。デフォルト値は 0 です。ドキュメント数がこのしきい値未満の場合、複雑なインデックスを構築する代わりに線形検索が実行されます。
// 線形しきい値を無効にする
{
"linear_build_threshold": 0
}
// 小規模データセットに線形検索を使用する
{
"linear_build_threshold": 1000
}
// より大きな閾値、ステージング環境に適しています
{
"linear_build_threshold": 5000
}
付録:完全な例
HNSW
// 基本的な HNSW 設定
PUT /hnsw_basic
{
"mappings": {
"properties": {
"vector": {
"type": "dense_vector",
"dims": 768,
"index": true,
"similarity": "cosine",
"index_options": {
"type": "havenask_native",
"knn_type": "HNSW"
}
}
}
}
}
// 高性能な HNSW 設定
PUT /hnsw_performance
{
"mappings": {
"properties": {
"vector": {
"type": "dense_vector",
"dims": 1024,
"index": true,
"similarity": "dot_product",
"index_options": {
"type": "havenask_native",
"knn_type": "HNSW",
"m": 48,
"ef_construction": 500,
"thread_count": 8,
"linear_build_threshold": 1000,
"is_embedding_saved": true,
"embedding_load_strategy": "ANN_INDEX_FILE",
"index_load_strategy": "MEM"
}
}
}
}
}
Linear
// 基本的な Linear 設定
PUT /linear_basic
{
"mappings": {
"properties": {
"vector": {
"type": "dense_vector",
"dims": 384,
"index": true,
"similarity": "l2_norm",
"index_options": {
"type": "havenask_native",
"knn_type": "Linear"
}
}
}
}
}
QC
// 基本的な QC 設定
PUT /qc_basic
{
"mappings": {
"properties": {
"vector": {
"type": "dense_vector",
"dims": 768,
"index": true,
"similarity": "cosine",
"index_options": {
"type": "havenask_native",
"knn_type": "QC"
}
}
}
}
}
// カスタム QC 設定
PUT /qc_custom
{
"mappings": {
"properties": {
"vector": {
"type": "dense_vector",
"dims": 1024,
"index": true,
"similarity": "dot_product",
"index_options": {
"type": "havenask_native",
"knn_type": "QC",
"thread_count": 8,
"linear_build_threshold": 5000,
"index_params": "{\"proxima.qc.builder.thread_count\": 8, \"proxima.qc.builder.centroid_count\": \"2000\"}"
}
}
}
}
}
QGraph
// 基本的な QGraph 設定
PUT /qgraph_basic
{
"mappings": {
"properties": {
"vector": {
"type": "dense_vector",
"dims": 768,
"index": true,
"similarity": "cosine",
"index_options": {
"type": "havenask_native",
"knn_type": "QGraph",
"quantizer": "int8"
}
}
}
}
}
// 高精度 QGraph 設定
PUT /qgraph_high_precision
{
"mappings": {
"properties": {
"vector": {
"type": "dense_vector",
"dims": 1536,
"index": true,
"similarity": "cosine",
"index_options": {
"type": "havenask_native",
"knn_type": "QGraph",
"m": 40,
"ef_construction": 600,
"thread_count": 8,
"quantizer": "fp16",
"is_embedding_saved": true,
"index_load_strategy": "MEM"
}
}
}
}
}
// メモリ最適化 QGraph 設定
PUT /qgraph_memory_optimized
{
"mappings": {
"properties": {
"vector": {
"type": "dense_vector",
"dims": 1024,
"index": true,
"similarity": "l2_norm",
"index_options": {
"type": "havenask_native",
"knn_type": "QGraph",
"m": 24,
"ef_construction": 300,
"thread_count": 6,
"quantizer": "int4",
"is_embedding_saved": false,
"index_load_strategy": "BUFFER"
}
}
}
}
}
RabitQGraph
// 基本的な RabitQGraph 構成 (l2_norm 類似度のみをサポート)
PUT /rabitqgraph_basic
{
"mappings": {
"properties": {
"vector": {
"type": "dense_vector",
"dims": 64,
"index": true,
"similarity": "l2_norm",
"index_options": {
"type": "havenask_native",
"knn_type": "RabitQGraph"
}
}
}
}
}
// パフォーマンス専有型 RabitQGraph 構成 - Map 形式で index_params を使用
PUT /rabitqgraph_performance
{
"mappings": {
"properties": {
"vector": {
"type": "dense_vector",
"dims": 128,
"index": true,
"similarity": "l2_norm",
"index_options": {
"type": "havenask_native",
"knn_type": "RabitQGraph",
"thread_count": 8,
"index_params": {
"param.rabitQGraph.builder.neighbor_cnt": 256,
"param.rabitQGraph.builder.ef_construction": 512,
"param.rabitQGraph.builder.quantized_bit_count": 4,
"param.rabitQGraph.builder.cluster_count": 128,
"param.rabitQGraph.searcher.ef": 300
}
}
}
}
}
}
// メモリ最適化 RabitQGraph 構成
PUT /rabitqgraph_memory_optimized
{
"mappings": {
"properties": {
"vector": {
"type": "dense_vector",
"dims": 192,
"index": true,
"similarity": "l2_norm",
"index_options": {
"type": "havenask_native",
"knn_type": "RabitQGraph",
"thread_count": 4,
"linear_build_threshold": 1000,
"index_params": {
"param.rabitQGraph.builder.neighbor_cnt": 64,
"param.rabitQGraph.builder.ef_construction": 200,
"param.rabitQGraph.builder.quantized_bit_count": 1,
"param.rabitQGraph.builder.cluster_count": 32,
"param.rabitQGraph.searcher.ef": 150,
"param.rabitQGraph.searcher.max_scan_ratio": 0.05
}
}
}
}
}
}
// タグフィルタリング付き RabitQGraph 構成
PUT /rabitqgraph_with_tags
{
"mappings": {
"properties": {
"vector": {
"type": "dense_vector",
"dims": 256,
"index": true,
"similarity": "l2_norm",
"index_options": {
"type": "havenask_native",
"knn_type": "RabitQGraph",
"tags": ["category", "region"],
"index_params": {
"param.rabitQGraph.builder.neighbor_cnt": 128,
"param.rabitQGraph.builder.ef_construction": 400,
"param.rabitQGraph.builder.quantized_bit_count": 8,
"param.rabitQGraph.searcher.ef": 250
}
}
},
"category": {
"type": "keyword"
},
"region": {
"type": "keyword"
}
}
}
}