embeddingstore

command module
v0.0.0-...-2c27dae Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

README

Mastro

Embedding Store

An Embedding store is a service to store embeddings and compute similarity between them. Embeddings are numerical vectors that can be extracted from unstructured data, such as text, images, audio and video files.

// Embedding ... a named feature vector to be used for similarity search
type Embedding struct {
	Id         string    `json:"id,omitempty"`
	Name       string    `json:"name,omitempty"`
	InsertedAt time.Time `json:"inserted_at,omitempty"`
	Vector     []float32 `json:"vector,omitempty"`
}

A data access object (DAO) for an embedding is defined as follows:

// EmbeddingDAOProvider ... The interface each dao must implement
type EmbeddingDAOProvider interface {
	Init(*conf.DataSourceDefinition)
	Upsert(e []Embedding) error
	GetById(id string) (*Embedding, error)
	GetByName(name string) ([]Embedding, error)
	SimilarToThis(vector []float32, k int) ([]Embedding, error)
	DeleteByName(name string) error
	DeleteByIds(ids ...string) error
	CloseConnection()
}

The interface is then implemented for specific targets in the embeddingstore/daos/* packages.

Service

A basic interface is dedined to retrieve embeddings:

// EmbeddingStoreService ... EmbeddingStoreService Interface listing service methods
type EmbeddingStoreService interface {
	Init(cfg *conf.Config) *resterrors.RestErr
	UpsertEmbeddings(embeddings []Embedding) *resterrors.RestErr
	GetEmbeddingByID(id string) (*Embedding, *resterrors.RestErr)
	GetEmbeddingByName(name string) ([]Embedding, *resterrors.RestErr)
	SimilarToThis(vector []float32, k int) ([]Embedding, *resterrors.RestErr)
	DeleteEmbeddingByName(name string) *resterrors.RestErr
	DeleteEmbeddingByIds(ids ...string) *resterrors.RestErr
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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