Dense vector index
In modern big data and AI workloads, vector data is widely used for high-dimensional features such as images, text, and audio. Vector data often has these characteristics:
- High dimensionality: Each vector can have hundreds to thousands of dimensions.
- Sparsity: Many vectors are mostly zeros (sparse vectors).
- Similarity queries: Applications often need approximate nearest neighbor search (ANNS).
To handle this vector data efficiently, pyseekdb exposes HNSW (Hierarchical Navigable Small World) index settings (HNSWConfiguration) to speed up similarity search.
This topic documents HNSW parameters in detail. For how to use HNSW end to end, see create_collection - Create a collection.
Use cases
Vector indexes fit scenarios such as:
- Recommendation systems: Match users or items using vector similarity.
- Image retrieval: Find similar images quickly via feature vectors.
- Semantic text search: Match meaning using word or sentence vectors.
- Bioinformatics: Work with high-dimensional vectors for genes or proteins.
- Anomaly detection: Spot unusual patterns via vector similarity.
Field reference
HNSWConfiguration configures a dense vector index (HNSW). Fields:
| Field | Type | Default | Description and constraints |
|---|---|---|---|
| dimension | int | 384 | Vector dimension, 1–4096 |
| distance | str | "cosine" | Distance metric: l2, cosine, inner_product |
| type | str | "hnsw" | Index type: hnsw, hnsw_sq, hnsw_bq |
| lib | str | "vsag" | Implementation library: vsag |
| M | int | 16 | Max connections, 5–128 |
| ef_construction | int | 200 | Build-time search range, 5–1000 |
| ef_search | int | 64 | Query-time search range, 1–1000 |
| extra_info_max_size | int | 0 | Max extra info size, 0–16384 |
| refine_k | float | 4.0 | Refine search parameter, 1.0–1000.0 |
| refine_type | str | "sq8" | Refine type: sq8, fp32 |
| bq_bits_query | int | 32 | Quantized query bits: 0, 4, or 32 |
| bq_use_fht | bool | true | Whether to use FHT |
| properties | dict | None | Other primitive key/value pairs; reserved keys are ignored with a warning |
VectorIndexConfig combines HNSW with an embedding function:
hnsw:HNSWConfigurationorNone(default HNSW).embedding_function:EmbeddingFunction; if omitted,DefaultEmbeddingFunction()is used.
Usage
To use a dense vector index in pyseekdb, configure it through Schema when you create a collection. If you do not set any schema fields, the collection defaults to an HNSW dense vector index.
Prerequisites
Install pyseekdb V1.2.0 or later.
pip install -U pyseekdb
Usage example
from pyseekdb import Client, HNSWConfiguration, Configuration
client = Client(host="127.0.0.1", port=2881, database="test")
config = Configuration(hnsw=HNSWConfiguration(dimension=384, distance="cosine"))
collection = client.create_collection("my_collection", configuration=config)