Vecgo is a Go library designed for efficient vector indexing and searching, supporting various index types and emphasizing approximate nearest neighbor search. It provides a versatile and user-friendly interface for managing and querying vast collections of high-dimensional vectors.
⚠️ This is experimental and subject to breaking changes.
Here's a basic example demonstrating how to perform nearest neighbor search with Vecgo:
package main
import (
"fmt"
"log"
"github.com/hupe1980/vecgo"
)
func main() {
vg := vecgo.NewHNSW[string]()
// vg := vecgo.NewFlat[string]()
_, err := vg.Insert(vecgo.VectorWithData[string]{
Vector: []float32{1.0, 2.0, 2.5},
Data: "Hello World!",
})
if err != nil {
log.Fatal(err)
}
k := 5
result, err := vg.KNNSearch([]float32{1.0, 2.0, 2.5}, k)
if err != nil {
log.Fatal(err)
}
fmt.Println(result[0].Data)
}
For more information on each method, please refer to the GoDoc documentation.
Contributions to Vecgo are welcome! Feel free to open issues for bug reports, feature requests, or submit pull requests with improvements.
Vecgo is licensed under the MIT License. See the LICENSE file for details.