vectorstores

package
v0.0.0-...-1414e4b Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CosineSimilarity

func CosineSimilarity(a, b []float32) float32

CosineSimilarity calculates the cosine similarity between two vectors.

func SimilaritySearch

func SimilaritySearch(ctx context.Context, store flowllm.VectorStore, embeddings flowllm.Embeddings, query string, k int) ([]flowllm.Document, error)

SimilaritySearch returns the k most similar documents to the given query. It uses the given vector store's SimilaritySearchVectorWithScore method to perform the search.

Types

type Memory

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

Memory is a simple in-memory vector store. It implements the VectorStore interface and stores the vectors in memory. It is not meant to be used in production, but it is useful for testing and as an example of how to implement a VectorStore.

func NewMemoryVectorStore

func NewMemoryVectorStore(embeddings flowllm.Embeddings) *Memory

NewMemoryVectorStore creates a new Memory vector store.

func (*Memory) AddDocuments

func (m *Memory) AddDocuments(ctx context.Context, documents ...flowllm.Document) error

func (*Memory) SimilaritySearch

func (m *Memory) SimilaritySearch(ctx context.Context, query string, k int) ([]flowllm.Document, error)

func (*Memory) SimilaritySearchVectorWithScore

func (m *Memory) SimilaritySearchVectorWithScore(_ context.Context, query []float32, k int) ([]flowllm.ScoredDocument, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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