ann

package
v0.5.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bruteforce

type Bruteforce[T any] struct {
	// contains filtered or unexported fields
}

Bruteforce is a naive implementation of vector index.

func NewBruteforce

func NewBruteforce[T any](distanceFunc func(a, b T) float32) *Bruteforce[T]

func (*Bruteforce[T]) Add

func (b *Bruteforce[T]) Add(v T) int

func (*Bruteforce[T]) SearchIndex

func (b *Bruteforce[T]) SearchIndex(q, k int, prune0 bool) ([]lo.Tuple2[int, float32], error)

func (*Bruteforce[T]) SearchVector

func (b *Bruteforce[T]) SearchVector(q T, k int, prune0 bool) []lo.Tuple2[int, float32]

type HNSW

type HNSW[T any] struct {
	// contains filtered or unexported fields
}

HNSW is a vector index based on Hierarchical Navigable Small Worlds.

func NewHNSW

func NewHNSW[T any](distanceFunc func(a, b T) float32) *HNSW[T]

func (*HNSW[T]) Add

func (h *HNSW[T]) Add(v T) int

func (*HNSW[T]) Marshal

func (h *HNSW[T]) Marshal(w io.Writer) error

func (*HNSW[T]) SearchIndex

func (h *HNSW[T]) SearchIndex(q, k int, prune0 bool) ([]lo.Tuple2[int, float32], error)

func (*HNSW[T]) SearchVector

func (h *HNSW[T]) SearchVector(q T, k int, prune0 bool) []lo.Tuple2[int, float32]

func (*HNSW[T]) Unmarshal

func (h *HNSW[T]) Unmarshal(r io.Reader) error

type Index

type Index interface {
	Add(v []float32) int
	SearchIndex(q, k int, prune0 bool) ([]lo.Tuple2[int, float32], error)
	SearchVector(q []float32, k int, prune0 bool) []lo.Tuple2[int, float32]
}

Jump to

Keyboard shortcuts

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