lancedb study
1.0.0
本博客文章中描述的基準研究代碼。
LancedB是開源,嵌入式和開發人員友好的向量數據庫。下面列出了有關LancedB的一些關鍵功能,這些功能使其非常有價值,以及在其GitHub存儲庫上列出的其他許多關鍵功能。
此存儲庫的目的是通過端到端的基準來證明LancedB的全文和矢量搜索功能,我們在其中仔細研究了查詢結果和吞吐量。
用於此演示的數據集是Kaggle的Wine評論數據集,其中包含〜130K葡萄酒的評論以及其他元數據。數據集將轉換為ZIP存檔,並在此處提供郵政編碼以及郵政編碼。
研究任何工具的性能是一個挑戰,因此為了進行比較,在此存儲庫中提供了Elasticsearch Workflow。 Elasticsearch是一種受歡迎的基於Lucene的全文和矢量搜索引擎,其使用定期用於全文(如今,矢量搜索),因此這使其成為將LanceNCANCE與Lancectb相比的有意義的工具。
通過requirements.txt將依賴項安裝在虛擬環境中。
# Setup the environment for the first time
python -m venv .venv # python -> python 3.11+
# Activate the environment (for subsequent runs)
source .venv/bin/activate
python -m pip install -r requirements.txt筆記
BAAI/bge-small-en-v1.5 )| 案件 | Elasticsearch(QPS) | lancedb(QPS) |
|---|---|---|
| FTS:串行 | 399.8 | 468.9 |
| FTS:並發 | 1539.0 | 528.9 |
| 向量搜索:串行 | 11.9 | 54.0 |
| 向量搜索:並發 | 50.7 | 71.6 |
下面顯示的串行基準涉及在Python中依次運行的查詢。這並不代表生產中現實的用例,但在每種情況下都可以理解基礎搜索引擎的性能(Lucene for Elasticsearch和Tantivy for LanceNCB)。
有關此信息的更多詳細信息將在博客文章中討論。
| 查詢 | Elasticsearch(SEC) | Elasticsearch(QPS) | LancedB(SEC) | lancedb(QPS) |
|---|---|---|---|---|
| 10 | 0.0516 | 193.8 | 0.0518 | 193.0 |
| 100 | 0.2589 | 386.3 | 0.2383 | 419.7 |
| 1000 | 2.5748 | 388.6 | 2.1759 | 459.3 |
| 10000 | 25.0318 | 399.8 | 21.3196 | 468.9 |
| 查詢 | Elasticsearch(SEC) | Elasticsearch(QPS) | LancedB(SEC) | lancedb(QPS) |
|---|---|---|---|---|
| 10 | 0.8087 | 12.4 | 0.2158 | 46.3 |
| 100 | 7.6020 | 13.1 | 1.6803 | 59.5 |
| 1000 | 84.0086 | 11.9 | 16.7948 | 59.5 |
| 10000 | 842.9494 | 11.9 | 185.0582 | 54.0 |
並發基準旨在為LancedB或Elasticsearch複製一個現實的用例 - 在同一時間到達多個查詢,並且DB頂部的REST API必須處理異步請求。
筆記
multiprocessing庫來實現的(較高數量的線程導致性能較慢)。 | 查詢 | Elasticsearch(SEC) | Elasticsearch(QPS) | LancedB(SEC) | lancedb(QPS) |
|---|---|---|---|---|
| 10 | 0.0350 | 285.7 | 0.0284 | 351.4 |
| 100 | 0.1243 | 804.1 | 0.2049 | 487.8 |
| 1000 | 0.6972 | 1434.5 | 1.8980 | 526.8 |
| 10000 | 6.4948 | 1539.0 | 18.9136 | 528.9 |
| 查詢 | Elasticsearch(SEC) | Elasticsearch(QPS) | LancedB,4個線程(SEC) | LancedB,4個線程(QPS) |
|---|---|---|---|---|
| 10 | 0.2896 | 34.5 | 0.1409 | 71.0 |
| 100 | 2.5275 | 39.6 | 1.3367 | 74.8 |
| 1000 | 20.4268 | 48.9 | 13.3158 | 75.1 |
| 10000 | 197.2314 | 50.7 | 139.6330 | 71.6 |