AISAQCompatible with Milvus 2.6.4+

AISAQ 是基於磁碟的向量索引,可擴充DISKANN,以最小的 DRAM 足跡處理十億級資料集。

DISKANN 將壓縮向量保存在記憶體中,而 AISAQ 則不同,它採用「近零 DRAM 架構」設計,也就是將所有資料結構保存在 SSD 上。

AISAQ 可以使用標準伺服器執行超高規模資料庫,同時提供操作模式以平衡效能與儲存成本。

AISAQ 如何運作

上圖比較了DISKANNAISAQ-PerformanceAISAQ-Scale 的儲存佈局,顯示資料 (原始向量、邊緣列表和 PQ 代碼) 在 RAM 和磁碟之間的分配方式。

Aisaq Vs Diskann Aisaq Vs Diskann

基礎:DISKANN 回顧

在 DISKANN 中,原始向量和邊緣清單儲存在磁碟上,而 PQ 壓縮向量則儲存在記憶體 (DRAM)。

當 DISKANN 遍歷到一個節點 (例如向量 0):

  • 它會從磁碟載入原始向量(raw_vector_0) 及其邊緣清單(edgelist_0)。

  • 邊緣清單指出下一個要造訪的鄰居 (本範例中的節點 2、3 和 5)。

  • 原始向量用來計算與查詢向量的精確距離,以進行排序。

  • 記憶體中的 PQ 資料用於近似距離篩選,以引導下一次遍歷。

由於 PQ 資料已經快取在 DRAM 中,因此每次節點造訪只需要一次磁碟 I/O,以適度的記憶體使用量達到高查詢速度。

有關這些元件和參數的詳細說明,請參閱DISKANN

AISAQ 操作模式

AISAQ 提供兩種運作模式,以因應兩種不同的使用情況:

效能模式:針對需要低延遲和高吞吐量的應用程式進行最佳化,例如線上語意搜尋。

規模模式:針對延遲限制較寬鬆的應用程式進行最佳化,例如 RAG 與離線語意搜尋,同時能以符合成本效益的方式將資料集擴充至超高規模。

AISAQ-performance 模式

AISAQ-performance透過將 PQ 資料從記憶體移至磁碟,達到「近零 DRAM 足跡」,同時透過資料託管與備援維持低 IOPS。

  • 每個節點的原始向量、邊緣列表及其鄰居的 PQ 資料都一起儲存在磁碟上。

  • 此佈局可確保訪問一個節點 (例如向量 0) 仍只需要單次磁碟 I/O。

  • 由於 PQ 資料在多個節點附近被重複儲存,索引檔案的大小會大幅增加,消耗更多的磁碟空間。

AISAQ-scale 模式

AISAQ-scale著重於減少磁碟空間使用量,同時滿足目標應用程式的效能需求。

在此模式中

  • PQ 資料會單獨儲存在磁碟上,沒有備援。

  • 此設計可最小化索引大小,但會導致圖形遍歷過程中產生更多 I/O 作業。

  • 為了減少 IOPS 開銷,AISAQ 引進了兩種最佳化方法:

    • 重新排列演算法,可依優先順序排序 PQ 向量,以改善資料位置性。

    • DRAM 中的 PQ 快取記憶體 (pq_read_page_cache_size),可快取經常存取的 PQ 資料。

配置範例

# milvus.yaml
knowhere:
  AISAQ:
    build:
      max_degree: 56 # Controls the maximum number of connections (edges) each data point can have in the Vamana graph
      search_list_size: 100 # During index construction, this parameter defines the size of the candidate pool used when searching for the nearest neighbors for each node. For every node being added to the graph, the algorithm maintains a list of the search_list_size best candidates found so far. The search for neighbors stops when this list can no longer be improved. From this final candidate pool, the top max_degree nodes are selected to form the final edges
      inline_pq: -1 # Number of PQ vectors stored inline per Index node (read when node is accessed, to reduce IO)
      rearrange: true # Re-arrange the PQ vectors data structure to improve data locality and reduce disk accesses during search (ignored in performance mode)
      num_entry_points: 100 # Number of candidate entry points to optimize search entry-point selection
      pq_code_budget_gb_ratio: 0.125 # Controls the size of the PQ codes (compressed representations of data points) compared to the size of the uncompressed data
      disk_pq_code_budget_gb_ratio: 0.25 # Controls the size of the PQ codes of the high precision vectors stored in the index (used for re-ranking), compared to the size of the uncompressed data
      pq_cache_size: 0 # PQ vectors cache size in DRAM (bytes). The PQ vectors cache is loaded during Index load and used during search to reduce IOs (ignored in performance mode)
      search_cache_budget_gb_ratio: 0 # Controls the amount of DRAM to be used for caching frequently accessed index nodes. This cache is loaded during index load and used during search to reduce IOs
    search:
      search_list: 16 # During a search operation, this parameter determines the size of the candidate pool that the algorithm maintains as it traverses the graph. A larger value increases the chances of finding the true nearest neighbors (higher recall) but also increases search latency
      beamwidth: 8 # Controls the degree of parallelism during search by determining the maximum number of parallel disk I/O requests to read the index nodes
      vectors_beamwidth: 1 # Controls the degree of parallelism during search by determining the maximum number of parallel disk I/O requests to read groups of neighboring PQ vectors (ignored in performance mode)
      pq_read_page_cache_size: 5242880 (5MiB) # PQ read cache size in DRAM per search thread (bytes). It caches frequently accessed data pages containing PQ vectors (ignored in performance mode and applicable only when rearrange is true). The PQ read cache memory is reused across all AISAQ segments

AISAQ 參數

AISAQ 繼承了 DISKANN 的一些參數 -max_degree,search_list_size, 和pq_code_budget_gb_ratio

索引建立參數

這些參數會影響 AISAQ 索引的建立方式。調整這些參數會影響索引大小、建立時間和搜尋品質。

參數

說明

值範圍

調整建議

max_degree

控制每個資料點在 Vamana 圖形中的最大連線(邊)數。

類型:整數

範圍:[1, 512]

預設值56

較高的值會建立較密集的圖形,可能會增加召回率 (找到更多相關結果),但也會增加記憶體使用量和建立時間。在大多數情況下,我們建議您設定此範圍內的值:[10, 100].

search_list_size

在索引建構期間,此參數會定義為每個節點搜尋最近鄰居時所使用的候選池大小。對於新增到圖表中的每個節點,演算法會維護一個 search_list_size 最佳候選人清單。當這份清單無法再改善時,鄰居搜尋就會停止。從這個最終候選人資料庫中,選出最高 max_degree 節點來組成最終邊。

類型:整數

範圍:[1, 512]

預設值100

較大的 search_list_size 會增加找到每個節點的真正最近鄰居的可能性,這可能會導致更高品質的圖、以及更好的搜尋效能 (回復率)。不過,這也是以大幅延長索引建立時間為代價。它應該永遠設定為大於或等於 max_degree 的值。

inline_pq

每個索引節點內嵌儲存的 PQ 向量數量 (在存取節點時讀取,以減少 IO)

類型:整數

範圍:[0,max_degree]

預設值-1

inline_pq 的值越高,效能越好,但會增加磁碟空間。

設定inline_pq=0 為 AISAQ 的比例模式。

設定inline_pq=-1 可自動以 PQ向量填滿索引中未使用的空間,以進一步優化比例模式下的 AISAQ。

設定inline_pq=max_degree適用於效能模式下的 AISAQ。

inline_pq 設定值在 0 到max_degree之間,可以調整效能與磁碟空間消耗之間的平衡。

rearrange

重新排列 PQ 向量資料結構,以改善資料位置並減少搜尋時的磁碟存取 (在效能模式中忽略)。

類型:布林

範圍:[真、假]

預設值true

為真時,會減少搜尋期間的 IO,但只會稍微增加記憶體和索引建立時間。

num_entry_points

候選入口點數量,以最佳化搜尋入口點選擇。

類型:整數

範圍:[0, 1000]

預設值100

高值可從較近的入口點開始搜尋,減少搜尋時間。

對於較大的區段,請設定較高的值(例如,對於 10M 以上的向量,請使用 1000 的值)。

pq_code_budget_gb_ratio

控制 PQ 碼(資料點的壓縮表示)相對於未壓縮資料的大小。

類型:浮點數

範圍: (0.0, 0.25)

預設值0.125

比率越高,搜尋結果越精確,可有效儲存更多原始向量的資訊,但會增加搜尋時的計算複雜度。

在大多數情況下,我們建議您在此範圍內設定值:(0.0417, 0.25]。

disk_pq_code_budget_gb_ratio

控制索引中儲存的高精度向量的 PQ 碼大小(用於重新排序),與未壓縮資料的大小相比。

類型:浮點數

範圍:[0, 0.25]

預設值0.25

預設值為 0.25 時,向量將量化為原始大小的 25%(4 倍壓縮),減少磁碟佔用空間,但對精確度的影響相對較小。

設定值為 0 時,會在磁碟索引中儲存完整精確度向量,以便重新排序。值越大,召回率越高,但會增加磁碟使用量。

pq_cache_size

以 DRAM 為單位的 PQ 向量快取大小 (位元組)。PQ 向量快取記憶體在索引載入時載入,並在搜尋時使用,以減少 IO (在效能模式中忽略)。

類型:整數

範圍:[0, 1073741824]

預設值0

較大的快取記憶體可改善查詢效能,但會增加 DRAM 使用量。

search_cache_budget_gb_ratio

控制用於快取頻繁存取的索引節點的 DRAM 容量。

此快取記憶體在索引載入時載入,並在搜尋時使用,以減少 IO。

類型:浮點數

範圍:[0.0, 0.3)

預設值0

較高的值會分配更多記憶體用於快取,減少磁碟 IO,但會消耗更多的系統記憶體。較低的值會使用較少的快取記憶體,可能會增加磁碟存取的需求。

索引搜尋參數

這些參數會影響 AISAQ 執行搜尋的方式。調整這些參數會影響搜尋速度、延遲和資源使用。

參數

說明

值範圍

調整建議

search_list

在搜尋作業中,此參數會決定演算法在遍歷圖時所維護的候選池大小。值越大,找到真正最近鄰居的機會越大 (召回率越高),但也會增加搜尋延遲。

類型:整數

範圍:[topk,int32_max]。

預設值16

為了在效能與精確度之間取得良好平衡,建議設定此值等於或稍大於您想要擷取的結果數量 (top_k)。

beamwidth

透過決定讀取索引節點的最大平行磁碟 I/O 請求數目,控制搜尋期間的平行程度。

類型:整數

範圍:[1, 16]

預設值8

較高的值會增加並行性,這可以在具有強大 CPU 和 SSD 的系統上加快搜尋速度。但是,設定太高可能會導致過度的資源爭用。

在大多數情況下,我們建議您設定值為 2。

vectors_beamwidth

控制搜尋期間的平行程度,方法是決定讀取相鄰 PQ向量群組的最大平行磁碟 I/O 請求數目 (在效能模式中忽略)。

類型:整數

範圍:[1, 4] 必須 <=beamwidth

預設值1

較高的值會增加平行性,這可以在擁有強大 CPU 和 SSD 的系統上加快搜尋速度。但是,設定太高可能會導致過度的資源爭用,因為每個鄰近的 PQ 向量群可能最多包含 max_degree 向量。

在大多數情況下,我們建議您設定值為 1。

pq_read_page_cache_size

每個搜尋線程以 DRAM 為單位的 PQ 讀取快取大小 (位元組)。它會快取包含 PQ 向量的頻繁存取資料頁 (在效能模式中會被忽略,僅在 rearrange 為 true 時適用)。

PQ 讀取快取記憶體在所有 AISAQ 區段中重複使用。

類型:整數

範圍:[0, 33554432]

預設值5242880 (5MiB)

較大的快取記憶體可改善查詢效能,但會增加 DRAM 使用量。

建議值範圍:小區段 (1 M向量) 為 2 MiB,中區段 (50 M向量) 為 5 MiB,大區段 (250 M向量) 為 10 MiB。

免費嘗試托管的 Milvus

Zilliz Cloud 無縫接入,由 Milvus 提供動力,速度提升 10 倍。

開始使用
反饋

這個頁面有幫助嗎?