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)

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. The counts are rebuilt from the stored texts when the store is opened (about 2 s for 58k nodes).
  • 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(). 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.0a1

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.0a1
File Size Uploaded Provenance Actions
llama_index_vector_stores_qann-0.1.0a1.tar.gz 14.1 kB With provenance Details for llama_index_vector_stores_qann-0.1.0a1.tar.gz

Built distribution (wheel)

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

Total release size: 26.7 kB

Release files / llama_index_vector_stores_qann-0.1.0a1.tar.gz

Download URL llama_index_vector_stores_qann-0.1.0a1.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d1529e170e8e8f44ce05f0b227547fe71c190511bbc76edeaa18db0bbb4ba04e
BLAKE2b-256 checksum
How to use checksums
3cb5e5a62e8650b95c1ff67c3d06a9e8ee688d0bd6bfa39e0b09421117556e1d
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 12, 2026.

Transparency log

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

Download URL llama_index_vector_stores_qann-0.1.0a1-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f2bc5c80c06841d0e9374b46e259cf0569b2a03f6179b1765ef752262f9259d
BLAKE2b-256 checksum
How to use checksums
759c3713de25d2e68bce86790fac6a17ec2dc6ac6bfe5333435370ede99912c7
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 12, 2026.

Transparency log

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

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.0a1.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 12, 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