search

package
v0.13.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CosineSimilarity

func CosineSimilarity(X, Y *mat.Dense) (*mat.Dense, error)

CosineSimilarity calculates the cosine similarity between two vectors. The vectors must be of the same length.

func MaximalMarginalRelevance

func MaximalMarginalRelevance(
	queryEmbedding *mat.Dense,
	embeddingList *mat.Dense,
	lambdaMult float64,
	k int,
) ([]int, error)

MaximalMarginalRelevance implements the Maximal Marginal Relevance algorithm. It takes a query embedding, a list of embeddings, a lambda multiplier, and a number of results to return. It returns a list of indices of the embeddings that are most relevant to the query. This is a relatively naive and unoptimized implementation of MMR. :-/ See https://www.cs.cmu.edu/~jgc/publication/The_Use_MMR_Diversity_Based_LTMIR_1998.pdf

Types

This section is empty.

Jump to

Keyboard shortcuts

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