index

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package index defines a minimal abstraction for vector indexes that can be built from embeddings, queried for kNN, and serialized for persistence. Implementations in this module include a brute-force baseline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index interface {
	// Build constructs the index from the given ids and vectors.
	// ids and vectors must have the same length; vectors must be non-nil.
	Build(ids []string, vectors [][]float32) error

	// Query runs a kNN search against the index with the provided query vector
	// and returns up to k matches as parallel slices of ids and scores, where
	// higher score means more similar (e.g., cosine similarity).
	Query(query []float32, k int) (ids []string, scores []float64, err error)

	// MarshalBinary serializes the index into a byte slice.
	MarshalBinary() ([]byte, error)

	// UnmarshalBinary reconstructs the index from a serialized byte slice.
	UnmarshalBinary(data []byte) error
}

Index defines a generic vector index with basic lifecycle methods. It enables building from (id, embedding) pairs, kNN queries, and binary serialization for persistence.

Directories

Path Synopsis
Package bruteforce provides a simple vector index that answers kNN queries by scanning all vectors and scoring via cosine similarity.
Package bruteforce provides a simple vector index that answers kNN queries by scanning all vectors and scoring via cosine similarity.
Package cover provides a cover-tree adapter that currently delegates to a brute-force implementation.
Package cover provides a cover-tree adapter that currently delegates to a brute-force implementation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL