next-plaid
A CPU-based Rust implementation of the PLAID algorithm for efficient multi-vector search (late interaction retrieval).
Features
- Pure Rust: No Python or GPU dependencies required
- CPU Optimized: Uses ndarray with rayon for parallel processing
- BLAS Acceleration: Optional Accelerate (macOS) or OpenBLAS backends for 3.6x faster indexing
- Metadata Filtering: Optional SQLite-based metadata storage for filtered search
Installation
[]
= "0.1"
For NPY file support (required for index persistence):
[]
= { = "0.1", = ["npy"] }
BLAS Acceleration (Recommended)
macOS (Apple Accelerate framework):
[]
= { = "0.1", = ["npy", "accelerate"] }
Linux (OpenBLAS):
[]
= { = "0.1", = ["npy", "openblas"] }
Note: OpenBLAS requires the system library (apt install libopenblas-dev on Ubuntu).
Metadata Filtering (Optional)
[]
= { = "0.1", = ["npy", "filtering"] }
Quick Start
Creating an Index
use ;
use Array2;
// Your document embeddings (list of [num_tokens, dim] arrays)
let embeddings: = load_embeddings;
// Create index with automatic centroid computation
let config = default;
let index = create_with_kmeans?;
Searching
use ;
// Load the index
let index = load?;
// Search parameters
let params = SearchParameters ;
// Single query
let query: = get_query_embeddings;
let result = index.search?;
println!;
println!;
Filtered Search with Metadata
use ;
use json;
// Create metadata database
let metadata = vec!;
create?;
// Query metadata to get document subset
let subset = where_condition?;
// Search only within the filtered subset
let result = index.search?;
Performance
SciFact Benchmark (5,183 documents, 1.2M tokens)
| Operation | next-plaid | FastPlaid | Speedup |
|---|---|---|---|
| Index + Update | 12.19s | 19.46s | 1.60x faster |
| Search (300 queries) | 16.38s | 85.85s | 5.2x faster |
| Total | 28.57s | 105.31s | 3.7x faster |
Memory Usage
| Operation | next-plaid | FastPlaid | Savings |
|---|---|---|---|
| Peak | 480 MB | 3,361 MB | 86% less |
Feature Flags
| Feature | Description |
|---|---|
npy |
NPY file support for index persistence |
filtering |
SQLite-based metadata filtering |
accelerate |
macOS Accelerate framework for BLAS |
openblas |
OpenBLAS for BLAS acceleration |
License
Apache-2.0