Skip to content

spt-index

SPT Format progressive HNSW indexing with Layer A/B/C tiered search

Overview

spt-index implements a three-layer progressive HNSW (Hierarchical Navigable Small World) index for the SPT file format. Layer A provides coarse entry-point routing at sub-5ms load time (~0.70 recall), Layer B adds partial adjacency for hot regions (~0.85 recall), and Layer C delivers full HNSW adjacency at 0.95+ recall. This progressive model enables instant queries that improve as more index data loads.

Key Features

  • Three-tier progressive loading -- Layer A/B/C with increasing recall and load time
  • HNSW graph implementation -- full hierarchical navigable small world graph
  • Distance functions -- cosine, dot product, and L2 distance built in
  • Segment codec -- encode/decode index segments for on-disk storage
  • no_std compatible -- works in embedded and WASM environments

Dependencies

No runtime dependencies. Self-contained with only rand as a dev-dependency.

Usage

rust
use spt_index::{ProgressiveIndex, HnswConfig, build_layer_a};

let config = HnswConfig::default();
// Build progressive index from vector data
// let layer_a = build_layer_a(&vectors, &config);

API Reference

Core Types

TypeDescription
ProgressiveIndexMain index supporting incremental layer loading
HnswGraphFull HNSW graph with multi-layer navigation
HnswConfigConfiguration for M, ef_construction, and layer parameters
LayerA / LayerB / LayerCIndividual index tier implementations
IndexSegDataOn-disk segment representation
IndexSegHeaderSegment header with codec metadata
VectorStoreTrait for providing vectors to the index
PartitionEntryEntry point for coarse partition routing

Released under the MIT License.