fastembed

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: MIT Imports: 16 Imported by: 2

README

WIP

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmbeddingModel

type EmbeddingModel string

Enum-type representing the available embedding models

const (
	AllMiniLML6V2 EmbeddingModel = "fast-all-MiniLM-L6-v2"
	BGEBaseEN     EmbeddingModel = "fast-bge-base-en"
	BGESmallEN    EmbeddingModel = "fast-bge-small-en"
)

type FlagEmbedding

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

Struct to interface with a FastEmbed model

func NewFlagEmbedding

func NewFlagEmbedding(options *InitOptions) (*FlagEmbedding, error)

Function to initialize a FastEmbed model

func (*FlagEmbedding) Destroy

func (f *FlagEmbedding) Destroy()

Function to cleanup the internal onnxruntime environment when it is no longer needed.

func (*FlagEmbedding) Embed

func (f *FlagEmbedding) Embed(input []string, batchSize int) ([]([]float32), error)

Function to embed a batch of input strings The batchSize parameter controls the number of inputs to embed in a single batch The batches are processed in parallel Returns the first error encountered if any Default batch size is 512

func (*FlagEmbedding) PassageEmbed

func (f *FlagEmbedding) PassageEmbed(input []string, batchSize int) ([]([]float32), error)

Function to embed string prefixed with "passage: "

func (*FlagEmbedding) QueryEmbed

func (f *FlagEmbedding) QueryEmbed(input string) ([]float32, error)

Function to embed a single input string prefixed with "query: " Recommended for generating query embeddings for semantic search

type InitOptions

type InitOptions struct {
	Model                EmbeddingModel
	ExecutionProviders   []string
	MaxLength            int
	CacheDir             string
	ShowDownloadProgress *bool
}

Options to initialize a FastEmbed model Model: The model to use for embedding ExecutionProviders: The execution providers to use for onnxruntime MaxLength: The maximum length of the input sequence CacheDir: The directory to cache the model files ShowDownloadProgress: Whether to show the download progress bar NOTE: We use a pointer for "ShowDownloadProgress" so that we can distinguish between the user not setting this flag and the user setting it to false. We want the default value to be true. As Go assigns a default(empty) value of "false" to bools, we can't distinguish if the user set it to false or not set at all. A pointer to bool will be nil if not set explicitly

type ModelInfo

type ModelInfo struct {
	Model       EmbeddingModel
	Dim         int
	Description string
}

Struct to represent FastEmbed model information

func ListSupportedModels added in v0.1.4

func ListSupportedModels() []ModelInfo

Function to list the supported FastEmbed models

Jump to

Keyboard shortcuts

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