Class EmbeddingBatchTransformation<TInput>

Creates embeddings for a batch of rows with one generator call and writes each vector back into the corresponding row object. The default batch size is 64.

Inheritance
DataFlowTransformation<TInput, TInput>
EmbeddingBatchTransformation<TInput>
Inherited Members
Namespace: ETLBox.AI
Assembly: ETLBox.AI.dll
Syntax
    public class EmbeddingBatchTransformation<TInput> : DataFlowTransformation<TInput, TInput>, IDataFlowTransformation<TInput, TInput>, IDataFlowSource<TInput>, IDataFlowSource, IDataFlowDestination<TInput>, IDataFlowDestination, IDataFlowComponent, ILoggableTask
Type Parameters
NameDescription
TInput

Type of ingoing and outgoing data.

Constructors

EmbeddingBatchTransformation()

Declaration
    public EmbeddingBatchTransformation()

EmbeddingBatchTransformation(IEmbeddingGenerator<string, Embedding<float>>)

Declaration
    public EmbeddingBatchTransformation(IEmbeddingGenerator<string, Embedding<float>> embeddingGenerator)
Parameters
TypeNameDescription
IEmbeddingGenerator<string, Embedding<float>>embeddingGenerator

EmbeddingBatchTransformation(IEmbeddingGenerator<string, Embedding<float>>, int)

Declaration
    public EmbeddingBatchTransformation(IEmbeddingGenerator<string, Embedding<float>> embeddingGenerator, int batchSize)
Parameters
TypeNameDescription
IEmbeddingGenerator<string, Embedding<float>>embeddingGenerator
intbatchSize

Properties

BatchSize

The number of rows sent to the embedding generator in one call. Default is 64.

Declaration
    public int BatchSize { get; set; }
Property Value
TypeDescription
int

EmbeddingGenerationOptions

Optional options passed to the embedding generator, e.g. model id or dimensions.

Declaration
    public EmbeddingGenerationOptions EmbeddingGenerationOptions { get; set; }
Property Value
TypeDescription
EmbeddingGenerationOptions

EmbeddingGenerator

Embedding generator created by the caller.

Declaration
    public IEmbeddingGenerator<string, Embedding<float>> EmbeddingGenerator { get; set; }
Property Value
TypeDescription
IEmbeddingGenerator<string, Embedding<float>>

RequireSameItemCount

If true, the generator must return exactly one vector per input row, otherwise the batch fails. If false (default), rows are only emitted for the returned vectors.

Declaration
    public bool RequireSameItemCount { get; set; }
Property Value
TypeDescription
bool

SourceBlock

SourceBlock from the underlying TPL.Dataflow which is used as output buffer for the component.

Declaration
    public override ISourceBlock<TInput> SourceBlock { get; }
Property Value
TypeDescription
ISourceBlock<TInput>
Overrides

TargetBlock

TargetBlock from the underlying TPL.Dataflow which is used as input buffer for the component.

Declaration
    public override ITargetBlock<TInput> TargetBlock { get; }
Property Value
TypeDescription
ITargetBlock<TInput>
Overrides

TextPropertyName

Only for ExpandoObject: property that contains the text to embed. Default is "Text".

Declaration
    public string TextPropertyName { get; set; }
Property Value
TypeDescription
string

TextSelector

Selects the text that is sent to the embedding generator.

Declaration
    public Func<TInput, string> TextSelector { get; set; }
Property Value
TypeDescription
Func<TInput, string>

VectorPropertyName

Only for ExpandoObject: property that receives the vector. Default is "Embedding".

Declaration
    public string VectorPropertyName { get; set; }
Property Value
TypeDescription
string

VectorSetter

Writes the returned vector into the row.

Declaration
    public Action<TInput, ReadOnlyMemory<float>> VectorSetter { get; set; }
Property Value
TypeDescription
Action<TInput, ReadOnlyMemory<float>>

Methods

CheckParameter()

Declaration
    protected override void CheckParameter()
Overrides

CleanUpOnFaulted(Exception)

Declaration
    protected override void CleanUpOnFaulted(Exception e)
Parameters
TypeNameDescription
Exceptione
Overrides

CleanUpOnSuccess()

Declaration
    protected override void CleanUpOnSuccess()
Overrides

CompleteBuffer()

Declaration
    protected override void CompleteBuffer()
Overrides

FaultBuffer(Exception)

Declaration
    protected override void FaultBuffer(Exception e)
Parameters
TypeNameDescription
Exceptione
Overrides

InitComponent()

Declaration
    protected override void InitComponent()
Overrides

PrepareParameterForCheck()

Declaration
    protected override void PrepareParameterForCheck()
Overrides

Reset()

Declaration
    protected override void Reset()
Overrides

Implements