Skip to main content

VectorBench-FAISS

A benchmarking and experimentation framework for FAISS vector search.

VectorBench-FAISS lets you build and compare vector search systems using recall@k, latency, and memory, with support for vector, BM25, hybrid retrieval, and metadata filtering.

The goal is to make the components of vector search inspectable and measurable rather than hiding everything behind a single similarity_search() call.

Features

  • FAISS vector search — IVF, HNSW, and PQ indexes
  • BM25 retrieval — keyword-based search without embeddings
  • Hybrid retrieval — vector + BM25 with Reciprocal Rank Fusion
  • Metadata filtering — filter results using document metadata
  • Benchmarking — recall@k, latency, and memory measurements
  • Dataset utilities — dataset downloading, chunking, and embedding preparation
  • Consistent interface — experiment with different index types through the same search API

Installation

Install the latest release from PyPI:

pip install vectorbench_faiss

Then import the main search engine:

from vectorbench_faiss.engine import VectorSearchEngine

Quick Start

from vectorbench_faiss.engine import VectorSearchEngine

documents = [
    "Python is a programming language.",
    "FAISS is a library for efficient similarity search.",
    "Vector databases are commonly used in RAG systems.",
]

metadatas = [
    {"source": "python"},
    {"source": "faiss"},
    {"source": "rag"},
]

engine = VectorSearchEngine(index_type="hnsw")

engine.add_documents(
    documents,
    metadatas=metadatas
)

results = engine.search(
    "What is FAISS?",
    k=5,
    mode="vector"
)

for result in results:
    print(result["score"], result["text"])

Search Modes

Embedding-based nearest-neighbor retrieval using the selected FAISS index.

results = engine.search(
    "What is vector search?",
    k=5,
    mode="vector"
)

Keyword-based retrieval without embeddings.

results = engine.search(
    "vector search",
    k=5,
    mode="bm25"
)

Combines vector and BM25 retrieval using Reciprocal Rank Fusion (RRF).

results = engine.search(
    "What is vector search?",
    k=5,
    mode="hybrid"
)

Metadata Filtering

Attach metadata to documents and filter results during retrieval:

results = engine.search(
    "search algorithms",
    k=5,
    mode="vector",
    filter={"topic": "vector-search"}
)

Metadata filtering can be used with vector, BM25, and hybrid search.


Benchmarking

Compare multiple search engines using BenchmarkRunner:

from vectorbench_faiss.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
)

Benchmarks measure:

  • Recall@k — retrieval quality
  • Latency — search performance
  • Memory — index memory usage

A reference index can be used as ground truth when evaluating approximate indexes.


Dataset Utilities

VectorBench includes utilities for preparing datasets from Hugging Face for experiments:

from vectorbench_faiss.data.download import download_dataset
from vectorbench_faiss.data.chunk import chunk_dataset

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",
)

The resulting documents and metadata can then be passed to VectorSearchEngine.


Embeddings

VectorBench uses sentence-transformers for generating embeddings. Models are cached locally after the first download, allowing subsequent runs to load them from the local cache.


Example Workflow

Dataset
   ↓
Chunking
   ↓
Embeddings
   ↓
FAISS Index
   ↓
Vector / BM25 / Hybrid Retrieval
   ↓
Benchmark
   ↓
Recall · Latency · Memory

VectorBench is designed primarily for learning, experimentation, and benchmarking of vector retrieval systems.


Requirements

VectorBench uses libraries including:

  • FAISS
  • sentence-transformers
  • BM25 retrieval

Dependencies are installed automatically when installing the package through PyPI.


Project Status

VectorBench-FAISS is currently focused on vector retrieval experimentation and benchmarking.

Upcoming: comparative dashboard for visualizing benchmark results across datasets, index types, and configurations.


Source code: https://github.com/SitanshuA091/VectorBench

Metadata

Release files for vectorbench-faiss 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vectorbench-faiss 0.1.1
File Size Uploaded Provenance
vectorbench_faiss-0.1.1.tar.gz 6.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for vectorbench-faiss 0.1.1
File Interpreter ABI Platform
vectorbench_faiss-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.8 kB

Release files / vectorbench_faiss-0.1.1.tar.gz

Download URL vectorbench_faiss-0.1.1.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
39621ccf1b5cd769d7a6651c91bc759d1f5bbccc2b75dc1ecf1defda22ed4fd6
BLAKE2b-256 checksum
How to use checksums
3135f71f63adf9c80ed2a4c74723766725a65db50363a1813f2c7f3470b8dacc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.14

Release files / vectorbench_faiss-0.1.1-py3-none-any.whl

Download URL vectorbench_faiss-0.1.1-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c907f3d8f02f7c59ceede5295500c8e5e003937392668b097555deef1ad22b15
BLAKE2b-256 checksum
How to use checksums
f3c3c3249889078170c00884dcf28c7aa57fc47d62fa609de2f82a9bc9b0480f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.14

Security for vectorbench-faiss 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page