Documentation
¶
Overview ¶
Package embedding defines utilities for embedding text with various providers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batcher ¶
type Batcher struct {
// contains filtered or unexported fields
}
Batcher is an `Embedder` that batches input data before embedding it.
type Embedder ¶
type Embedder interface {
// Embed embeds the given texts and returns their embeddings.
Embed(ctx context.Context, purpose Purpose, texts []string) (*Embeddings, error)
}
An Embedder is anything that can embed text in batches.
func ConstructEmbedder ¶
ConstructEmbedder constructs an embedder for the given model.
type EmbedderFn ¶
EmbedderFn is a function that embeds text in batches.
func (EmbedderFn) Embed ¶
func (f EmbedderFn) Embed( ctx context.Context, purpose Purpose, texts []string, ) (*Embeddings, error)
type Embeddings ¶
Embeddings is a collection of embeddings with a given dimensionality.
func (*Embeddings) At ¶
func (e *Embeddings) At(i int) ([]float32, error)
At returns the embedding at the given index.
func (*Embeddings) DataType ¶
func (e *Embeddings) DataType() DataType
DataType returns the underlying data type of the embeddings.
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter is an `Embedder` that limits the rate of requests to an inner `Embedder`.
type Model ¶
type Model string
Model is an enumeration over the models we support.
const (
ModelVoyageLarge2Instruct Model = "voyage-large-2-instruct"
)
Supported models.
func (Model) MaxBatchSize ¶
MaxBatchSize returns the maximum batch size for the model.
func (Model) MaxReqsPerSec ¶
MaxReqsPerSec returns the rate limit for the model, as max requests per second.