A benchmarking playground for FAISS vector indexes with hybrid BM25 + vector retrieval
Project description
VectorBench 
A benchmarking playground for FAISS vector indexes. VecBench builds and compares Flat, IVF, HNSW, and PQ indexes on recall@k, latency, and memory, and layers on hybrid BM25 + vector retrieval with metadata filtering. The goal is to expose what's normally hidden inside a vector database — embedding, indexing, and retrieval as separate, inspectable pieces rather than one opaque similarity_search() call.
Introduction
Generally we interact with vector search through a library call in a RAG pipeline, where a vector store handles embedding, indexing, and retrieval invisibly behind an API. VectorBench builds those pieces from scratch (using FAISS's index implementations directly, not reimplementing the algorithms) so one can see and measure exactly what each index type is doing, and where its tradeoffs actually show up.
Project structure
VectorBench/
├── data/ # dataset download, chunking, and embedding scripts
├── indexes/ # wrapper classes around FAISS index types (IVF, HNSW, PQ, ...)
├── retrieval/ # BM25, reciprocal rank fusion, metadata filtering
├── engine.py # VectorSearchEngine — the main user-facing interface
├── benchmark.py # recall@k, latency, and memory measurement harness
└── configs/ # dataset, model, and index parameter configs
engine.py is the entry point most usage goes through. data/, indexes/, and retrieval/ are the building blocks it wires together; benchmark.py drives engine instances repeatedly to produce comparison numbers across index types.
Usage
-
pip install vectorbench
-
(via git)Clone the repository
git clone https://github.com/SitanshuA091/VectorBench cd VecBenchInstall dependencies with uv
uv sync(Optional) Set a local model cache directory in
.envat the project root, so downloaded embedding models are stored inside the project instead of your global HF cacheHF_HOME=./.cache -
Use the engine directly in a script or notebook
from vectorbench.engine import VectorSearchEngine documents = ["your first document", "your second document", "..."] metadatas = [{"source": "notes"}, {"source": "notes"}] engine = VectorSearchEngine(index_type="hnsw") engine.add_documents(documents, metadatas=metadatas) results = engine.search("a query string", k=5, mode="vector") for r in results: print(r["score"], r["text"])
-
Or run it against a real dataset via the data pipeline
from vectorbench.data.download import download_dataset from vectorbench.data.chunk import chunk_dataset from vectorbench.engine import VectorSearchEngine download_dataset(dataset_name="rajpurkar/squad", split="train", output_dir="data/raw/squad") chunk_dataset(input_path="data/raw/squad/raw_data.jsonl", output_path="data/raw/squad/chunked_data.jsonl") engine = VectorSearchEngine(index_type="ivf") # load chunked_data.jsonl, pass documents/metadatas into engine.add_documents(...)
-
Run the benchmark harness to compare index types
from benchmark import BenchmarkRunner engines = {"ivf": ivf_engine, "hnsw": hnsw_engine, "pq": pq_engine} runner = BenchmarkRunner(engines, ground_truth_key="ivf") results = runner.run_all(documents, queries)
Search modes
mode="vector"— pure embedding-based nearest neighbor search through the selected FAISS indexmode="bm25"— pure keyword-based search, no embeddings involvedmode="hybrid"— both run independently, merged via reciprocal rank fusion
Metadata filtering can be layered on top of any mode via the filter argument to engine.search(...).
Notes
- Embedding models are downloaded once via
sentence-transformersand cached locally; subsequent runs load from cache with no network call. - FAISS index classes are used directly (
faiss.IndexIVFFlat,faiss.IndexHNSWFlat,faiss.IndexIVFPQ); this project wraps them with a consistent interface rather than reimplementing the underlying algorithms. - Recall@k benchmarking requires a ground-truth reference index (typically an exact/uncompressed index) to compare approximate results against.
- The
test_exps/directory contains sample evaluation scripts that demonstrate how to benchmark the framework on Hugging Face datasets and analyze performance metrics and results. - Upcoming - proper comparative dashboard
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vectorbench_faiss-0.1.0.tar.gz.
File metadata
- Download URL: vectorbench_faiss-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b53f1c68f6312ec1f3d836b80f8be3d3c9b3c2b811dfeceea857346f2219728
|
|
| MD5 |
207e1e2f7b13cc04a4effa5e96206c3b
|
|
| BLAKE2b-256 |
f06d2936a03cbdf634ce5609d5c1c83993f5936bf21358083f3b675074c4570a
|
File details
Details for the file vectorbench_faiss-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vectorbench_faiss-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29e9b0dddb1741fefbf69868e91fb1cb4c1c60fec73c0f957fffda9b501bd73a
|
|
| MD5 |
e1df5b45cb8a003c9249e9621c099fc0
|
|
| BLAKE2b-256 |
c017dee8c8d30fbc1eb3a4c7932f1b55c0c16422956ed3ec8315199bc17e39b2
|