
Zvec
- 20 installs
- 22 repo stars
- Updated August 1, 2026
- itechmeat/llm-code
Embed the Zvec in-process vector database: collections, HNSW-RaBitQ/DiskANN indexing, embeddings, reranking and persistence.
About
A guide to Zvec, a lightweight in-process vector database ("SQLite for vectors") covering collections, indexing, embedding and reranking pipelines, and persistence. Use it when embedding Zvec into an app or tuning its retrieval and storage behavior.
- Embed checklist: init, create_and_open, insert/upsert Docs, query, and periodic optimize()
- HNSW-RaBitQ for low-memory ANN (x86_64/AVX2 only), DiskANN for billion-scale, hybrid MultiQuery retrieval
Zvec by the numbers
- 20 all-time installs (skills.sh)
- Ranked #555 of 911 Databases skills by installs in the Skillselion catalog
- Data as of Aug 2, 2026 (Skillselion catalog sync)
npx skills add https://github.com/itechmeat/llm-code --skill zvecAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 20 |
|---|---|
| repo stars | ★ 22 |
| Last updated | August 1, 2026 |
| Repository | itechmeat/llm-code ↗ |
What it does
Embed the Zvec in-process vector database: collections, HNSW-RaBitQ/DiskANN indexing, embeddings, reranking and persistence.
Files
Zvec
Zvec is a lightweight, in-process vector database meant to be embedded into applications ("SQLite for vectors").
Quick navigation
- Overview:
references/overview.md - Concepts:
references/concepts.md - Quickstart (first operations):
references/quickstart.md - Installation (only if needed):
references/installation.md - Index types & quantization:
references/indexing.md - Embedding pipelines:
references/embedding.md - Reranking pipelines:
references/reranker.md - Data modeling & collections:
references/collections.md - CRUD / search operations:
references/data-operations.md - Configuration & persistence:
references/configuration.md
Operator recipes (high signal)
- Minimal “embed Zvec” checklist
- (Optional) Configure globals once at startup via
zvec.init(...)(logging,query_threads). - Create a collection on disk with
create_and_open(path=..., schema=..., option=...). - Ingest documents as
Doc(id=..., fields=..., vectors=...)viainsert()orupsert(). - Query via
collection.query(vectors=VectorQuery(...), topk=...). - Call
collection.optimize()periodically after heavy ingestion.
- Bulk ingest + keep query latency stable
- Prefer batched
insert()/upsert(). - Monitor
collection.statsand runoptimize()when flat buffers grow.
- Hybrid retrieval patterns
- Filter-only:
collection.query(filter=..., topk=...). - Vector + filter: pass both
vectors=...andfilter=.... - Multi-vector fusion: pass multiple
VectorQueryitems and rerank usingWeightedReRankeror RRF.
- Memory-sensitive ANN on x86_64
- Prefer
HNSW-RaBitQwhen HNSW-quality recall matters but memory is the limiting factor. - Start with the documented defaults (
total_bits=7,num_clusters=16) and tune query-timeefbefore changing quantization bits.
- Safe evolution of live collections
- Add/drop/alter scalar columns via
add_column(),drop_column(),alter_column(). - Manage indexes via
create_index()/drop_index()(scalar). Vector indexes cannot be dropped.
Critical prohibitions
- Do not mirror vendor docs verbatim; summarize in your own words.
- Do not assume a client/server deployment model: Zvec is in-process.
- Do not add project-specific paths, secrets, or environment assumptions.
- Do not choose
HNSW-RaBitQon unsupported hardware; current docs limit it tox86_64withAVX2or better.
Release Highlights (0.5.0)
- Full-text search (FTS): attach an FTS index to any string field via
create_index()/drop_index()and query it with natural-language or structured expressions, alongside vector indexes. - Hybrid retrieval: the
MultiQueryAPI combines dense vectors, sparse vectors, scalar filters, and text in one query with consistent reranking across Python, Go, Rust, and C++. - DiskANN index: keeps the bulk of the index on disk instead of RAM, cutting memory use for billion-scale datasets on memory-constrained hosts.
- Output field selection:
fetch()accepts anoutput_fieldsparameter to control which fields are returned. - New SDKs and tooling: official Go SDK (cgo, prebuilt Linux/macOS/Windows libs), Rust SDK (RAII, builder APIs), and Zvec Studio (
pip install zvec-studio) for visual data browsing and query testing.
Release Highlights (0.3.0 -> 0.4.0)
- Windows support and official Windows packages for Python and Node.js
- HNSW-RaBitQ quantized vector indexing for lower-memory ANN on supported x86_64 hosts
- Stable C API for building or maintaining additional language bindings
- MCP server / agent skills ecosystem for AI-driven collection management and retrieval workflows
- 0.3.1 hotfixes for relaxed collection path restrictions and better Windows cross-drive/path handling
- 0.4.0 adds official Dart/Flutter bindings, iOS build support, a larger
topKceiling, stricterquery_paramsvalidation, and fixes an SQ8 quantizer recall regression.
Links
- Documentation: https://zvec.org/en/docs/
- GitHub: https://github.com/alibaba/zvec
- Releases: https://github.com/alibaba/zvec/releases
- Issues: https://github.com/alibaba/zvec/issues
Collections
Collections are the primary containers for documents in Zvec (similar to tables). They define the schema (fields + vectors + indexes) and own the on-disk storage.
Create
Use create_and_open() to create a new collection on disk and return a Collection handle.
- If a collection already exists at the path, creation errors (prevents accidental overwrite).
- As of
0.3.1, upstream removed earlier collection path restrictions and fixed Windows cross-drive creation issues.
Schema building blocks
CollectionSchema(name=..., fields=[...], vectors=[...])FieldSchema(name=..., data_type=..., nullable=..., index_param=...)VectorSchema(name=..., data_type=..., dimension=..., index_param=...)
Options
read_onlymust beFalseduring creation.enable_mmapenables memory-mapped I/O (docs indicate defaultTrue).
Python snippets (as shown):
import zvec
collection_option = zvec.CollectionOption(read_only=False, enable_mmap=True)import zvec
collection = zvec.create_and_open(
path="/path/to/my/collection",
schema=collection_schema,
option=collection_option,
)Open
Use open() to load an existing collection directory.
pathmust point to a valid collection directory.- Use
read_only=Truewhen multiple processes access the same collection. - If you previously had Windows-specific workarounds for drive/path behavior, re-test them on
0.3.1; path-related diagnostics also improved.
import zvec
existing_collection = zvec.open(
path="/path/to/my/collection",
option=zvec.CollectionOption(read_only=False, enable_mmap=True),
)Inspect
Helpful for debugging and monitoring:
collection.schema(and.fields,.vectors)collection.statscollection.optioncollection.path
print(collection.schema)
print(collection.schema.fields)
print(collection.schema.vectors)
print(collection.stats)
print(collection.option)
print(collection.path)Optimize
collection.optimize() builds/merges buffered vectors into the configured vector index.
- Newly inserted vectors accumulate in a flat buffer for fast ingestion.
- As the buffer grows, searches get slower.
- Optimization runs without blocking other reads/writes.
collection.optimize()Destroy
Destroying a collection deletes its on-disk directory and all contents (irreversible).
import zvec
collection = zvec.open(path="/path/to/my/collection")
collection.destroy()Schema evolution (DDL)
Zvec supports dynamic schema evolution for scalar fields and indexes.
Limitations mentioned:
- Adding/dropping vector fields is not supported yet.
add_column()currently supports numerical scalar fields only, andexpressionmust evaluate to a number.
Add/drop/alter column:
import zvec
new_field = zvec.FieldSchema(name="rating", data_type=zvec.DataType.INT32)
collection.add_column(field_schema=new_field, expression="5")
collection.drop_column(field_name="publish_year")
collection.alter_column(old_name="publish_year", new_name="release_year")Index management:
import zvec
collection.create_index(
field_name="dense_embedding",
index_param=zvec.FlatIndexParam(metric_type=zvec.MetricType.COSINE),
)
collection.create_index(
field_name="publish_year",
index_param=zvec.InvertIndexParam(),
)
collection.drop_index(field_name="publish_year")Constraint:
- Vector indexes cannot be dropped; every vector field must have exactly one index.
Links
- Section: https://zvec.org/en/docs/collections/
- Create: https://zvec.org/en/docs/collections/create/
- Open: https://zvec.org/en/docs/collections/open/
- Inspect: https://zvec.org/en/docs/collections/inspect/
- Destroy: https://zvec.org/en/docs/collections/destroy/
- Optimize: https://zvec.org/en/docs/collections/optimize/
- Schema evolution: https://zvec.org/en/docs/collections/schema-evolution/
Concepts
Zvec is an in-process vector database: you embed it into your application process, store vectors plus metadata, and query by similarity.
Data model
- Collection: container of documents (roughly a table).
- Document: record with:
id(unique string; immutable after insertion)vectors(named vector fields)fields(named scalar metadata)
Schema rules
- Each collection has a schema describing scalar fields + vector fields, their types, and index parameters.
- All documents must conform to the collection’s schema.
- Schema is dynamic (you can add/remove scalar fields and indexes without recreating the collection).
- No cross-collection queries (no joins/unions/multi-collection search).
Persistence model
- Each collection is persisted in its own directory and is self-contained (directory can be relocated).
Embeddings and vectors
Retrieval loop
1. Generate embeddings for items and store them. 2. Generate the query embedding with the same model/pipeline. 3. Run similarity search to retrieve nearest neighbors.
Metric alignment
Embedding models are typically trained with a particular similarity objective (cosine, dot product/IP, Euclidean/L2). For best relevance, use the same metric in Zvec indexing/querying.
Dense vs sparse
- Dense: fixed-length arrays; strong semantic generalization; less interpretable.
- Sparse: few non-zero dimensions (often term-weight style); more interpretable; weaker semantic generalization unless encoded.
Indexing and filtering
Vector index
- Flat/brute-force search is exact but becomes too slow at scale.
- ANN indexes trade a small amount of accuracy for large speed gains.
- Docs mention index types: Flat, HNSW, IVF.
ANN quality is often measured as $\text{Recall@}k$:
$$ ext{Recall@}k = \frac{\text{# of true nearest neighbors found in top-}k}{k} $$
Inverted index
- Use inverted indexes for scalar fields you filter on frequently (exact match/IN, ranges, membership).
- Trade-offs: extra storage + slower writes due to index maintenance.
Links
- Concepts: https://zvec.org/en/docs/concepts/
- Data modeling: https://zvec.org/en/docs/concepts/data-modeling/
- Vector embedding: https://zvec.org/en/docs/concepts/vector-embedding/
- Vector index: https://zvec.org/en/docs/concepts/vector-index/
- Inverted index: https://zvec.org/en/docs/concepts/inverted-index/
Configuration
Zvec exposes global configuration via an init() call.
Key rule
- Call
init()once at application startup, before creating/opening any collections. - It is not intended for runtime reconfiguration.
- If you do not call
init(), Zvec applies defaults tuned to the environment.
What configuration is for (examples)
- Logging verbosity / output
- Concurrency controls (e.g., query thread count)
Python example
import zvec
zvec.init(
log_type=zvec.LogType.CONSOLE,
log_level=zvec.LogLevel.WARN,
query_threads=4,
)Links
- Docs: https://zvec.org/en/docs/config/
- Python API reference: https://zvec.org/api-reference/python/config/
Data Operations
Zvec provides document-level operations for inserting, updating, deleting, fetching, and querying documents in a collection.
Docs note that writes (insert, upsert, update, delete) become visible to queries immediately (real-time workloads).
Document shape (Doc)
id: unique string identifierfields: scalar metadata (must match schema; nullable fields can be omitted)vectors: named dense/sparse vectors (must match schema type/dimension)
Schema mismatches (unknown field, wrong dimension/type) raise exceptions.
Insert
- Adds new documents.
- Duplicate IDs fail; use upsert to overwrite.
import zvec
result = collection.insert(
[
zvec.Doc(
id="text_1",
vectors={"text_embedding": [0.1, 0.2, 0.3, 0.4]},
fields={"text": "This is a sample text."},
),
zvec.Doc(
id="text_2",
vectors={"text_embedding": [0.4, 0.3, 0.2, 0.1]},
fields={"text": "This is another sample text."},
),
]
)
print(result)Upsert
- Insert-or-replace by
id. - After large upsert batches, run
collection.optimize()to keep search fast.
import zvec
result = collection.upsert(
zvec.Doc(
id="text_1",
vectors={"text_embedding": [0.1, 0.2, 0.3, 0.4]},
fields={"text": "Updated text."},
)
)
print(result)Update
- Updates only the fields/vectors you provide; omitted content remains unchanged.
- IDs must already exist.
import zvec
results = collection.update(
[
zvec.Doc(
id="book_1",
vectors={
"sparse_embedding": {35: 0.25, 237: 0.1, 369: 0.44},
},
fields={
"category": ["Romance", "Classic Literature", "American Civil War"],
},
),
zvec.Doc(
id="book_2",
fields={
"book_title": "The Great Gatsby",
},
),
]
)
print(results)Delete
- Delete by IDs:
delete(ids=...). - Bulk delete by scalar condition:
delete_by_filter(filter=...).
result = collection.delete(ids=["doc_id_2", "doc_id_3"])
print(result)
collection.delete_by_filter(filter="publish_year < 1900")Query
query() supports vector similarity search, scalar filtering, or both.
- Single-vector: pass one
VectorQuery. - Multi-vector: pass a list of
VectorQueryand fuse/rerank. 0.4.0relaxes the upper bound ontopk, which helps larger recall windows; still keep it intentional because downstream reranking and serialization cost scale with result count.0.4.0also tightensquery_paramstype validation. If you were passing loosely typed user input through directly, validate/coerce it before calling into Zvec.
import zvec
result = collection.query(
vectors=zvec.VectorQuery(
field_name="dense_embedding",
vector=[0.1] * 768,
),
filter="publish_year < 1999",
topk=10,
)Multi-vector + weighted reranker example:
import zvec
result = collection.query(
topk=10,
vectors=[
zvec.VectorQuery(field_name="dense_embedding", vector=[0.1] * 768),
zvec.VectorQuery(field_name="sparse_embedding", vector={1: 0.1, 37: 0.43}),
],
reranker=zvec.WeightedReRanker(
topn=3,
metric=zvec.MetricType.IP,
weights={
"dense_embedding": 1.2,
"sparse_embedding": 1.0,
},
),
)
print(result)Hybrid retrieval (MultiQuery, 0.5.0+)
MultiQuery combines dense vectors, sparse vectors, scalar filters, and full-text (FTS) search in a single query with consistent reranking across the Python, Go, Rust, and C++ bindings. Attach an FTS index to a string field via create_index() first, then include a text clause alongside vector clauses. Use it when a single request must blend semantic and keyword relevance.
Fetch
Direct lookup by ID(s); missing IDs are omitted. Pass output_fields (0.5.0+) to control which fields come back.
result = collection.fetch(ids=["book_1", "book_2", "book_3"], output_fields=["title", "author"])
print(result)Links
- Section: https://zvec.org/en/docs/data-operations/
- Insert: https://zvec.org/en/docs/data-operations/insert/
- Upsert: https://zvec.org/en/docs/data-operations/upsert/
- Update: https://zvec.org/en/docs/data-operations/update/
- Delete: https://zvec.org/en/docs/data-operations/delete/
- Query: https://zvec.org/en/docs/data-operations/query/
- Fetch: https://zvec.org/en/docs/data-operations/fetch/
Embedding (AI Extension)
Zvec provides embedding functions to convert text into vectors for similarity search. It ships built-in implementations and supports custom embedding function integrations.
Scope / current limitations
- Current support is text modality only.
Built-in embedding function options
Dense embeddings
- Local dense (
DefaultLocalDenseEmbedding): Sentence Transformers-based. - Uses
all-MiniLM-L6-v2by default (384 dimensions) and downloads the model on first use. - Qwen dense (
QwenDenseEmbedding): Dashscope API (requires API key; dimension must be set explicitly). - OpenAI dense (
OpenAIDenseEmbedding): OpenAI API (requires API key; follow provider limits). - Jina dense (
JinaDenseEmbedding): Jina Embeddings API (requires API key). Supports Jina Embeddings v5. - Docs mention task-specific embeddings and Matryoshka-style dimension reduction support.
Custom HTTP embeddings
- Custom HTTP (
CustomHTTPEmbedding): call any OpenAI-compatible embedding endpoint (LM Studio, Ollama, self-hosted models). Configurebase_url,model, and optionalapi_key.
Sparse embeddings
- Local sparse (
DefaultLocalSparseEmbedding): SPLADE-based, outputs a sparse dictionary. - BM25 (
BM25EmbeddingFunction): local BM25 encoder (no API key). - Built-in encoder option supports at least English/Chinese.
- Custom encoder option can be trained on your corpus and uses BM25 parameters (e.g.,
b,k1). - Qwen sparse (
QwenSparseEmbedding): Dashscope API (requires API key).
Choosing an approach
- Prefer local functions when you want offline/embedded behavior and predictable costs.
- Prefer API-based functions when you want managed model serving and can accept network + quota constraints.
- Consider hybrid retrieval (dense + sparse) when you need stronger relevance across both semantic and lexical signals.
Operational notes
- Model download: local models are downloaded on first use; ensure network access.
- Memory: local models consume RAM; call
clear_cache()to release model memory when appropriate. - Rate limits: API providers can throttle; plan retries/backoff in your app.
- Thread safety: docs state embedding functions are thread-safe.
Extending / custom embedding functions
Docs mention protocol base classes:
DenseEmbeddingFunction[T]SparseEmbeddingFunction[T]
And framework-oriented base classes:
SentenceTransformerFunctionBaseQwenFunctionBase
Links
- Docs: https://zvec.org/en/docs/embedding/
- Python API reference (extension protocols):
- DenseEmbeddingFunction: https://zvec.org/api-reference/python/extension/#zvec.extension.DenseEmbeddingFunction
- SparseEmbeddingFunction: https://zvec.org/api-reference/python/extension/#zvec.extension.SparseEmbeddingFunction
Indexing
Zvec vector indexes control the trade-off between recall, latency, and memory. Choose the vector index per field when you design the collection schema.
Index families
Flat— exact/brute-force search. Best for tiny collections, correctness checks, and low-complexity baselines.HNSW— the general-purpose ANN choice when you want low latency with good recall.HNSW-RaBitQ— new in0.3.0; combines HNSW graph traversal with RaBitQ quantization to reduce memory while keeping strong recall.IVF— another approximate strategy supported by Zvec when you want a different latency/memory profile than HNSW.DiskANN— new in0.5.0; keeps the bulk of the index on disk instead of RAM, drastically cutting memory use for billion-scale datasets on memory-constrained hosts.FTS— new in0.5.0; a full-text index attached to a string field (viacreate_index()), queried with natural-language or structured expressions for hybrid retrieval.
When HNSW-RaBitQ is the right tool
Use HNSW-RaBitQ when all of the following are true:
- You run on
x86_64hardware withAVX2(or better). - HNSW-like recall matters, but the memory footprint of full-precision vectors is too large.
- Your vectors are between
64and4095dimensions.
Avoid it on ARM hosts; the current upstream docs mark it unsupported there.
Practical tuning order
1. Start with the documented defaults: total_bits=7, num_clusters=16. 2. Tune query-time ef first for the recall/latency trade-off. 3. Lower total_bits only when you explicitly need more compression and can accept some recall loss. 4. Increase sample_count only when the training sample quality is the bottleneck for very large datasets.
Main parameters
Index build parameters
metric_type— choose the same distance metric your embeddings were trained for.m— more graph links improve recall but increase memory/build cost.ef_construction— larger build-time candidate pool improves graph quality and slows indexing.total_bits— main memory/accuracy control for RaBitQ.num_clusters— clustering granularity for the quantization training step.sample_count— training sample size (0means use all vectors).
Query parameters
ef— main recall/latency control at query time.radius— optional score threshold for range-style filtering.is_linear— bypass the index for brute-force verification or tiny datasets.is_using_refiner— re-score top candidates with exact distances when precision matters more than latency.
Operator guidance
- Keep one clear reason for each vector index choice; vector indexes cannot be dropped later without redesigning the collection.
- After heavy ingestion, run
collection.optimize()so the configured vector index catches up with buffered writes. - For memory-sensitive production deployments on supported x86_64 servers,
HNSW-RaBitQis the new first thing to evaluate before overprovisioning RAM. 0.4.0fixes an SQ8 quantizer recall regression caused by incorrect int8 rounding metadata handling. Re-benchmark quantized indexes before keeping older compensating thresholds or fallback logic.- Sparse vector indices are now sorted before reaching the core engine, so custom pipelines should not rely on preserving caller-provided sparse-index order as implicit behavior.
Links
- Vector index overview: https://zvec.org/en/docs/db/concepts/vector-index/
- HNSW-RaBitQ: https://zvec.org/en/docs/db/concepts/vector-index/hnsw-rabitq-index/
- Python API params: https://zvec.org/api-reference/python/params/
Installation
This skill assumes Zvec is already installed. Use this page only when you need to set up Zvec in a new environment.
Official prebuilt packages now cover the main desktop/server targets, including Windows support added in 0.3.0 and official Flutter/mobile support in 0.4.0.
Python
- Requirement (as documented in the GitHub README): Python 3.10–3.14
pip install zvecNode.js
npm install @zvec/zvecDart / Flutter
0.4.0 adds an official Flutter package:
flutter pub add zvec- The package ships Dart/Flutter FFI bindings.
- Upstream release notes say Android (
arm64-v8a) and iOS (arm64) prebuilt native libraries are downloaded automatically during the build. - For mobile usage, prefer the official package over maintaining ad-hoc FFI glue.
Supported platforms (official packages)
- Linux (
x86_64,ARM64) - macOS (
ARM64) - Windows (
x86_64) - Android (
arm64-v8a) via Flutter package - iOS (
arm64) via Flutter package
Build from source
If you need an unsupported platform/architecture or want unreleased behavior, use the upstream build guide instead of assuming package availability.
Links
- GitHub README (installation snippets): https://github.com/alibaba/zvec
- Quickstart: https://zvec.org/en/docs/quickstart/
- Build guide: https://zvec.org/en/docs/db/build/
Overview
Zvec is an in-process vector database (library-style), intended to run inside your application process rather than as a separate server.
What Zvec is for
- Similarity search over vectors for semantic search, RAG, and recommendations.
- Embedded / local deployments where a separate vector DB service is undesirable.
- Optionally acting as the “vector search component” alongside an existing system (e.g., SQL DB holding canonical records).
Key capabilities (as described)
- Dense and sparse vectors.
- Hybrid search (vector similarity + structured filters).
- Multi-vector queries (retrieve with multiple embedding signals).
- Designed for low-latency similarity search.
- Official SDKs for Python and Node.js, plus a stable C API for broader language bindings.
- Official package coverage across Linux, macOS, and Windows.
- Official agent-facing integrations via MCP server and agent skills projects.
Next reading
- Quickstart: https://zvec.org/en/docs/quickstart/
- Data modeling: https://zvec.org/en/docs/concepts/data-modeling/
- Indexing & quantization:
indexing.md - Embedding: https://zvec.org/en/docs/embedding/
- Reranker: https://zvec.org/en/docs/reranker/
Ecosystem notes
- The upstream project now publishes an official MCP server for collection management, CRUD, vector search, and embedding-driven workflows.
- The upstream project also maintains official agent skills for LLM-assisted Zvec usage.
- Treat these as adjacent tooling around the embedded database, not as a replacement for understanding the core collection/index model.
Link
- Page: https://zvec.org/en/docs/
Quickstart
This page walks through the minimal workflow: create a collection with a schema, insert documents with vectors + metadata, and query by vector (optionally with filters).
If you still need installation steps, see installation.md.
Minimal workflow (conceptual)
1. Create a collection
- Define a schema with scalar fields + one or more vector fields.
2. Add documents
- Insert/upsert documents containing
id, scalarfields, andvectors.
3. (Optional) Optimize
- Run an optimization step to improve performance (the page shows
collection.optimize()).
4. Retrieve by ID
- Fetch a document directly by its immutable
id.
5. Vector search
- Basic similarity search uses a
query()operation (the docs highlightquery()as the main entry). - Filtered similarity search combines vector search with a filter expression so only matching documents are considered.
6. Inspect
- Print schema and stats (examples shown as
print(collection.schema)andprint(collection.stats)).
7. Delete
- Delete by ID (example:
collection.delete(ids="book_1")). - Delete by filter (example:
collection.delete_by_filter(filter="publish_year < 1900")).
Notes
- If the code examples on the site don’t show up in text extraction (client-rendered), open the page in a browser to copy exact snippets.
Link
- Page: https://zvec.org/en/docs/quickstart/
Reranker (AI Extension)
Reranking is a second-stage step that re-orders retrieved candidates to improve relevance.
When to use
- You want higher precision after a fast ANN retrieval stage.
- You combine multiple retrieval methods (dense + sparse) and need to fuse result lists.
Built-in rerankers mentioned
- DefaultLocalReRanker: local cross-encoder model (
cross-encoder/ms-marco-MiniLM-L6-v2, ~80MB). - QwenReRanker: Dashscope API reranker (requires API key; subject to rate limits).
- RrfReRanker: Reciprocal Rank Fusion for multi-result-list fusion; uses ranks/positions (scores not required).
- WeightedReRanker: weighted fusion for scored multi-result-list retrieval.
Pipeline patterns
- Two-stage retrieval:
1. fast recall (vector search) → 2) rerank top-N for precision
- Multi-vector fusion:
- Use RRF/Weighted when you have multiple retrieval lists (e.g., dense and sparse).
- For single-vector retrieval results, prefer DefaultLocalReRanker or QwenReRanker.
Operational notes
- Local rerankers download models on first use.
- Local models consume memory; call
clear_cache()when appropriate. - API rerankers are constrained by quotas/rate limits.
- Docs state reranking functions are thread-safe.
Extending / custom rerankers
- Custom rerankers inherit from
RerankFunction(exported asReRanker). - Docs mention building on base classes such as
QwenFunctionBase.
Links
- Docs: https://zvec.org/en/docs/reranker/
- Python API reference (ReRanker protocol): https://zvec.org/api-reference/python/extension/#zvec.extension.ReRanker