hnswgo

package module
v0.0.0-...-3064a60 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: MIT Imports: 5 Imported by: 0

README

hnswlib-to-go

Hnswlib to go. Golang interface to hnswlib(https://github.com/nmslib/hnswlib). This is a golang interface of hnswlib. For more information, please follow hnswlib and Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs.. But in this project, we make compatible hnswlib to 0.7.0.

Version
  • version 1.1.0

    • Update hnswlib compatible version to 0.7.0
    • Add some apis(AddBatchPoints、SearchBatchKNN、Free、SetNormalize)
  • version 1.0.1

    • Code format
    • Add an api support unload the graph(Experimental)
  • version 1.0.0

    • hnswlib compatible version 0.5.2.
Build
  • Linux/MacOS
    • Build Golang Env
    • go mod init
    • make
Usage
  • When building golang program, please add export CGO_CXXFLAGS=-std=c++11 command before go build / run / test ...
argument type
dim int vector dimension
M int seeALGO_PARAMS.md
efConstruction int seeALGO_PARAMS.md
randomSeed int random seed for hnsw
maxElements int max records in data
spaceType str
spaceType distance
ip inner product
cosine cosine similarity
l2 l2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HNSW

type HNSW struct {
	// contains filtered or unexported fields
}

func Load

func Load(location string, dim int, spaceType string) *HNSW

Load load a hnsw graph

func New

func New(dim, M, efConstruction, randSeed int, maxElements uint32, spaceType string) *HNSW

New make a hnsw graph

func (*HNSW) AddBatchPoints

func (h *HNSW) AddBatchPoints(vectors [][]float32, labels []uint32, coroutines int) bool

AddBatchPoints add some points on graph

func (*HNSW) AddPoint

func (h *HNSW) AddPoint(vector []float32, label uint32) bool

AddPoint add a point on graph

func (*HNSW) Free

func (h *HNSW) Free()

func (*HNSW) Save

func (h *HNSW) Save(location string) bool

Save save graph node on graph

func (*HNSW) SearchBatchKNN

func (h *HNSW) SearchBatchKNN(vectors [][]float32, N, coroutines int) ([][]uint32, [][]float32)

func (*HNSW) SearchKNN

func (h *HNSW) SearchKNN(vector []float32, N int) ([]uint32, []float32)

SearchKNN search points on graph with knn-algorithm

func (*HNSW) SetEf

func (h *HNSW) SetEf(ef int)

SetEf set ef argument on graph

func (*HNSW) SetNormalize

func (h *HNSW) SetNormalize(isNeedNormalize bool)

func (*HNSW) Unload

func (h *HNSW) Unload() bool

Unload TODO Test for release the graph memory

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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