tei

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Huggingface Text Embeddings Inference https://github.com/huggingface/text-embeddings-inference

package is a wrapper for the Huggingface text embeddings inference project that can be run locally for creating vector embeddings.

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingAPIBaseURL = errors.New("missing the API Base URL") //nolint:lll

Functions

This section is empty.

Types

type Option

type Option func(emb *TextEmbeddingsInference)

func WithAPIBaseURL

func WithAPIBaseURL(url string) Option

WithAPIBaseURL adds base url for api.

func WithBatchSize

func WithBatchSize(batchSize int) Option

WithBatchSize is an option for specifying the batch size.

func WithCookies

func WithCookies(cookies map[string]string) Option

WithCookies add request cookies.

func WithHeaders

func WithHeaders(headers map[string]string) Option

WithHeaders add request headers.

func WithPoolSize

func WithPoolSize(poolSize int) Option

WithPoolSize is an option for specifying the number of goroutines.

func WithStripNewLines

func WithStripNewLines(stripNewLines bool) Option

WithStripNewLines is an option for specifying the should it strip new lines.

func WithTimeout

func WithTimeout(dur time.Duration) Option

WithTimeout set the request timeout.

func WithTruncate

func WithTruncate() Option

WithTruncate set the embedder to truncate input length.

type TextEmbeddingsInference

type TextEmbeddingsInference struct {
	StripNewLines bool

	BatchSize int
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (TextEmbeddingsInference, error)

func (TextEmbeddingsInference) EmbedDocuments

func (e TextEmbeddingsInference) EmbedDocuments(_ context.Context, texts []string) ([][]float32, error)

EmbedDocuments creates one vector embedding for each of the texts.

func (TextEmbeddingsInference) EmbedQuery

func (e TextEmbeddingsInference) EmbedQuery(_ context.Context, text string) ([]float32, error)

EmbedQuery embeds a single text.

Jump to

Keyboard shortcuts

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