ann

package
v0.5.11 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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