Documentation ¶
Index ¶
- Constants
- type DataPoint
- type DistanceMeasure
- type SearchResult
- type VectorIndex
- func (vi *VectorIndex[T]) AddDataPoint(dataPoint *DataPoint[T]) error
- func (vi *VectorIndex[T]) Build()
- func (vi *VectorIndex[T]) GetNormalVector(dataPoints []*DataPoint[T]) []float64
- func (vi *VectorIndex[T]) SearchByItem() ([]int, error)
- func (vi *VectorIndex[T]) SearchByVector(input []float64, searchNum int, numberOfBuckets float64) (*[]SearchResult[T], error)
Constants ¶
View Source
const (
DefaultBuckets = 10.0
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataPoint ¶
type DataPoint[T comparable] struct { ID T Embedding []float64 }
func NewDataPoint ¶
func NewDataPoint[T comparable](id T, embedding []float64) *DataPoint[T]
type DistanceMeasure ¶
func NewCosineDistanceMeasure ¶
func NewCosineDistanceMeasure() DistanceMeasure
func NewEuclideanDistanceMeasure ¶
func NewEuclideanDistanceMeasure() DistanceMeasure
type SearchResult ¶
type SearchResult[T comparable] struct { ID T Distance float64 Vector []float64 }
type VectorIndex ¶
type VectorIndex[T comparable] struct { NumberOfRoots int NumberOfDimensions int MaxItemsPerLeafNode int Roots []*treeNode[T] IDToTreeNodeMapping map[string]*treeNode[T] IDToDataPointMapping map[T]*DataPoint[T] DataPoints []*DataPoint[T] DistanceMeasure DistanceMeasure Mutex *sync.Mutex }
T is the type of the identifier used to identify data points
func NewVectorIndex ¶
func NewVectorIndex[T comparable](numberOfRoots int, numberOfDimensions int, maxIetmsPerLeafNode int, dataPoints []*DataPoint[T], distanceMeasure DistanceMeasure) (*VectorIndex[T], error)
func (*VectorIndex[T]) AddDataPoint ¶
func (vi *VectorIndex[T]) AddDataPoint(dataPoint *DataPoint[T]) error
func (*VectorIndex[T]) Build ¶
func (vi *VectorIndex[T]) Build()
func (*VectorIndex[T]) GetNormalVector ¶
func (vi *VectorIndex[T]) GetNormalVector(dataPoints []*DataPoint[T]) []float64
GetNormalVector calculates the normal vector of a hyperplane that separates the two clusters of data points. nolint: funlen, gocognit, cyclop, gosec
func (*VectorIndex[T]) SearchByItem ¶
func (vi *VectorIndex[T]) SearchByItem() ([]int, error)
func (*VectorIndex[T]) SearchByVector ¶
func (vi *VectorIndex[T]) SearchByVector(input []float64, searchNum int, numberOfBuckets float64) (*[]SearchResult[T], error)
nolint: funlen, cyclop
Click to show internal directories.
Click to hide internal directories.