embeddings

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsistentHashEmbeddingFunction

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

func (*ConsistentHashEmbeddingFunction) EmbedDocuments

func (e *ConsistentHashEmbeddingFunction) EmbedDocuments(ctx context.Context, documents []string) ([]Embedding, error)

func (*ConsistentHashEmbeddingFunction) EmbedQuery

func (e *ConsistentHashEmbeddingFunction) EmbedQuery(_ context.Context, document string) (Embedding, error)

type Distance

type Distance float32

type DistanceMetric

type DistanceMetric string
const (
	L2     DistanceMetric = "l2"
	COSINE DistanceMetric = "cosine"
	IP     DistanceMetric = "ip"
)

type DistanceMetricOperator

type DistanceMetricOperator interface {
	Compare(a, b []float32) float64
}

type Distances

type Distances []Distance

type Embedding

type Embedding interface {
	Len() int
	ContentAsFloat32() []float32
	ContentAsInt32() []int32
	FromFloat32(content ...float32) error
	Compare(other Embedding, metric DistanceMetricOperator) float32
	IsDefined() bool
}

func NewEmbeddingFromFloat32

func NewEmbeddingFromFloat32(embedding []float32) Embedding

func NewEmbeddingFromFloat64

func NewEmbeddingFromFloat64(embedding []float64) Embedding

func NewEmbeddingFromInt32

func NewEmbeddingFromInt32(embedding []int32) Embedding

func NewEmbeddingsFromFloat32

func NewEmbeddingsFromFloat32(lst [][]float32) ([]Embedding, error)

func NewEmbeddingsFromInt32

func NewEmbeddingsFromInt32(lst [][]int32) ([]Embedding, error)

func NewEmbeddingsFromInterface

func NewEmbeddingsFromInterface(lst []interface{}) ([]Embedding, error)

func NewEmptyEmbedding

func NewEmptyEmbedding() Embedding

func NewEmptyEmbeddings

func NewEmptyEmbeddings() []Embedding

func NewInt32Embedding

func NewInt32Embedding(embedding []int32) Embedding

type EmbeddingFunction

type EmbeddingFunction interface {
	// EmbedDocuments returns a vector for each text.
	EmbedDocuments(ctx context.Context, texts []string) ([]Embedding, error)
	// EmbedQuery embeds a single text.
	EmbedQuery(ctx context.Context, text string) (Embedding, error)
}

func NewConsistentHashEmbeddingFunction

func NewConsistentHashEmbeddingFunction() EmbeddingFunction

type EmbeddingModel

type EmbeddingModel string

type Embeddings

type Embeddings []Embedding

type Float32Embedding

type Float32Embedding struct {
	ArrayOfFloat32 *[]float32
}

func (*Float32Embedding) Compare

func (e *Float32Embedding) Compare(other Embedding, metric DistanceMetricOperator) float32

func (*Float32Embedding) ContentAsFloat32

func (e *Float32Embedding) ContentAsFloat32() []float32

func (*Float32Embedding) ContentAsInt32

func (e *Float32Embedding) ContentAsInt32() []int32

func (*Float32Embedding) FromFloat32

func (e *Float32Embedding) FromFloat32(content ...float32) error

func (*Float32Embedding) IsDefined

func (e *Float32Embedding) IsDefined() bool

func (*Float32Embedding) Len

func (e *Float32Embedding) Len() int

func (*Float32Embedding) MarshalJSON

func (e *Float32Embedding) MarshalJSON() ([]byte, error)

func (*Float32Embedding) UnmarshalJSON

func (e *Float32Embedding) UnmarshalJSON(b []byte) error

type Int32Embedding

type Int32Embedding struct {
	ArrayOfInt32 *[]int32
}

func (*Int32Embedding) Compare

func (e *Int32Embedding) Compare(other Embedding, metric DistanceMetricOperator) float32

func (*Int32Embedding) ContentAsFloat32

func (e *Int32Embedding) ContentAsFloat32() []float32

func (*Int32Embedding) ContentAsInt32

func (e *Int32Embedding) ContentAsInt32() []int32

func (*Int32Embedding) FromFloat32

func (e *Int32Embedding) FromFloat32(_ ...float32) error

func (*Int32Embedding) FromInt32

func (e *Int32Embedding) FromInt32(content ...int32) error

func (*Int32Embedding) IsDefined

func (e *Int32Embedding) IsDefined() bool

func (*Int32Embedding) Len

func (e *Int32Embedding) Len() int

func (*Int32Embedding) MarshalJSON

func (e *Int32Embedding) MarshalJSON() ([]byte, error)

func (*Int32Embedding) UnmarshalJSON

func (e *Int32Embedding) UnmarshalJSON(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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