Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

llama-index-vector-stores-qann

A LlamaIndex vector store backed by qann: HNSW, IVF with fast-scan PQ and re-ranking, or exact search, with metadata filters and hybrid (dense + BM25 or SPLADE) search. Node text, metadata and relationships are stored in the qann index, so a store persists to one file.

This is a community integration maintained with qann, not by LlamaIndex.

pip install --pre llama-index-vector-stores-qann

Quick start

from llama_index.core import StorageContext, VectorStoreIndex
from llama_index.vector_stores.qann import QANNVectorStore

store = QANNVectorStore(index="ivf-pq", sparse="bm25")
index = VectorStoreIndex.from_documents(documents, storage_context=StorageContext.from_defaults(vector_store=store))

retriever = index.as_retriever(similarity_top_k=10, vector_store_query_mode="hybrid", alpha=0.6)
nodes = retriever.retrieve("how do bonds work?")

store.persist("store.qann")
store = QANNVectorStore.from_persist_path("store.qann", mmap=True)
index = VectorStoreIndex.from_vector_store(store)

Durable writes

persist() writes the whole index each time. With persist_directory, every add and delete is logged to disk before it returns, and the store reopens from the same directory after a restart or crash:

store = QANNVectorStore(index="hnsw", sparse="bm25", persist_directory="store/")   # opens the store there, or creates it on the first add
index = VectorStoreIndex.from_documents(documents, storage_context=StorageContext.from_defaults(vector_store=store))
store = QANNVectorStore.from_persist_path("store/", mmap=True)                     # also opens a persist_directory

The index is checkpointed as the log grows, and tuned hybrid weights are checkpointed when tune_hybrid_weights returns. Needs qann 0.1.0a33 or later.

Choosing the index

1. Presets. Pass index= by name. The parameters follow qann's configuration guide.

index= What it builds When
"hnsw" (default) HNSWIndex(M=16, ef_construction=200) Adds at any time; low latency.
"ivf-pq" IVF, fast-scan PQ (dim / 2 subspaces), RefineIndex(k_factor=4), nlist = max(100, √n) Least RAM with from_persist_path(..., mmap=True). Trains on the first batch of nodes (at least 1,000), so build it from the whole corpus at once.
"flat" FlatIndex Exact; small corpora.

All presets use cosine distance; metric="l2" or "ip" changes that.

2. Any qann index. Build one with the parameters you want and pass it in, e.g. QANNVectorStore(index=qann.RefineIndex(base, k_factor=8)). store.client is the underlying qann index, for any other setting.

3. Search settings. nprobe, ef_search and k_factor can be set for every query, or per query through the retriever:

store = QANNVectorStore(index="ivf-pq", search_params={"nprobe": 32})
retriever = index.as_retriever(vector_store_kwargs={"nprobe": 64})

sparse="bm25" adds BM25 over the node texts. A custom encoder works too, such as SPLADE: any object with encode_documents(texts) and encode_query(text) that returns scipy.sparse rows with term ids below 2^31. The retriever's query mode picks the side:

vector_store_query_mode Searches
"default" dense side
"sparse" / "text_search" sparse side
"hybrid" both, fused; alpha weights dense against sparse as (alpha, 1 - alpha)
"mmr" dense side, then maximal marginal relevance
  • BM25 keeps up with the corpus. Each query term's IDF comes from the current document counts, so adds and deletes stay exact without re-encoding stored nodes. It is qann.BM25, so the counts are rebuilt from the stored texts in C++ when the store is opened (0.15 s for 58k nodes, about 5 s for 1M).
  • Default weights. Without alpha, hybrid mode uses the store's weights, (1, 1) unless tuned.
  • Tuning. store.tune_hybrid_weights(query_embeddings, query_strs, relevant) picks the weights from labeled queries. relevant holds node ids per query, as a set or {node id: grade}. The weights are saved with the store. Tune on queries you won't evaluate on.
  • Custom encoders on reopen. Pass a custom encoder again when opening the store, like from_persist_path(..., sparse=encoder).

Filters

LlamaIndex MetadataFilters are translated to qann filters and evaluated inside the search. These are supported:

  • ==, !=, >, >=, <, <=, in, nin and is_empty
  • the and, or and not conditions, including nested filter groups

A node without the filtered key matches only !=, nin and is_empty, the same as LlamaIndex's own stores. A test checks 150 random filter combinations against LlamaIndex's SimpleVectorStore.

Not supported, because they need list or substring matching that qann's filter columns don't have: text_match, text_match_insensitive, contains, any and all. These raise NotImplementedError.

Strings and numbers in node metadata become filterable columns; other values are kept on the node but can't be filtered on.

Also supported

  • delete(ref_doc_id) removes all nodes of a source document, which is what index.delete_ref_doc uses. There's also delete_nodes(node_ids, filters), get_nodes(node_ids, filters) and clear(); their filters run in qann like a query's, except text_match and contains, which are checked in Python. Adding an existing node id replaces that node.
  • Queries restricted to node_ids or doc_ids.
  • Similarities where higher is closer: cosine similarity, the inner product, or minus the squared L2 distance; the fused score with hybrid search.
  • Async methods (LlamaIndex's defaults; qann releases the GIL during queries and adds).
  • persist(path) writes one qann file, so StorageContext.persist(persist_dir) writes it as default__vector_store.json. Open it with QANNVectorStore.from_persist_path. Only local paths are supported.

Metadata

Release files for llama-index-vector-stores-qann 0.1.0a3

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

Source distribution (sdist)

Source distribution for llama-index-vector-stores-qann 0.1.0a3
File Size Uploaded Provenance Actions
llama_index_vector_stores_qann-0.1.0a3.tar.gz 14.2 kB With provenance Details for llama_index_vector_stores_qann-0.1.0a3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-vector-stores-qann 0.1.0a3
File Interpreter ABI Platform Actions
llama_index_vector_stores_qann-0.1.0a3-py3-none-any.whl Python 3 none any Details for llama_index_vector_stores_qann-0.1.0a3-py3-none-any.whl

Total release size: 26.5 kB

Release files / llama_index_vector_stores_qann-0.1.0a3.tar.gz

Download URL llama_index_vector_stores_qann-0.1.0a3.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
dd31ee57cf150b32eabf2dc203c610393d9328766d500d3149232feaa6e1512e
BLAKE2b-256 checksum
How to use checksums
da63573d6db82b2bf296390ba7b4c1d6a41953f0152efe4938f9eca1a284cd9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / llama_index_vector_stores_qann-0.1.0a3-py3-none-any.whl

Download URL llama_index_vector_stores_qann-0.1.0a3-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58a48794e6920dd8566960aaedd06cddabadea96af9646721b4c3b04e9687f90
BLAKE2b-256 checksum
How to use checksums
779741992a857bc53516f7a31c29c3fe5345410b348fa1716703de67f0c1064a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for llama-index-vector-stores-qann 0.1.0a3

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for llama_index_vector_stores_qann-0.1.0a3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

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.

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