vdb

package module
v0.0.0-...-4e2ed10 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: BSD-2-Clause Imports: 13 Imported by: 0

README

vdb

idiotically simple vector database for LLM embeddings in Go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrZeroVector         = errors.New("zero length vector")
	ErrVectorSizeMismatch = errors.New("vectors are not the same size")
)
View Source
var ErrInvalidParallel = errors.New("number of threads must be >= 0")

Functions

func Embeddings

func Embeddings(input string, model string) ([][]float64, error)

Types

type DB

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

func (*DB) AddVector

func (d *DB) AddVector(x *Vector) error

func (*DB) GobDecode

func (d *DB) GobDecode(data []byte) error

func (*DB) GobEncode

func (d *DB) GobEncode() ([]byte, error)

func (*DB) Len

func (d *DB) Len() int

func (*DB) LoadFile

func (d *DB) LoadFile(fn DecodeFunction) error

func (*DB) SetFilename

func (d *DB) SetFilename(f string)

func (*DB) SetParallel

func (d *DB) SetParallel(p int) error

func (*DB) SimilarVectors

func (d *DB) SimilarVectors(x *Vector, n int, t float64) ([]*Vector, error)

type DecodeFunction

type DecodeFunction func(json.RawMessage) (any, error)

type EmbedRequest

type EmbedRequest struct {
	Model string `json:"model"`
	Input string `json:"input"`
}

type EmbedResponse

type EmbedResponse struct {
	Embeddings [][]float64 `json:"embeddings"`
}

type Vector

type Vector struct {
	V    []float64 `json:"v"`
	N    float64   `json:"n"`
	Data any       `json:"d"`
	// contains filtered or unexported fields
}

func NewVector

func NewVector(x []float64, data any) (*Vector, error)

func (*Vector) CosineSimilarity

func (a *Vector) CosineSimilarity(b *Vector) (float64, error)

Finds the cosine similarity between two non-zero vectors.

func (*Vector) Equal

func (a *Vector) Equal(b *Vector) bool

func (*Vector) GetData

func (v *Vector) GetData() any

func (*Vector) Len

func (v *Vector) Len() int

func (*Vector) Next

func (v *Vector) Next() *Vector

func (*Vector) Prev

func (v *Vector) Prev() *Vector

func (*Vector) String

func (v *Vector) String() string

Jump to

Keyboard shortcuts

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