Skip to main content
Version: V1.4.1

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:

FieldTypeDefaultDescription and constraints
dimensionint384Vector dimension, 1–4096
distancestr"cosine"Distance metric: l2, cosine, inner_product
typestr"hnsw"Index type: hnsw, hnsw_sq, hnsw_bq
libstr"vsag"Implementation library: vsag
sync_modestr"async"HNSW synchronous/asynchronous maintenance: "immediate" / "async". Supported for hnsw, hnsw_sq, and hnsw_bq. Semantics match SQL sync_mode in WITH (...). The server returns an error if the DDL or value is not supported.
Mint16Max connections, 5–128
ef_constructionint200Build-time search range, 5–1000
ef_searchint64Query-time search range, 1–1000
extra_info_max_sizeint0Max extra info size, 0–16384
refine_kfloat4.0Refine search parameter, 1.0–1000.0
refine_typestr"sq8"Refine type: sq8, fp32
bq_bits_queryint32Quantized query bits: 0, 4, or 32
bq_use_fhtbooltrueWhether to use FHT
propertiesdictNoneOther primitive key/value pairs; reserved keys are ignored with a warning

VectorIndexConfig combines HNSW with an embedding function:

  • hnsw: HNSWConfiguration or None (default HNSW).
  • embedding_function: EmbeddingFunction; if omitted, DefaultEmbeddingFunction() is used.

Asynchronous maintenance mode​

When the backend vector index uses asynchronous maintenance (sync_mode=async), Collection writes can return before the index catches up. Approximate search results are eventually consistent. After an insert, approximate visibility is generally within milliseconds. Starting in seekdb V1.3.0, server and embedded modes use asynchronous indexes by default. To get approximate search hits as soon as possible after a write, call Collection.refresh_index() (see refresh_index). You can also run SQL CALL dbms_index_manager.refresh();. See REFRESH (DBMS_INDEX_MANAGER).

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)