pipelines

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 37 Imported by: 48 modules, 9 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderDecisionState added in v0.8.6

func RenderDecisionState(v any) (string, error)

RenderDecisionState renders a structured state as decision models take a JSON state: indented JSON with non-ASCII characters left as they are. Object keys follow Go's encoding (struct field order, or sorted map keys), so use a struct when key order matters.

func WithASRBlankID added in v0.8.1

func WithASRPrompt added in v0.8.6

WithASRPrompt sets the model-specific user prompt used for generative ASR.

func WithASRSampleRate added in v0.8.1

func WithASRSampleRate(sampleRate int) backends.PipelineOption[*AutomaticSpeechRecognitionPipeline]

WithASRSampleRate sets the sample rate expected by the model.

func WithASRStreamingOptions added in v0.9.0

WithASRStreamingOptions configures a package loaded with WithGenAIStreamingASR. ChunkSamples must be the package's maximum chunk size at its native sample rate.

func WithAudioClassificationSampleRate added in v0.8.1

func WithAudioClassificationSampleRate(sampleRate int) backends.PipelineOption[*AudioClassificationPipeline]

WithAudioClassificationSampleRate sets the sample rate expected by the model.

func WithAudioTopK added in v0.8.1

WithAudioTopK sets the number of classifications returned per waveform.

func WithAverageAggregation added in v0.3.4

func WithAverageAggregation() backends.PipelineOption[*TokenClassificationPipeline]

WithAverageAggregation sets the aggregation strategy for the token labels to average It reproduces simple aggregation from the huggingface implementation.

func WithBackgroundRemovalOutput added in v0.8.1

func WithBackgroundRemovalOutput(name string) backends.PipelineOption[*BackgroundRemovalPipeline]

func WithBatchSize added in v0.5.0

func WithBatchSize(size int) backends.PipelineOption[*CrossEncoderPipeline]

func WithBoxesOutput added in v0.6.0

func WithBoxesOutput(name string) backends.PipelineOption[*ObjectDetectionPipeline]

func WithClassification added in v0.6.2

func WithClassification() backends.PipelineOption[*TabularPipeline]

func WithDecisionMaxBatchRows added in v0.8.6

func WithDecisionMaxBatchRows(n int) backends.PipelineOption[*DecisionPipeline]

WithDecisionMaxBatchRows caps the (state, question) rows per forward pass.

func WithDecisionMaxBatchTokens added in v0.8.6

func WithDecisionMaxBatchTokens(n int) backends.PipelineOption[*DecisionPipeline]

WithDecisionMaxBatchTokens caps a forward pass's padded size, rows times longest row.

func WithDecisionQuestions added in v0.8.6

func WithDecisionQuestions(questions map[string]DecisionQuestion) backends.PipelineOption[*DecisionPipeline]

WithDecisionQuestions sets the questions Run asks of every input.

func WithDetectionIouThreshold added in v0.6.0

func WithDetectionIouThreshold(th float32) backends.PipelineOption[*ObjectDetectionPipeline]

func WithDetectionScoreThreshold added in v0.6.0

func WithDetectionScoreThreshold(th float32) backends.PipelineOption[*ObjectDetectionPipeline]

func WithDetectionTopK added in v0.6.0

func WithDetectionTopK(k int) backends.PipelineOption[*ObjectDetectionPipeline]

func WithEnableThinking added in v0.8.6

func WithEnableThinking(enabled bool) backends.PipelineOption[*TextGenerationPipeline]

WithEnableThinking controls the chat template's enable_thinking argument for every call made by this pipeline. Engine mode does not support this option.

func WithFillMaskTopK added in v0.8.1

func WithFillMaskTopK(topK int) backends.PipelineOption[*FillMaskPipeline]

func WithFirstAggregation added in v0.3.4

func WithFirstAggregation() backends.PipelineOption[*TokenClassificationPipeline]

WithFirstAggregation sets the aggregation strategy for the token labels to first It reproduces first aggregation from the huggingface implementation.

func WithFixedPadding added in v0.5.1

func WithFixedPadding(fixedPaddingLength int) backends.PipelineOption[*TextClassificationPipeline]

func WithGroundedThresholds added in v0.8.3

func WithGroundedThresholds(box, text float32) backends.PipelineOption[*GroundedObjectDetectionPipeline]

func WithGuidance added in v0.7.0

WithGuidance enables constrained (guided) generation using a lark grammar, JSON schema, or regex.

func WithHypothesisTemplate added in v0.1.4

func WithHypothesisTemplate(hypothesisTemplate string) backends.PipelineOption[*ZeroShotClassificationPipeline]

WithHypothesisTemplate can be used to set the hypothesis template for classification.

func WithIDLabelMap added in v0.6.2

func WithIDLabelMap(labels map[int]string) backends.PipelineOption[*TabularPipeline]

func WithIgnoreLabels

func WithIgnoreLabels(ignoreLabels []string) backends.PipelineOption[*TokenClassificationPipeline]

func WithImageCLSToken added in v0.8.3

WithImageCLSToken reads token 0 of a rank-three hidden state. DINOv2's embed_image uses that token. The default remains a mean over every token. A pooled vector is an error.

func WithImageEmbeddingNormalization added in v0.8.1

func WithImageEmbeddingNormalization() backends.PipelineOption[*ImageFeatureExtractionPipeline]

func WithImageLabels added in v0.8.1

func WithImageMode added in v0.6.0

WithImageMode enables image feature extraction mode for vision encoders (e.g., CLIP visual encoder). When enabled, the pipeline accepts images instead of text and skips tokenization.

func WithImageModelPooler added in v0.8.2

WithImageModelPooler selects the model's rank-two pooler_output. The default pools rank-three hidden states with an arithmetic mean, not the model pooler.

func WithImageTopK added in v0.8.1

func WithLabels added in v0.1.4

WithLabels can be used to set the labels to classify the examples.

func WithMaskToken added in v0.8.1

func WithMaskToken(token string) backends.PipelineOption[*FillMaskPipeline]

func WithMaxAggregation added in v0.3.4

WithMaxAggregation sets the aggregation strategy for the token labels to Max It reproduces max aggregation from the huggingface implementation.

func WithMaxLength added in v0.6.0

func WithMaxLength(maxLength int) backends.PipelineOption[*TextGenerationPipeline]

WithMaxLength allows the user to define the maximum generated tokens.

func WithModelPooler added in v0.8.2

WithModelPooler selects the model's rank-two pooler_output instead of mean pooling hidden states. Models without that output are rejected.

func WithMultiLabel added in v0.0.9

func WithMultilabel added in v0.1.4

func WithMultilabel(multilabel bool) backends.PipelineOption[*ZeroShotClassificationPipeline]

WithMultilabel can be used to set whether the pipeline is multilabel.

func WithNCHWFormat added in v0.5.7

func WithNCHWFormat[T imagePipeline]() backends.PipelineOption[T]

func WithNHWCFormat added in v0.5.7

func WithNHWCFormat[T imagePipeline]() backends.PipelineOption[T]

func WithNormalization added in v0.1.1

WithNormalization applies normalization to the mean pooled output of the feature pipeline.

func WithNormalizationSteps added in v0.5.0

func WithNormalizationSteps[T imagePipeline](steps ...imageutil.NormalizationStep) backends.PipelineOption[T]

func WithOutputName added in v0.1.4

func WithOutputName(outputName string) backends.PipelineOption[*FeatureExtractionPipeline]

WithOutputName if there are multiple outputs from the underlying model, which output should be returned. If not passed, the first output from the feature pipeline is returned.

func WithPreprocessSteps added in v0.5.0

func WithPreprocessSteps[T imagePipeline](steps ...imageutil.PreprocessStep) backends.PipelineOption[T]

WithPreprocessSteps is a unified option to add image preprocessing steps to any pipeline that supports them (e.g., FeatureExtractionPipeline in image mode and ImageClassificationPipeline). This avoids conflicting option names.

func WithRegression added in v0.6.2

func WithRegression() backends.PipelineOption[*TabularPipeline]

func WithScoreThreshold added in v0.5.0

func WithScoreThreshold(threshold float32) backends.PipelineOption[*CrossEncoderPipeline]

func WithScoresOutput added in v0.6.0

func WithScoresOutput(name string) backends.PipelineOption[*ObjectDetectionPipeline]

func WithSeed added in v0.6.3

func WithSegmentationLogitsOutput added in v0.8.1

func WithSegmentationLogitsOutput(name string) backends.PipelineOption[*ImageSegmentationPipeline]

func WithSegmentationScoreThreshold added in v0.8.1

func WithSegmentationScoreThreshold(threshold float32) backends.PipelineOption[*ImageSegmentationPipeline]

func WithSigmoid added in v0.0.9

func WithSimpleAggregation

func WithSimpleAggregation() backends.PipelineOption[*TokenClassificationPipeline]

WithSimpleAggregation sets the aggregation strategy for the token labels to simple It reproduces simple aggregation from the huggingface implementation.

func WithSingleLabel added in v0.0.9

func WithSoftmax added in v0.0.9

func WithSortResults added in v0.5.0

func WithSortResults() backends.PipelineOption[*CrossEncoderPipeline]

func WithSplitWords added in v0.5.9

WithSplitWords enables word-level alignment like Hugging Face's is_split_into_words.

func WithStopSequences added in v0.6.3

func WithStopSequences(stopSequences []string) backends.PipelineOption[*TextGenerationPipeline]

WithStopSequences allows the user to define stop sequences that will end the generation when encountered. If the model produces any of the provided strings in the output, generation for that sequence will stop and the stop string will be excluded.

func WithStreaming added in v0.6.0

WithStreaming allows the user to receive generated tokens as a stream instead of waiting for the entire response.

func WithSystemPrompt added in v0.6.2

func WithSystemPrompt(systemPrompt string) backends.PipelineOption[*TextGenerationPipeline]

WithSystemPrompt allows the user to define a system prompt that will be prepended to every input.

func WithTabularSigmoid added in v0.6.2

func WithTabularSigmoid() backends.PipelineOption[*TabularPipeline]

func WithTabularSoftmax added in v0.6.2

func WithTabularSoftmax() backends.PipelineOption[*TabularPipeline]

func WithTemperature added in v0.6.3

func WithTemperature(temperature float64) backends.PipelineOption[*TextGenerationPipeline]

func WithTools added in v0.7.0

WithTools sets the list of Hermes-style tool definition JSON strings to include in the chat template.

func WithTopK added in v0.5.0

WithTopK sets the number of top classifications to return.

func WithTopP added in v0.6.3

func WithWordSplitter added in v0.8.4

WithWordSplitter splits every input with splitter before labelling it, and implies WithSplitWords: Run labels the words the splitter returns, exactly as RunWords would label the same words.

Give the trainer the same option (TrainerConfig.PipelineOptions) and write the training examples as raw text: the token classification dataset then splits them with this splitter too, so training and inference cannot split differently. A splitter is code, not part of the saved model, so it must be passed again wherever the fine-tuned model is loaded.

func WithZeroShotObjectLabels added in v0.8.1

func WithZeroShotObjectLabels(labels []string) backends.PipelineOption[*ZeroShotObjectDetectionPipeline]

func WithoutAggregation

WithoutAggregation returns the token labels.

Types

type ASRTimestamp added in v0.8.6

type ASRTimestamp = backends.ASRTimestamp

ASRTimestamp identifies the text and time range of a recognized word or segment.

type AddressParseAddress added in v0.8.3

type AddressParseAddress struct {
	Address        string
	CleanedAddress string
	Words          []AddressParseWord
	Components     []AddressParseComponent
}

AddressParseAddress contains word-level predictions and adjacent parsed fields.

func (AddressParseAddress) ToFields added in v0.8.3

func (a AddressParseAddress) ToFields() map[string]string

ToFields combines adjacent components with the same tag into a convenient tag-to-value map. Repeated fields are joined with a space.

type AddressParseComponent added in v0.8.3

type AddressParseComponent struct {
	Tag    string
	Value  string
	Scores []float32
}

AddressParseComponent groups adjacent words with the same predicted tag.

type AddressParseConfig added in v0.8.3

type AddressParseConfig = backends.PipelineConfig[*AddressParsePipeline]

type AddressParseOption added in v0.8.3

type AddressParseOption = backends.PipelineOption[*AddressParsePipeline]

func WithAddressParseBatchSize added in v0.8.3

func WithAddressParseBatchSize(size int) AddressParseOption

WithAddressParseBatchSize limits the number of addresses processed in each inference batch. The default is 32.

func WithAddressParseHyphenSplit added in v0.8.3

func WithAddressParseHyphenSplit() AddressParseOption

WithAddressParseHyphenSplit enables splitting a leading unit/street-number pair such as "3-305 Main Street" into "3 305 Main Street".

func WithAddressParseManifestFilename added in v0.8.3

func WithAddressParseManifestFilename(filename string) AddressParseOption

WithAddressParseManifestFilename selects a manifest relative to the model directory.

func WithAddressParsePreprocessors added in v0.8.3

func WithAddressParsePreprocessors(processors ...AddressParsePreprocessor) AddressParseOption

WithAddressParsePreprocessors applies each processor in order before built-in address cleaning. Nil processors are ignored.

func WithAddressParseProbabilities added in v0.8.3

func WithAddressParseProbabilities(enabled bool) AddressParseOption

WithAddressParseProbabilities controls whether word prediction scores are included. Scores are enabled by default for backwards compatibility.

func WithAddressParseProbabilityRounding added in v0.8.3

func WithAddressParseProbabilityRounding(digits int) AddressParseOption

WithAddressParseProbabilityRounding rounds included scores to digits decimal places using ties-to-even rounding. A negative value disables rounding; values from 0 through 9 are supported.

type AddressParseOutput added in v0.8.3

type AddressParseOutput struct {
	Addresses []AddressParseAddress
}

AddressParseOutput is the typed result for one batch of addresses.

func (*AddressParseOutput) GetOutput added in v0.8.3

func (o *AddressParseOutput) GetOutput() []any

type AddressParsePipeline added in v0.8.3

type AddressParsePipeline struct {
	*backends.BasePipeline
	Encoder *backends.Model
	Decoder *backends.Model

	HyphenSplit      bool
	ManifestFilename string
	// contains filtered or unexported fields
}

AddressParsePipeline runs AddressParse's BPEmb model using separate embedder, encoder, and decoder-step ONNX graphs.

func NewAddressParsePipeline added in v0.8.3

func NewAddressParsePipeline(ctx context.Context, config AddressParseConfig, model *backends.Model) (*AddressParsePipeline, error)

NewAddressParsePipeline initializes a AddressParse export bundle.

func (*AddressParsePipeline) GetMetadata added in v0.8.3

func (*AddressParsePipeline) GetModel added in v0.8.3

func (p *AddressParsePipeline) GetModel() *backends.Model

func (*AddressParsePipeline) GetStatistics added in v0.8.3

func (*AddressParsePipeline) IsGenerative added in v0.8.3

func (*AddressParsePipeline) IsGenerative() bool

func (*AddressParsePipeline) Run added in v0.8.3

Run implements the common pipeline interface for a batch of addresses.

func (*AddressParsePipeline) RunAddresses added in v0.8.3

func (p *AddressParsePipeline) RunAddresses(ctx context.Context, addresses []string) (*AddressParseOutput, error)

RunAddresses parses a batch of raw street addresses.

func (*AddressParsePipeline) Validate added in v0.8.3

func (p *AddressParsePipeline) Validate() error

type AddressParsePreprocessor added in v0.8.3

type AddressParsePreprocessor func(string) string

AddressParsePreprocessor transforms an address before AddressParse's built-in lowercase, comma removal, whitespace normalization, and optional hyphen split.

type AddressParseWord added in v0.8.3

type AddressParseWord struct {
	Word  string
	Tag   string
	TagID int
	Score float32
}

AddressParseWord is a word-level prediction from the address parser.

type AnyToAnyConfig added in v0.8.4

type AnyToAnyConfig = backends.PipelineConfig[*AnyToAnyPipeline]

type AnyToAnyEvent added in v0.8.4

type AnyToAnyEvent struct {
	Sequence int
	Type     string // text, image, audio or done
	Text     string
	Image    image.Image
	Audio    *AudioWaveform
}

AnyToAnyEvent carries a text delta or a complete generated media artifact. Events for each conversation are ordered; Sequence identifies the batch item. Audio is emitted after codec reconstruction, not as speculative PCM chunks.

type AnyToAnyOption added in v0.8.4

type AnyToAnyOption = backends.PipelineOption[*AnyToAnyPipeline]

func WithAnyToAnyGenerationMode added in v0.8.4

func WithAnyToAnyGenerationMode(mode string) AnyToAnyOption

WithAnyToAnyGenerationMode requests text, image, audio or interleaved output. Available modes depend on the selected model family.

func WithAnyToAnyGuidance added in v0.8.4

func WithAnyToAnyGuidance(guidance *backends.Guidance) AnyToAnyOption

WithAnyToAnyGuidance enables constrained text generation for Phi-4's GenAI session.

func WithAnyToAnyMaxLength added in v0.8.4

func WithAnyToAnyMaxLength(n int) AnyToAnyOption

func WithAnyToAnyMaxNewTokens added in v0.8.4

func WithAnyToAnyMaxNewTokens(n int) AnyToAnyOption

func WithAnyToAnyStreaming added in v0.8.4

func WithAnyToAnyStreaming() AnyToAnyOption

func WithAnyToAnySystemPrompt added in v0.8.4

func WithAnyToAnySystemPrompt(prompt string) AnyToAnyOption

func WithAnyToAnyTools added in v0.8.4

func WithAnyToAnyTools(tools []string) AnyToAnyOption

WithAnyToAnyTools sets Hermes-style tool definitions for Phi-4's GenAI chat template. The pipeline returns generated tool-call text; applications execute tools themselves.

func WithAnyToAnyVideoDecoder added in v0.8.4

func WithAnyToAnyVideoDecoder(decoder VideoDecoder, maxFrames int) AnyToAnyOption

WithAnyToAnyVideoDecoder sets the optional file decoder and the explicit maximum prefix frame count. Decoded inputs exceeding that limit are rejected.

type AnyToAnyOutput added in v0.8.4

type AnyToAnyOutput struct {
	Responses   []string
	Results     []AnyToAnyResult
	TokenStream chan backends.SequenceDelta
	EventStream chan AnyToAnyEvent
	ErrorStream chan error
}

func (*AnyToAnyOutput) GetOutput added in v0.8.4

func (o *AnyToAnyOutput) GetOutput() []any

type AnyToAnyPipeline added in v0.8.4

type AnyToAnyPipeline struct {
	VideoDecoder    VideoDecoder
	VideoFrameLimit int
	GenerationMode  string
	MaxNewTokens    int
	// contains filtered or unexported fields
}

AnyToAnyPipeline supports Phi-4 multimodal understanding and native Janus/LFM media generation. Input and output modalities depend on the model family; see PIPELINE_SUPPORT.md for the verified graph contracts.

func NewAnyToAnyPipeline added in v0.8.4

func NewAnyToAnyPipeline(ctx context.Context, config AnyToAnyConfig, model *backends.Model) (*AnyToAnyPipeline, error)

func (AnyToAnyPipeline) GetMetadata added in v0.8.4

func (p AnyToAnyPipeline) GetMetadata() backends.PipelineMetadata

func (AnyToAnyPipeline) GetModel added in v0.8.4

func (p AnyToAnyPipeline) GetModel() *backends.Model

func (*AnyToAnyPipeline) GetStatistics added in v0.8.4

func (p *AnyToAnyPipeline) GetStatistics() backends.PipelineStatistics

func (*AnyToAnyPipeline) IsGenerative added in v0.8.4

func (*AnyToAnyPipeline) IsGenerative() bool

func (*AnyToAnyPipeline) Run added in v0.8.4

func (*AnyToAnyPipeline) RunConversations added in v0.8.4

func (p *AnyToAnyPipeline) RunConversations(ctx context.Context, inputs [][]MultimodalMessage) (*AnyToAnyOutput, error)

func (*AnyToAnyPipeline) RunMessages added in v0.8.4

func (p *AnyToAnyPipeline) RunMessages(ctx context.Context, inputs [][]backends.Message) (*AnyToAnyOutput, error)

RunMessages accepts conversations with attachments or ordered ContentBlocks. Phi-4 produces text; native bundles select media with GenerationMode. Audio inputs must use the format accepted by the selected model's processor.

func (*AnyToAnyPipeline) Validate added in v0.8.4

func (p *AnyToAnyPipeline) Validate() error

type AnyToAnyResult added in v0.8.4

type AnyToAnyResult struct {
	Text   string
	Images []image.Image
	Audio  *AudioWaveform
}

AnyToAnyResult owns a generated response. Audio samples use Audio.SampleRate; images are decoded RGB pixels. Model capabilities determine populated fields.

type AudioClassificationOutput added in v0.8.1

type AudioClassificationOutput struct {
	Predictions [][]AudioClassificationResult
}

func (*AudioClassificationOutput) GetOutput added in v0.8.1

func (o *AudioClassificationOutput) GetOutput() []any

type AudioClassificationPipeline added in v0.8.1

type AudioClassificationPipeline struct {
	*backends.BasePipeline
	IDLabelMap map[int]string
	Input      backends.InputOutputInfo
	TopK       int
	SampleRate int
}

AudioClassificationPipeline classifies mono audio waveforms.

func NewAudioClassificationPipeline added in v0.8.1

func NewAudioClassificationPipeline(ctx context.Context, config backends.PipelineConfig[*AudioClassificationPipeline], model *backends.Model) (*AudioClassificationPipeline, error)

func (*AudioClassificationPipeline) GetMetadata added in v0.8.1

func (*AudioClassificationPipeline) GetModel added in v0.8.1

func (*AudioClassificationPipeline) GetStatistics added in v0.8.1

func (*AudioClassificationPipeline) IsGenerative added in v0.8.1

func (p *AudioClassificationPipeline) IsGenerative() bool

func (*AudioClassificationPipeline) Run added in v0.8.1

Run executes the pipeline on PCM WAV file paths.

func (*AudioClassificationPipeline) RunFiles added in v0.8.1

func (*AudioClassificationPipeline) RunWaveforms added in v0.8.1

func (*AudioClassificationPipeline) RunWithAudio added in v0.8.1

RunWithAudio executes mono samples already sampled at the pipeline's configured SampleRate.

func (*AudioClassificationPipeline) Validate added in v0.8.1

func (p *AudioClassificationPipeline) Validate() error

type AudioClassificationResult added in v0.8.1

type AudioClassificationResult struct {
	Label      string
	Score      float32
	ClassIndex int
}

type AudioWaveform added in v0.8.1

type AudioWaveform struct {
	Samples    []float32
	SampleRate int
}

AudioWaveform is a mono waveform and its sampling rate. Samples are expected to be normalized to the range [-1, 1].

type AutomaticSpeechRecognitionOutput added in v0.8.1

type AutomaticSpeechRecognitionOutput struct {
	Text              []string
	Words             [][]string
	WordTimestamps    [][]ASRTimestamp
	SegmentTimestamps [][]ASRTimestamp
}

AutomaticSpeechRecognitionOutput contains one transcription per waveform.

func (*AutomaticSpeechRecognitionOutput) GetOutput added in v0.8.1

func (o *AutomaticSpeechRecognitionOutput) GetOutput() []any

type AutomaticSpeechRecognitionPipeline added in v0.8.1

type AutomaticSpeechRecognitionPipeline struct {
	*backends.BasePipeline
	IDLabelMap       map[int]string
	BlankID          int
	Input            backends.InputOutputInfo
	SampleRate       int
	Prompt           string
	StreamingOptions StreamingASROptions
}

AutomaticSpeechRecognitionPipeline recognizes speech with CTC or a GenAI model.

func (*AutomaticSpeechRecognitionPipeline) GetMetadata added in v0.8.1

func (*AutomaticSpeechRecognitionPipeline) GetModel added in v0.8.1

func (*AutomaticSpeechRecognitionPipeline) GetStatistics added in v0.8.1

func (*AutomaticSpeechRecognitionPipeline) IsGenerative added in v0.8.1

func (p *AutomaticSpeechRecognitionPipeline) IsGenerative() bool

func (*AutomaticSpeechRecognitionPipeline) Run added in v0.8.1

func (*AutomaticSpeechRecognitionPipeline) RunAudioStream added in v0.9.0

func (p *AutomaticSpeechRecognitionPipeline) RunAudioStream(ctx context.Context, chunks <-chan []float32) (<-chan backends.ASRResult, <-chan error, error)

RunAudioStream accepts mono PCM at SampleRate and emits incremental transcript fragments. Ownership of each chunk transfers to the pipeline; do not mutate it. Chunks larger than ChunkSamples are split automatically. Close chunks to flush the stream, and consume both output channels until closed. Cancel ctx to stop early.

func (*AutomaticSpeechRecognitionPipeline) RunFiles added in v0.8.1

func (*AutomaticSpeechRecognitionPipeline) RunWaveforms added in v0.8.1

func (*AutomaticSpeechRecognitionPipeline) RunWithAudio added in v0.8.1

RunWithAudio executes mono samples already sampled at the pipeline's configured SampleRate.

func (*AutomaticSpeechRecognitionPipeline) SupportsGenerativeModelLoading added in v0.8.6

func (*AutomaticSpeechRecognitionPipeline) SupportsGenerativeModelLoading() bool

SupportsGenerativeModelLoading allows callers to select GenAI explicitly while keeping ONNX/CTC as the default loading mode for this pipeline.

func (*AutomaticSpeechRecognitionPipeline) Validate added in v0.8.1

type BackgroundRemovalOutput added in v0.8.1

type BackgroundRemovalOutput struct{ Results []BackgroundRemovalResult }

func (*BackgroundRemovalOutput) GetOutput added in v0.8.1

func (o *BackgroundRemovalOutput) GetOutput() []any

type BackgroundRemovalPipeline added in v0.8.1

type BackgroundRemovalPipeline struct {
	*backends.BasePipeline

	OutputName string
	// contains filtered or unexported fields
}

BackgroundRemovalPipeline is a Hugot extension for foreground alpha prediction.

func NewBackgroundRemovalPipeline added in v0.8.1

func NewBackgroundRemovalPipeline(ctx context.Context, config backends.PipelineConfig[*BackgroundRemovalPipeline], model *backends.Model) (*BackgroundRemovalPipeline, error)

func (*BackgroundRemovalPipeline) GetMetadata added in v0.8.1

func (*BackgroundRemovalPipeline) GetModel added in v0.8.1

func (p *BackgroundRemovalPipeline) GetModel() *backends.Model

func (*BackgroundRemovalPipeline) GetStatistics added in v0.8.1

func (*BackgroundRemovalPipeline) IsGenerative added in v0.8.1

func (p *BackgroundRemovalPipeline) IsGenerative() bool

func (*BackgroundRemovalPipeline) Run added in v0.8.1

func (*BackgroundRemovalPipeline) RunPipeline added in v0.8.1

func (*BackgroundRemovalPipeline) RunWithImages added in v0.8.1

func (*BackgroundRemovalPipeline) Validate added in v0.8.1

func (p *BackgroundRemovalPipeline) Validate() error

type BackgroundRemovalResult added in v0.8.1

type BackgroundRemovalResult struct {
	Width, Height int
	Mask          [][]float32
}

type ClassificationOutput

type ClassificationOutput struct {
	Label string
	Score float32
}

type CrossEncoderOutput added in v0.5.0

type CrossEncoderOutput struct {
	Results []CrossEncoderResult
}

func (*CrossEncoderOutput) GetOutput added in v0.5.0

func (t *CrossEncoderOutput) GetOutput() []any

type CrossEncoderPipeline added in v0.5.0

type CrossEncoderPipeline struct {
	*backends.BasePipeline
	// contains filtered or unexported fields
}

func NewCrossEncoderPipeline added in v0.5.0

func NewCrossEncoderPipeline(sessionContext context.Context, config backends.PipelineConfig[*CrossEncoderPipeline], model *backends.Model) (*CrossEncoderPipeline, error)

func (*CrossEncoderPipeline) GetMetadata added in v0.5.0

func (*CrossEncoderPipeline) GetModel added in v0.5.0

func (p *CrossEncoderPipeline) GetModel() *backends.Model

func (*CrossEncoderPipeline) GetStatistics added in v0.5.9

func (*CrossEncoderPipeline) IsGenerative added in v0.6.0

func (p *CrossEncoderPipeline) IsGenerative() bool

func (*CrossEncoderPipeline) Run added in v0.5.0

func (*CrossEncoderPipeline) RunPipeline added in v0.5.0

func (p *CrossEncoderPipeline) RunPipeline(ctx context.Context, query string, documents []string) (*CrossEncoderOutput, error)

func (*CrossEncoderPipeline) Validate added in v0.5.0

func (p *CrossEncoderPipeline) Validate() error

type CrossEncoderResult added in v0.5.0

type CrossEncoderResult struct {
	Document string
	Score    float32
	Index    int
}

type CrossEncoderStatistics added in v0.5.9

type CrossEncoderStatistics struct {
	TotalQueries     uint64
	TotalDocuments   uint64
	AverageLatency   time.Duration
	AverageBatchSize float64
	FilteredResults  uint64
}

type DecisionAnswer added in v0.8.6

type DecisionAnswer struct {
	Type DecisionQuestionType
	// Probabilities over the options, keyed by option name: "false"/"true" for noul,
	// the option names for choice, the level index ("0", "1", ...) for score.
	Probabilities map[string]float64
	// Noul is P(true), set for noul questions.
	Noul float64
	// Choice is the most probable option, set for choice questions.
	Choice string
	// Score is the expected level index, set for score questions.
	Score float64
	// Confidence is 0 for a uniform and 1 for a one-hot distribution (choice), or how
	// tightly the mass clusters on the scale (score). Noul has none: P(true) is it.
	Confidence float64
}

DecisionAnswer is the model's answer to one question.

type DecisionCriterion added in v0.8.6

type DecisionCriterion struct {
	Name        string
	Description string
}

DecisionCriterion is one option of a question.

For a choice question, Name is the option's label and Description is optional. For a score question, Description is the level's rubric; Name is ignored, since levels are numbered 0..L-1 lowest first. For a noul question, criteria are optional and override the default description of "false" and/or "true" by Name.

type DecisionInput added in v0.8.6

type DecisionInput struct {
	State     string
	Questions map[string]DecisionQuestion
}

DecisionInput is a state and the questions to ask of it. Use RenderDecisionState to turn a structured state into text.

type DecisionOutput added in v0.8.6

type DecisionOutput struct {
	Results []DecisionResult
}

DecisionOutput holds one result per input, in input order.

func (*DecisionOutput) GetOutput added in v0.8.6

func (o *DecisionOutput) GetOutput() []any

type DecisionPipeline added in v0.8.6

type DecisionPipeline struct {
	*backends.BasePipeline
	// Questions are asked of every input passed to Run.
	Questions map[string]DecisionQuestion
	// MaxBatchRows caps how many (state, question) rows run in one forward pass.
	MaxBatchRows int
	// MaxBatchTokens caps a forward pass's padded size (rows x longest row), so a long
	// state is not batched with short ones it would pad to its own length. A row longer
	// than the budget still runs, alone.
	MaxBatchTokens int
	Config         DecisionReadoutConfig
	// contains filtered or unexported fields
}

DecisionPipeline runs decision models ("system one" models, as served behind the Jev API): instead of generating text, the model answers typed questions about a state (a text, or JSON). The question types are noul (yes/no), choice (one of N named options) and score (a level on an ordered scale). Options are given at request time, so any label set works without retraining.

The ONNX graph takes input_ids, attention_mask and option_index ([batch, options], the position of each option's last token) and returns per-option logits ([batch, options]); temperature, softmax and confidence are applied here. Prompt rendering follows the model's format; the Strands format (the strands* declarations at the end of this file) is the one supported today.

func NewDecisionPipeline added in v0.8.6

func NewDecisionPipeline(ctx context.Context, config backends.PipelineConfig[*DecisionPipeline], model *backends.Model) (*DecisionPipeline, error)

func (*DecisionPipeline) GetMetadata added in v0.8.6

func (p *DecisionPipeline) GetMetadata() backends.PipelineMetadata

func (*DecisionPipeline) GetModel added in v0.8.6

func (p *DecisionPipeline) GetModel() *backends.Model

func (*DecisionPipeline) GetStatistics added in v0.8.6

func (p *DecisionPipeline) GetStatistics() backends.PipelineStatistics

func (*DecisionPipeline) IsGenerative added in v0.8.6

func (*DecisionPipeline) IsGenerative() bool

func (*DecisionPipeline) Run added in v0.8.6

Run asks the pipeline's configured questions (WithDecisionQuestions) of each input.

func (*DecisionPipeline) RunPipeline added in v0.8.6

func (p *DecisionPipeline) RunPipeline(ctx context.Context, inputs []DecisionInput) (*DecisionOutput, error)

RunPipeline answers each input's questions. Every (state, question) pair is one row; rows of similar length are batched together.

func (*DecisionPipeline) Validate added in v0.8.6

func (p *DecisionPipeline) Validate() error

type DecisionQuestion added in v0.8.6

type DecisionQuestion struct {
	Type         DecisionQuestionType
	Instructions string
	Criteria     []DecisionCriterion
}

DecisionQuestion is one question asked of a state.

type DecisionQuestionType added in v0.8.6

type DecisionQuestionType string

DecisionQuestionType is one of the three decision primitives.

const (
	// DecisionNoul is a yes/no question: is the statement true of the state?
	DecisionNoul DecisionQuestionType = "noul"
	// DecisionChoice selects exactly one of N named options.
	DecisionChoice DecisionQuestionType = "choice"
	// DecisionScore rates the state on an ordered scale of 2 to 10 levels.
	DecisionScore DecisionQuestionType = "score"
)

type DecisionReadoutConfig added in v0.8.6

type DecisionReadoutConfig struct {
	Temperature       float64            `json:"temperature"`
	TemperatureByKind map[string]float64 `json:"temperature_by_kind"`
	OrdinalSmoothing  float64            `json:"ordinal_smoothing"`
	MaxLength         int                `json:"max_length"`
	ForceBOS          bool               `json:"force_bos"`
	HeadType          string             `json:"head_type"`
}

DecisionReadoutConfig holds the readout settings a decision model ships with: the fitted temperature per question type, the ordinal smoothing the score confidence corrects for, and the context length. Strands models ship it as strands_decider_config.json.

type DecisionResult added in v0.8.6

type DecisionResult struct {
	Answers map[string]DecisionAnswer
}

DecisionResult holds one input's answers, keyed by question name.

type DepthEstimationConfig added in v0.8.1

type DepthEstimationConfig = backends.PipelineConfig[*DepthEstimationPipeline]

type DepthEstimationOption added in v0.8.1

type DepthEstimationOption = backends.PipelineOption[*DepthEstimationPipeline]

func WithDepthEstimationOutput added in v0.8.1

func WithDepthEstimationOutput(name string) DepthEstimationOption

WithDepthEstimationOutput is an explicit-name alias for WithDepthOutput.

func WithDepthOutput added in v0.8.1

func WithDepthOutput(name string) DepthEstimationOption

WithDepthOutput selects the model output containing predicted depth values.

type DepthEstimationOutput added in v0.8.1

type DepthEstimationOutput struct {
	Results []DepthEstimationResult
}

func (*DepthEstimationOutput) GetOutput added in v0.8.1

func (o *DepthEstimationOutput) GetOutput() []any

type DepthEstimationPipeline added in v0.8.1

type DepthEstimationPipeline struct {
	*backends.BasePipeline

	DepthOutput string
	// contains filtered or unexported fields
}

DepthEstimationPipeline estimates one depth value for each source-image pixel.

func NewDepthEstimationPipeline added in v0.8.1

func NewDepthEstimationPipeline(ctx context.Context, config DepthEstimationConfig, model *backends.Model) (*DepthEstimationPipeline, error)

func (*DepthEstimationPipeline) GetMetadata added in v0.8.1

func (*DepthEstimationPipeline) GetModel added in v0.8.1

func (p *DepthEstimationPipeline) GetModel() *backends.Model

func (*DepthEstimationPipeline) GetStatistics added in v0.8.1

func (*DepthEstimationPipeline) IsGenerative added in v0.8.1

func (p *DepthEstimationPipeline) IsGenerative() bool

func (*DepthEstimationPipeline) Run added in v0.8.1

func (*DepthEstimationPipeline) RunPipeline added in v0.8.1

func (p *DepthEstimationPipeline) RunPipeline(ctx context.Context, inputs []string) (*DepthEstimationOutput, error)

func (*DepthEstimationPipeline) RunWithImagePaths added in v0.8.1

func (p *DepthEstimationPipeline) RunWithImagePaths(ctx context.Context, paths []string) (*DepthEstimationOutput, error)

func (*DepthEstimationPipeline) RunWithImages added in v0.8.1

func (p *DepthEstimationPipeline) RunWithImages(ctx context.Context, images []image.Image) (*DepthEstimationOutput, error)

func (*DepthEstimationPipeline) Validate added in v0.8.1

func (p *DepthEstimationPipeline) Validate() error

type DepthEstimationResult added in v0.8.1

type DepthEstimationResult struct {
	Width    int
	Height   int
	DepthMap [][]float32
}

type Detection added in v0.6.0

type Detection struct {
	Label string
	Class int
	Box   [4]float32 // [xmin, ymin, xmax, ymax] in pixels
	Score float32
}

type DocumentQuestionAnsweringConfig added in v0.8.1

type DocumentQuestionAnsweringConfig = backends.PipelineConfig[*DocumentQuestionAnsweringPipeline]

type DocumentQuestionAnsweringInput added in v0.8.1

type DocumentQuestionAnsweringInput struct {
	DocumentPath string
	ImagePath    string
	Question     string
	Role         string
	History      []backends.Message
}

DocumentQuestionAnsweringInput pairs a document with a question. Native Donut inference uses DocumentPath (or ImagePath as a fallback) and Question.

type DocumentQuestionAnsweringOption added in v0.8.1

type DocumentQuestionAnsweringOption = backends.PipelineOption[*DocumentQuestionAnsweringPipeline]

func WithDocumentQuestionAnsweringMaxLength added in v0.8.1

func WithDocumentQuestionAnsweringMaxLength(n int) DocumentQuestionAnsweringOption

func WithDocumentQuestionAnsweringStreaming added in v0.8.1

func WithDocumentQuestionAnsweringStreaming() DocumentQuestionAnsweringOption

type DocumentQuestionAnsweringOutput added in v0.8.1

type DocumentQuestionAnsweringOutput struct {
	Results []DocumentQuestionAnsweringResult
}

func (*DocumentQuestionAnsweringOutput) GetOutput added in v0.8.2

func (o *DocumentQuestionAnsweringOutput) GetOutput() []any

type DocumentQuestionAnsweringPipeline added in v0.8.1

type DocumentQuestionAnsweringPipeline struct {
	*backends.BasePipeline
	Decoder         *backends.Model
	DecoderFilename string
	MaxLength       int
	// contains filtered or unexported fields
}

DocumentQuestionAnsweringPipeline runs a Donut DocVQA encoder/decoder. It is not an ORT GenAI conversational pipeline.

func NewDocumentQuestionAnsweringPipeline added in v0.8.1

func NewDocumentQuestionAnsweringPipeline(ctx context.Context, config DocumentQuestionAnsweringConfig, model *backends.Model) (*DocumentQuestionAnsweringPipeline, error)

func (*DocumentQuestionAnsweringPipeline) GetMetadata added in v0.8.2

func (*DocumentQuestionAnsweringPipeline) GetModel added in v0.8.2

func (*DocumentQuestionAnsweringPipeline) GetStatistics added in v0.8.2

func (*DocumentQuestionAnsweringPipeline) IsGenerative added in v0.8.1

func (*DocumentQuestionAnsweringPipeline) IsGenerative() bool

func (*DocumentQuestionAnsweringPipeline) Run added in v0.8.1

func (*DocumentQuestionAnsweringPipeline) RunPipeline added in v0.8.1

func (*DocumentQuestionAnsweringPipeline) RunWithImages added in v0.8.1

func (*DocumentQuestionAnsweringPipeline) Validate added in v0.8.1

type DocumentQuestionAnsweringResult added in v0.8.2

type DocumentQuestionAnsweringResult struct{ Answer string }

type Entity added in v0.0.5

type Entity struct {
	Entity    string
	Word      string
	Scores    []float32
	TokenIDs  []uint32
	Index     int
	Start     uint
	End       uint
	Score     float32
	IsSubword bool
}

type FFmpegVideoDecoder added in v0.8.4

type FFmpegVideoDecoder struct {
	FFmpegPath  string
	FFprobePath string
}

FFmpegVideoDecoder is an optional file decoder. FFmpegPath and FFprobePath default to ffmpeg and ffprobe on PATH. No codec library is linked into Hugot.

func (FFmpegVideoDecoder) Decode added in v0.8.4

func (d FFmpegVideoDecoder) Decode(ctx context.Context, path string, maxFrames int) (VideoInput, error)

type FeatureExtractionOutput

type FeatureExtractionOutput struct {
	Embeddings [][]float32
}

func (*FeatureExtractionOutput) GetOutput added in v0.0.5

func (t *FeatureExtractionOutput) GetOutput() []any

type FeatureExtractionPipeline

type FeatureExtractionPipeline struct {
	*backends.BasePipeline
	OutputName string

	Output backends.InputOutputInfo

	OutputIndex   int // Record the index of the output selected, defaults to first (0)
	Normalization bool
	// contains filtered or unexported fields
}

FeatureExtractionPipeline A feature extraction pipeline is a go version of https://github.com/huggingface/transformers/blob/main/src/transformers/pipelines/feature_extraction.py It supports both text and image inputs for embedding extraction.

func NewFeatureExtractionPipeline

func NewFeatureExtractionPipeline(sessionContext context.Context, config backends.PipelineConfig[*FeatureExtractionPipeline], model *backends.Model) (*FeatureExtractionPipeline, error)

NewFeatureExtractionPipeline init a feature extraction pipeline.

func (*FeatureExtractionPipeline) GetMetadata added in v0.1.4

GetMetadata returns metadata information about the pipeline, in particular: OutputInfo: names and dimensions of the output layer.

func (*FeatureExtractionPipeline) GetModel added in v0.3.0

func (p *FeatureExtractionPipeline) GetModel() *backends.Model

func (*FeatureExtractionPipeline) GetStatistics added in v0.5.9

GetStatistics returns the runtime statistics for the pipeline.

func (*FeatureExtractionPipeline) IsGenerative added in v0.6.0

func (p *FeatureExtractionPipeline) IsGenerative() bool

func (*FeatureExtractionPipeline) PreprocessImages added in v0.6.0

func (p *FeatureExtractionPipeline) PreprocessImages(batch *backends.PipelineBatch, inputs []image.Image) error

PreprocessImages converts images to input tensors for vision models.

func (*FeatureExtractionPipeline) Run

Run the pipeline on a batch of strings.

func (*FeatureExtractionPipeline) RunPipeline added in v0.0.6

RunPipeline is like Run, but returns the concrete feature extraction output type rather than the interface.

func (*FeatureExtractionPipeline) RunRaw added in v0.8.2

RunRaw returns unpooled, unnormalized text features, including padding tokens.

func (*FeatureExtractionPipeline) RunRawWithImagePaths added in v0.8.2

func (p *FeatureExtractionPipeline) RunRawWithImagePaths(ctx context.Context, paths []string) (*RawFeatureOutput, error)

RunRawWithImagePaths loads images and returns their raw features.

func (*FeatureExtractionPipeline) RunRawWithImages added in v0.8.2

func (p *FeatureExtractionPipeline) RunRawWithImages(ctx context.Context, images []image.Image) (*RawFeatureOutput, error)

RunRawWithImages returns the selected image tensor without pooling or normalization.

func (*FeatureExtractionPipeline) RunWithImagePaths added in v0.6.0

func (p *FeatureExtractionPipeline) RunWithImagePaths(ctx context.Context, paths []string) (*FeatureExtractionOutput, error)

RunWithImagePaths loads images from file paths and runs the pipeline. Convenience method that combines image loading with RunWithImages.

func (*FeatureExtractionPipeline) RunWithImages added in v0.6.0

RunWithImages runs the pipeline on a batch of images (for vision models). Use this method when ImageMode is enabled.

func (*FeatureExtractionPipeline) Validate added in v0.0.5

func (p *FeatureExtractionPipeline) Validate() error

Validate checks that the pipeline is valid.

type FillMaskOutput added in v0.8.1

type FillMaskOutput struct {
	Predictions [][]FillMaskResult
}

func (*FillMaskOutput) GetOutput added in v0.8.1

func (o *FillMaskOutput) GetOutput() []any

type FillMaskPipeline added in v0.8.1

type FillMaskPipeline struct {
	*backends.BasePipeline
	TopK      int
	MaskToken string
}

FillMaskPipeline predicts replacements for a single mask token in each input.

func NewFillMaskPipeline added in v0.8.1

func NewFillMaskPipeline(ctx context.Context, config backends.PipelineConfig[*FillMaskPipeline], model *backends.Model) (*FillMaskPipeline, error)

func (*FillMaskPipeline) GetMetadata added in v0.8.1

func (p *FillMaskPipeline) GetMetadata() backends.PipelineMetadata

func (*FillMaskPipeline) GetModel added in v0.8.1

func (p *FillMaskPipeline) GetModel() *backends.Model

func (*FillMaskPipeline) GetStatistics added in v0.8.1

func (p *FillMaskPipeline) GetStatistics() backends.PipelineStatistics

func (*FillMaskPipeline) IsGenerative added in v0.8.1

func (p *FillMaskPipeline) IsGenerative() bool

func (*FillMaskPipeline) Run added in v0.8.1

func (*FillMaskPipeline) RunPipeline added in v0.8.1

func (p *FillMaskPipeline) RunPipeline(ctx context.Context, inputs []string) (*FillMaskOutput, error)

func (*FillMaskPipeline) Validate added in v0.8.1

func (p *FillMaskPipeline) Validate() error

type FillMaskResult added in v0.8.1

type FillMaskResult struct {
	Token    string
	TokenID  int
	Sequence string
	Score    float32
}

type GroundedObjectDetectionPipeline added in v0.8.3

type GroundedObjectDetectionPipeline struct {
	*backends.BasePipeline
	BoxThreshold  float32
	TextThreshold float32
}

GroundedObjectDetectionPipeline runs a caption-prompted detector such as Grounding DINO. One caption is encoded with the image. Labels come from the tokens whose class probability clears the text threshold.

func (*GroundedObjectDetectionPipeline) GetMetadata added in v0.8.3

func (*GroundedObjectDetectionPipeline) GetModel added in v0.8.3

func (*GroundedObjectDetectionPipeline) GetStatistics added in v0.8.3

func (*GroundedObjectDetectionPipeline) IsGenerative added in v0.8.3

func (*GroundedObjectDetectionPipeline) IsGenerative() bool

func (*GroundedObjectDetectionPipeline) Run added in v0.8.3

Run is unavailable because []string cannot carry the caption. Use RunWithCaption.

func (*GroundedObjectDetectionPipeline) RunWithCaption added in v0.8.3

func (p *GroundedObjectDetectionPipeline) RunWithCaption(ctx context.Context, inputs []string, caption string) (*ObjectDetectionOutput, error)

func (*GroundedObjectDetectionPipeline) RunWithImagesAndCaption added in v0.8.3

func (p *GroundedObjectDetectionPipeline) RunWithImagesAndCaption(ctx context.Context, images []image.Image, caption string) (*ObjectDetectionOutput, error)

func (*GroundedObjectDetectionPipeline) Validate added in v0.8.3

func (p *GroundedObjectDetectionPipeline) Validate() error

type ImageClassificationOutput added in v0.5.0

type ImageClassificationOutput struct {
	Predictions [][]ImageClassificationResult // batch of results
}

func (*ImageClassificationOutput) GetOutput added in v0.5.0

func (o *ImageClassificationOutput) GetOutput() []any

type ImageClassificationPipeline added in v0.5.0

type ImageClassificationPipeline struct {
	*backends.BasePipeline
	IDLabelMap map[int]string

	Output backends.InputOutputInfo

	TopK int
	// contains filtered or unexported fields
}

ImageClassificationPipeline is a go version of https://github.com/huggingface/transformers/blob/main/src/transformers/pipelines/image_classification.py It takes images (as file paths or image.Image) and returns top-k class predictions.

func NewImageClassificationPipeline added in v0.5.0

func NewImageClassificationPipeline(sessionContext context.Context, config backends.PipelineConfig[*ImageClassificationPipeline], model *backends.Model) (*ImageClassificationPipeline, error)

NewImageClassificationPipeline initializes an image classification pipeline.

func (*ImageClassificationPipeline) GetMetadata added in v0.5.0

func (*ImageClassificationPipeline) GetModel added in v0.5.0

func (*ImageClassificationPipeline) GetStatistics added in v0.5.9

func (*ImageClassificationPipeline) IsGenerative added in v0.6.0

func (p *ImageClassificationPipeline) IsGenerative() bool

func (*ImageClassificationPipeline) Run added in v0.5.0

Run runs the pipeline on a batch of image file paths.

func (*ImageClassificationPipeline) RunPipeline added in v0.5.0

RunPipeline returns the concrete output type.

func (*ImageClassificationPipeline) RunWithImages added in v0.5.0

func (*ImageClassificationPipeline) Validate added in v0.5.0

func (p *ImageClassificationPipeline) Validate() error

type ImageClassificationResult added in v0.5.0

type ImageClassificationResult struct {
	Label      string
	Score      float32
	ClassIndex int
}

type ImageFeatureExtractionOutput added in v0.8.1

type ImageFeatureExtractionOutput struct{ Embeddings [][]float32 }

func (*ImageFeatureExtractionOutput) GetOutput added in v0.8.1

func (o *ImageFeatureExtractionOutput) GetOutput() []any

type ImageFeatureExtractionPipeline added in v0.8.1

type ImageFeatureExtractionPipeline struct {
	*backends.BasePipeline

	OutputIndex   int
	Normalization bool
	// contains filtered or unexported fields
}

ImageFeatureExtractionPipeline returns one pooled embedding per image.

func (*ImageFeatureExtractionPipeline) GetMetadata added in v0.8.1

func (*ImageFeatureExtractionPipeline) GetModel added in v0.8.1

func (*ImageFeatureExtractionPipeline) GetStatistics added in v0.8.1

func (*ImageFeatureExtractionPipeline) IsGenerative added in v0.8.1

func (p *ImageFeatureExtractionPipeline) IsGenerative() bool

func (*ImageFeatureExtractionPipeline) Run added in v0.8.1

func (*ImageFeatureExtractionPipeline) RunPipeline added in v0.8.1

func (*ImageFeatureExtractionPipeline) RunRaw added in v0.8.2

RunRaw loads image paths and returns unpooled, unnormalized model features.

func (*ImageFeatureExtractionPipeline) RunRawWithImages added in v0.8.2

func (p *ImageFeatureExtractionPipeline) RunRawWithImages(ctx context.Context, images []image.Image) (*RawFeatureOutput, error)

RunRawWithImages retains the batch, sequence and hidden dimensions of image features.

func (*ImageFeatureExtractionPipeline) RunWithImages added in v0.8.1

func (*ImageFeatureExtractionPipeline) Validate added in v0.8.1

func (p *ImageFeatureExtractionPipeline) Validate() error

type ImagePair added in v0.8.4

type ImagePair struct {
	Images [2]image.Image `json:"-"`
	Paths  [2]string      `json:"paths"`
}

ImagePair keeps pair boundaries explicit. Each side must supply exactly one decoded image or path. Images may have different original dimensions.

type ImageSegmentationOutput added in v0.8.1

type ImageSegmentationOutput struct {
	Results []ImageSegmentationResult
}

func (*ImageSegmentationOutput) GetOutput added in v0.8.1

func (o *ImageSegmentationOutput) GetOutput() []any

type ImageSegmentationPipeline added in v0.8.1

type ImageSegmentationPipeline struct {
	*backends.BasePipeline
	IDLabelMap map[int]string

	LogitsOutput   string
	ScoreThreshold float32
	// contains filtered or unexported fields
}

ImageSegmentationPipeline decodes semantic segmentation logits into masks in the coordinate space of the source image.

func NewImageSegmentationPipeline added in v0.8.1

func NewImageSegmentationPipeline(ctx context.Context, config backends.PipelineConfig[*ImageSegmentationPipeline], model *backends.Model) (*ImageSegmentationPipeline, error)

func (*ImageSegmentationPipeline) GetMetadata added in v0.8.1

func (*ImageSegmentationPipeline) GetModel added in v0.8.1

func (p *ImageSegmentationPipeline) GetModel() *backends.Model

func (*ImageSegmentationPipeline) GetStatistics added in v0.8.1

func (*ImageSegmentationPipeline) IsGenerative added in v0.8.1

func (p *ImageSegmentationPipeline) IsGenerative() bool

func (*ImageSegmentationPipeline) Run added in v0.8.1

func (*ImageSegmentationPipeline) RunPipeline added in v0.8.1

func (*ImageSegmentationPipeline) RunWithImages added in v0.8.1

func (*ImageSegmentationPipeline) Validate added in v0.8.1

func (p *ImageSegmentationPipeline) Validate() error

type ImageSegmentationResult added in v0.8.1

type ImageSegmentationResult struct {
	Width    int
	Height   int
	Segments []ImageSegmentationSegment
}

type ImageSegmentationSegment added in v0.8.1

type ImageSegmentationSegment struct {
	Label string
	Class int
	Score float32
	Mask  [][]bool
}

type ImageTextPrompt added in v0.8.1

type ImageTextPrompt struct {
	ImagePath string
	Prompt    string
	Role      string
	History   []backends.Message
}

ImageTextPrompt pairs an image file (or data URI) with a prompt.

By default (all zero values, as before) a prompt describes a single user turn: the pipeline sends one message with Role "user", the Prompt as its content, and ImagePath as the attached image. That keeps the one-shot image+text->text workflows backward compatible.

For multi-turn image/text conversations, set Role to the role the final (image) turn should carry, and add History for any previous turns in this conversation. They are emitted in order — History, then the final image turn — so the underlying backend sees a full, correctly labelled conversation. If a per-conversation system turn is needed, put it in History[0]; the pipeline-level SystemPrompt on the pipeline struct (set once at construction) is still applied globally by the backend.

type ImageTextToTextConfig added in v0.8.1

type ImageTextToTextConfig = backends.PipelineConfig[*ImageTextToTextPipeline]

type ImageTextToTextOption added in v0.8.1

type ImageTextToTextOption = backends.PipelineOption[*ImageTextToTextPipeline]

func WithImageTextToTextGuidance added in v0.8.4

func WithImageTextToTextGuidance(guidance *backends.Guidance) ImageTextToTextOption

WithImageTextToTextGuidance enables constrained text generation using a JSON schema, regex, or Lark grammar supported by the selected ORT GenAI session.

func WithImageTextToTextMaxLength added in v0.8.1

func WithImageTextToTextMaxLength(n int) ImageTextToTextOption

func WithImageTextToTextStreaming added in v0.8.1

func WithImageTextToTextStreaming() ImageTextToTextOption

func WithImageTextToTextTools added in v0.8.4

func WithImageTextToTextTools(tools []string) ImageTextToTextOption

WithImageTextToTextTools sets Hermes-style tool definitions for the chat template. The pipeline returns generated tool-call text; applications execute tools themselves.

type ImageTextToTextPipeline added in v0.8.1

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

func NewImageTextToTextPipeline added in v0.8.1

func NewImageTextToTextPipeline(ctx context.Context, config ImageTextToTextConfig, model *backends.Model) (*ImageTextToTextPipeline, error)

func (ImageTextToTextPipeline) GetMetadata added in v0.8.1

func (p ImageTextToTextPipeline) GetMetadata() backends.PipelineMetadata

func (ImageTextToTextPipeline) GetModel added in v0.8.1

func (p ImageTextToTextPipeline) GetModel() *backends.Model

func (ImageTextToTextPipeline) GetStatistics added in v0.8.1

func (p ImageTextToTextPipeline) GetStatistics() backends.PipelineStatistics

func (*ImageTextToTextPipeline) IsGenerative added in v0.8.1

func (*ImageTextToTextPipeline) IsGenerative() bool

func (*ImageTextToTextPipeline) Run added in v0.8.1

func (*ImageTextToTextPipeline) RunWithImages added in v0.8.1

func (ImageTextToTextPipeline) Validate added in v0.8.1

func (p ImageTextToTextPipeline) Validate() error

type Keypoint added in v0.8.4

type Keypoint struct {
	X int `json:"x"`
	Y int `json:"y"`
}

type KeypointMatch added in v0.8.4

type KeypointMatch struct {
	KeypointImage0 Keypoint `json:"keypoint_image_0"`
	KeypointImage1 Keypoint `json:"keypoint_image_1"`
	Score          float32  `json:"score"`
}

type KeypointMatchingConfig added in v0.8.4

type KeypointMatchingConfig = backends.PipelineConfig[*KeypointMatchingPipeline]

type KeypointMatchingOption added in v0.8.4

type KeypointMatchingOption = backends.PipelineOption[*KeypointMatchingPipeline]

func WithKeypointMatchingThreshold added in v0.8.4

func WithKeypointMatchingThreshold(threshold float32) KeypointMatchingOption

type KeypointMatchingOutput added in v0.8.4

type KeypointMatchingOutput struct{ Matches [][]KeypointMatch }

func (*KeypointMatchingOutput) GetOutput added in v0.8.4

func (o *KeypointMatchingOutput) GetOutput() []any

type KeypointMatchingPipeline added in v0.8.4

type KeypointMatchingPipeline struct {
	*backends.BasePipeline
	Threshold float32
	// contains filtered or unexported fields
}

KeypointMatchingPipeline accepts the dense/padded FP32 SuperGlue export contract. Dynamic keypoint counts are read from runtime output shapes.

func NewKeypointMatchingPipeline added in v0.8.4

func NewKeypointMatchingPipeline(ctx context.Context, config KeypointMatchingConfig, model *backends.Model) (*KeypointMatchingPipeline, error)

func (*KeypointMatchingPipeline) GetMetadata added in v0.8.4

func (*KeypointMatchingPipeline) GetModel added in v0.8.4

func (p *KeypointMatchingPipeline) GetModel() *backends.Model

func (*KeypointMatchingPipeline) GetStatistics added in v0.8.4

func (*KeypointMatchingPipeline) IsGenerative added in v0.8.4

func (*KeypointMatchingPipeline) IsGenerative() bool

func (*KeypointMatchingPipeline) Run added in v0.8.4

Run accepts one JSON ImagePair per string, e.g. {"paths":["a.png","b.png"]}.

func (*KeypointMatchingPipeline) RunPairs added in v0.8.4

func (*KeypointMatchingPipeline) Validate added in v0.8.4

func (p *KeypointMatchingPipeline) Validate() error

type MaskGenerationMask added in v0.8.1

type MaskGenerationMask struct {
	Mask  [][]bool
	Score float32
	// PredictedIOU is SAM's unbounded regression output; Score is clipped to [0,1].
	PredictedIOU   float32
	StabilityScore float32
	Box            [4]int
	Area           int
}

type MaskGenerationOutput added in v0.8.1

type MaskGenerationOutput struct{ Results []MaskGenerationResult }

func (*MaskGenerationOutput) GetOutput added in v0.8.2

func (o *MaskGenerationOutput) GetOutput() []any

type MaskGenerationPipeline added in v0.8.1

type MaskGenerationPipeline struct {
	*backends.BasePipeline
	Decoder                                                                  *backends.Model
	DecoderFilename                                                          string
	PointsPerSide, PointsPerBatch                                            int
	PredictedIOUThreshold, StabilityThreshold, StabilityOffset, NMSThreshold float32
	// contains filtered or unexported fields
}

MaskGenerationPipeline generates automatic SAM proposals, not semantic classes.

func NewMaskGenerationPipeline added in v0.8.1

func NewMaskGenerationPipeline(ctx context.Context, config backends.PipelineConfig[*MaskGenerationPipeline], model *backends.Model) (*MaskGenerationPipeline, error)

func (*MaskGenerationPipeline) GetMetadata added in v0.8.2

func (*MaskGenerationPipeline) GetModel added in v0.8.2

func (p *MaskGenerationPipeline) GetModel() *backends.Model

func (*MaskGenerationPipeline) GetStatistics added in v0.8.2

func (*MaskGenerationPipeline) IsGenerative added in v0.8.1

func (*MaskGenerationPipeline) IsGenerative() bool

func (*MaskGenerationPipeline) Run added in v0.8.1

func (*MaskGenerationPipeline) RunPipeline added in v0.8.1

func (p *MaskGenerationPipeline) RunPipeline(ctx context.Context, inputs []string) (*MaskGenerationOutput, error)

func (*MaskGenerationPipeline) RunWithBoxes added in v0.8.3

func (p *MaskGenerationPipeline) RunWithBoxes(ctx context.Context, img image.Image, boxes [][4]float32) (*MaskGenerationOutput, error)

RunWithBoxes prompts one SAM2 image with source-pixel xyxy boxes. Every decoder mask is returned with its IoU. SlimSAM has no box input.

func (*MaskGenerationPipeline) RunWithImages added in v0.8.1

func (p *MaskGenerationPipeline) RunWithImages(ctx context.Context, images []image.Image) (*MaskGenerationOutput, error)

func (*MaskGenerationPipeline) RunWithPoints added in v0.8.3

func (p *MaskGenerationPipeline) RunWithPoints(ctx context.Context, img image.Image, points [][2]float32, labels []int64) (*MaskGenerationOutput, error)

RunWithPoints prompts one SAM2 image with one object. Labels are 1 for a foreground point and 0 for background. Points are source-pixel xy. Every decoder mask is returned with its IoU.

func (*MaskGenerationPipeline) Validate added in v0.8.2

func (p *MaskGenerationPipeline) Validate() error

type MaskGenerationResult added in v0.8.1

type MaskGenerationResult struct {
	Width, Height int
	Masks         []MaskGenerationMask
}

type MultimodalContent added in v0.8.4

type MultimodalContent struct {
	Type  string      `json:"type"`
	Text  string      `json:"text,omitempty"`
	URL   string      `json:"url,omitempty"`
	Video *VideoInput `json:"-"`
}

MultimodalContent is one ordered text, image, audio or video item. Media URLs are paths (images also accept data URIs). Decoded videos use Video instead of URL. Phi-4 receives video as ordered images annotated with their timestamps.

type MultimodalMessage added in v0.8.4

type MultimodalMessage struct {
	Role    string              `json:"role"`
	Content []MultimodalContent `json:"content"`
}

type MultimodalTextOutput added in v0.8.1

type MultimodalTextOutput struct {
	Responses   []string
	TokenStream chan backends.SequenceDelta
	ErrorStream chan error
}

func (*MultimodalTextOutput) GetOutput added in v0.8.1

func (o *MultimodalTextOutput) GetOutput() []any

type ObjectDetectionOutput added in v0.6.0

type ObjectDetectionOutput struct {
	Detections [][]Detection
}

func (*ObjectDetectionOutput) GetOutput added in v0.6.0

func (o *ObjectDetectionOutput) GetOutput() []any

type ObjectDetectionPipeline added in v0.6.0

type ObjectDetectionPipeline struct {
	*backends.BasePipeline
	IDLabelMap map[int]string

	BoxesOutput  string
	ScoresOutput string

	TopK           int
	ScoreThreshold float32
	IouThreshold   float32
	// contains filtered or unexported fields
}

ObjectDetectionPipeline implements a Hugging Face-like object detection pipeline. It supports models that output bounding boxes and class scores.

func NewObjectDetectionPipeline added in v0.6.0

func NewObjectDetectionPipeline(sessionContext context.Context, config backends.PipelineConfig[*ObjectDetectionPipeline], model *backends.Model) (*ObjectDetectionPipeline, error)

NewObjectDetectionPipeline initializes an object detection pipeline.

func (*ObjectDetectionPipeline) GetMetadata added in v0.6.0

func (*ObjectDetectionPipeline) GetModel added in v0.6.0

func (p *ObjectDetectionPipeline) GetModel() *backends.Model

func (*ObjectDetectionPipeline) GetStatistics added in v0.6.0

func (*ObjectDetectionPipeline) GetStats added in v0.6.0

func (p *ObjectDetectionPipeline) GetStats() []string

func (*ObjectDetectionPipeline) IsGenerative added in v0.6.0

func (p *ObjectDetectionPipeline) IsGenerative() bool

func (*ObjectDetectionPipeline) Run added in v0.6.0

Run with file paths.

func (*ObjectDetectionPipeline) RunPipeline added in v0.6.0

func (p *ObjectDetectionPipeline) RunPipeline(ctx context.Context, inputs []string) (*ObjectDetectionOutput, error)

func (*ObjectDetectionPipeline) RunWithImages added in v0.6.0

func (p *ObjectDetectionPipeline) RunWithImages(ctx context.Context, inputs []image.Image) (*ObjectDetectionOutput, error)

func (*ObjectDetectionPipeline) Validate added in v0.6.0

func (p *ObjectDetectionPipeline) Validate() error

type RawFeatureOutput added in v0.8.2

type RawFeatureOutput struct {
	OutputName   string
	Dimensions   backends.Shape
	HiddenStates [][][]float32
	Embeddings   [][]float32
}

RawFeatureOutput retains the selected model output without pooling or normalization. HiddenStates is [batch, sequence, hidden] for rank-three outputs; Embeddings is [batch, hidden] for rank-two outputs. Exactly one of these fields is populated. Dimensions contains the actual tensor shape, including padding tokens.

func (*RawFeatureOutput) GetOutput added in v0.8.2

func (o *RawFeatureOutput) GetOutput() []any

type StreamingASROptions added in v0.9.0

type StreamingASROptions = backends.StreamingASROptions

StreamingASROptions configures PCM chunk sizing, VAD, and language settings.

type TableQuestionAnsweringConfig added in v0.8.1

type TableQuestionAnsweringConfig = backends.PipelineConfig[*TableQuestionAnsweringPipeline]

type TableQuestionAnsweringInput added in v0.8.1

type TableQuestionAnsweringInput struct {
	Table    [][]string
	Question string
	Query    string
	Role     string
	History  []backends.Message
}

TableQuestionAnsweringInput pairs a table (header first) with a question. Query is a fallback for an empty Question. Native TAPAS uses the table/query.

type TableQuestionAnsweringOption added in v0.8.1

type TableQuestionAnsweringOption = backends.PipelineOption[*TableQuestionAnsweringPipeline]

func WithTableQuestionAnsweringMaxLength added in v0.8.1

func WithTableQuestionAnsweringMaxLength(n int) TableQuestionAnsweringOption

func WithTableQuestionAnsweringStreaming added in v0.8.1

func WithTableQuestionAnsweringStreaming() TableQuestionAnsweringOption

type TableQuestionAnsweringOutput added in v0.8.1

type TableQuestionAnsweringOutput struct {
	Results []TableQuestionAnsweringResult
}

func (*TableQuestionAnsweringOutput) GetOutput added in v0.8.2

func (o *TableQuestionAnsweringOutput) GetOutput() []any

type TableQuestionAnsweringPipeline added in v0.8.1

type TableQuestionAnsweringPipeline struct {
	*backends.BasePipeline
	MaxLength     int
	CellThreshold float32
	// Embedding limits include the reserved zero row/column ID.
	MaxRows    int
	MaxColumns int
	// contains filtered or unexported fields
}

TableQuestionAnsweringPipeline runs TAPAS cell selection and aggregation.

func NewTableQuestionAnsweringPipeline added in v0.8.1

func NewTableQuestionAnsweringPipeline(ctx context.Context, config TableQuestionAnsweringConfig, model *backends.Model) (*TableQuestionAnsweringPipeline, error)

func (*TableQuestionAnsweringPipeline) GetMetadata added in v0.8.2

func (*TableQuestionAnsweringPipeline) GetModel added in v0.8.2

func (*TableQuestionAnsweringPipeline) GetStatistics added in v0.8.2

func (*TableQuestionAnsweringPipeline) IsGenerative added in v0.8.1

func (*TableQuestionAnsweringPipeline) IsGenerative() bool

func (*TableQuestionAnsweringPipeline) Run added in v0.8.1

func (*TableQuestionAnsweringPipeline) RunPipeline added in v0.8.1

func (*TableQuestionAnsweringPipeline) RunSequential added in v0.8.2

func (p *TableQuestionAnsweringPipeline) RunSequential(ctx context.Context, table [][]string, questions []string) (*TableQuestionAnsweringOutput, error)

RunSequential answers questions in order, using only the preceding answer's selected cells as TAPAS prev_labels. State is local to this call.

func (*TableQuestionAnsweringPipeline) Validate added in v0.8.1

func (p *TableQuestionAnsweringPipeline) Validate() error

type TableQuestionAnsweringResult added in v0.8.2

type TableQuestionAnsweringResult struct {
	Answer      string
	Coordinates [][2]int
	Cells       []string
	Aggregator  string
}

type TabularClassificationOutput added in v0.6.2

type TabularClassificationOutput struct {
	PredictedClass string
	Probabilities  []ClassificationOutput
}

type TabularOutput added in v0.6.2

type TabularOutput struct {
	ClassificationResults []TabularClassificationOutput
	RegressionResults     []float32
}

TabularOutput returns per-input results. - For classification: []TabularClassificationOutput - For regression: float32 for each input.

func (*TabularOutput) GetOutput added in v0.6.2

func (o *TabularOutput) GetOutput() []any

type TabularPipeline added in v0.6.2

type TabularPipeline struct {
	*backends.BasePipeline
	IDLabelMap              map[int]string // optional mapping from class IDs to labels
	AggregationFunctionName string         // for classification: SOFTMAX or SIGMOID
	ProblemType             string         // "classification" or "regression"
}

TabularPipeline supports classic ML models (e.g., decision trees, random forests) exported to ONNX that take numeric feature vectors and output either class logits or regression values.

func NewTabularPipeline added in v0.6.2

func NewTabularPipeline(sessionContext context.Context, config backends.PipelineConfig[*TabularPipeline], model *backends.Model) (*TabularPipeline, error)

NewTabularPipeline initializes the pipeline.

func (*TabularPipeline) GetMetadata added in v0.6.2

func (p *TabularPipeline) GetMetadata() backends.PipelineMetadata

func (*TabularPipeline) GetModel added in v0.6.2

func (p *TabularPipeline) GetModel() *backends.Model

func (*TabularPipeline) GetStatistics added in v0.6.2

func (p *TabularPipeline) GetStatistics() backends.PipelineStatistics

func (*TabularPipeline) IsGenerative added in v0.6.2

func (p *TabularPipeline) IsGenerative() bool

func (*TabularPipeline) Run added in v0.6.2

Run executes the pipeline over inputs.

func (*TabularPipeline) RunPipeline added in v0.6.2

func (p *TabularPipeline) RunPipeline(ctx context.Context, inputs [][]float32) (*TabularOutput, error)

func (*TabularPipeline) Validate added in v0.6.2

func (p *TabularPipeline) Validate() error

type TextClassificationOutput

type TextClassificationOutput struct {
	ClassificationOutputs [][]ClassificationOutput
}

func (*TextClassificationOutput) GetOutput added in v0.0.5

func (t *TextClassificationOutput) GetOutput() []any

type TextClassificationPipeline

type TextClassificationPipeline struct {
	*backends.BasePipeline
	AggregationFunctionName string
	ProblemType             string
	FixedPaddingLength      int
}

func NewTextClassificationPipeline

func NewTextClassificationPipeline(sessionContext context.Context, config backends.PipelineConfig[*TextClassificationPipeline], model *backends.Model) (*TextClassificationPipeline, error)

NewTextClassificationPipeline initializes a new text classification pipeline.

func (*TextClassificationPipeline) GetMetadata added in v0.1.4

GetMetadata returns metadata information about the pipeline, in particular: OutputInfo: names and dimensions of the output layer used for text classification.

func (*TextClassificationPipeline) GetModel added in v0.3.0

func (p *TextClassificationPipeline) GetModel() *backends.Model

func (*TextClassificationPipeline) GetStatistics added in v0.5.9

GetStatistics returns the runtime statistics for the pipeline.

func (*TextClassificationPipeline) IsGenerative added in v0.6.0

func (p *TextClassificationPipeline) IsGenerative() bool

func (*TextClassificationPipeline) Run

Run the pipeline on a string batch.

func (*TextClassificationPipeline) RunPipeline added in v0.0.6

func (*TextClassificationPipeline) Validate added in v0.0.5

func (p *TextClassificationPipeline) Validate() error

Validate checks that the pipeline is valid.

type TextGenerationCallOptions added in v0.8.6

type TextGenerationCallOptions struct {
	// MaxLength overrides the pipeline's configured maximum when greater than zero.
	// A zero value uses the pipeline maximum.
	MaxLength int
}

TextGenerationCallOptions contains settings that can be changed for a single call.

type TextGenerationOutput added in v0.5.0

type TextGenerationOutput struct {
	TokenStream chan backends.SequenceDelta
	ErrorStream chan error
	Responses   []string
}

func (*TextGenerationOutput) GetOutput added in v0.5.0

func (t *TextGenerationOutput) GetOutput() []any

type TextGenerationPipeline added in v0.5.0

type TextGenerationPipeline struct {
	*backends.BasePipeline
	Temperature   *float64
	TopP          *float64
	Seed          *int
	Guidance      *backends.Guidance
	SystemPrompt  string
	StopSequences []string
	Tools         []string
	MaxLength     int
	Streaming     bool
}

func NewTextGenerationPipeline added in v0.5.0

func NewTextGenerationPipeline(sessionContext context.Context, config backends.PipelineConfig[*TextGenerationPipeline], model *backends.Model) (*TextGenerationPipeline, error)

NewTextGenerationPipeline initializes a new text generation pipeline.

func (*TextGenerationPipeline) GetContextLength added in v0.8.4

func (p *TextGenerationPipeline) GetContextLength() int

GetContextLength returns the model's configured context length.

func (*TextGenerationPipeline) GetMetadata added in v0.5.0

func (*TextGenerationPipeline) GetModel added in v0.5.0

func (p *TextGenerationPipeline) GetModel() *backends.Model

func (*TextGenerationPipeline) GetStatistics added in v0.5.9

GetStatistics returns the runtime statistics for the pipeline.

func (*TextGenerationPipeline) IsGenerative added in v0.6.0

func (p *TextGenerationPipeline) IsGenerative() bool

func (*TextGenerationPipeline) Run added in v0.5.0

func (*TextGenerationPipeline) RunMessages added in v0.6.0

func (p *TextGenerationPipeline) RunMessages(ctx context.Context, inputs [][]backends.Message) (*TextGenerationOutput, error)

func (*TextGenerationPipeline) RunMessagesWithOptions added in v0.8.6

func (p *TextGenerationPipeline) RunMessagesWithOptions(ctx context.Context, inputs [][]backends.Message, options *TextGenerationCallOptions) (*TextGenerationOutput, error)

RunMessagesWithOptions runs message conversations with optional per-call overrides.

func (*TextGenerationPipeline) RunMessagesWithOverrides added in v0.7.0

func (p *TextGenerationPipeline) RunMessagesWithOverrides(ctx context.Context, inputs [][]backends.Message, tools []string, guidance *backends.Guidance) (*TextGenerationOutput, error)

func (*TextGenerationPipeline) RunPipeline added in v0.5.0

func (p *TextGenerationPipeline) RunPipeline(ctx context.Context, inputs []string) (*TextGenerationOutput, error)

func (*TextGenerationPipeline) RunPipelineWithOptions added in v0.8.6

func (p *TextGenerationPipeline) RunPipelineWithOptions(ctx context.Context, inputs []string, options *TextGenerationCallOptions) (*TextGenerationOutput, error)

RunPipelineWithOptions runs text prompts with optional per-call overrides.

func (*TextGenerationPipeline) RunWithOptions added in v0.8.6

RunWithOptions runs text prompts and returns the standard pipeline output with optional per-call overrides.

func (*TextGenerationPipeline) Validate added in v0.5.0

func (p *TextGenerationPipeline) Validate() error

type TextToAudioConfig added in v0.8.1

type TextToAudioConfig = backends.PipelineConfig[*TextToAudioPipeline]

TextToAudioConfig configures a TextToAudioPipeline.

type TextToAudioOption added in v0.8.1

type TextToAudioOption = backends.PipelineOption[*TextToAudioPipeline]

TextToAudioOption configures a TextToAudioPipeline.

func WithTextToAudioSampleRate added in v0.8.1

func WithTextToAudioSampleRate(sampleRate int) TextToAudioOption

WithTextToAudioSampleRate sets the sample rate attached to generated waveforms.

type TextToAudioOutput added in v0.8.1

type TextToAudioOutput struct {
	Audio []AudioWaveform
}

TextToAudioOutput contains one mono waveform for every input text.

func (*TextToAudioOutput) GetOutput added in v0.8.1

func (o *TextToAudioOutput) GetOutput() []any

type TextToAudioPipeline added in v0.8.1

type TextToAudioPipeline struct {
	*backends.BasePipeline
	Input      backends.InputOutputInfo
	Output     backends.InputOutputInfo
	SampleRate int
}

TextToAudioPipeline generates audio waveforms from text inputs.

func NewTextToAudioPipeline added in v0.8.1

func NewTextToAudioPipeline(ctx context.Context, config TextToAudioConfig, model *backends.Model) (*TextToAudioPipeline, error)

func (*TextToAudioPipeline) GetMetadata added in v0.8.1

func (*TextToAudioPipeline) GetModel added in v0.8.1

func (p *TextToAudioPipeline) GetModel() *backends.Model

func (*TextToAudioPipeline) GetStatistics added in v0.8.1

func (p *TextToAudioPipeline) GetStatistics() backends.PipelineStatistics

func (*TextToAudioPipeline) IsGenerative added in v0.8.1

func (p *TextToAudioPipeline) IsGenerative() bool

func (*TextToAudioPipeline) Run added in v0.8.1

Run executes the pipeline for a batch of text inputs.

func (*TextToAudioPipeline) RunText added in v0.8.1

func (p *TextToAudioPipeline) RunText(ctx context.Context, inputs []string) (*TextToAudioOutput, error)

RunText generates waveforms from text inputs.

func (*TextToAudioPipeline) Validate added in v0.8.1

func (p *TextToAudioPipeline) Validate() error

type TextToSpeechConfig added in v0.8.1

type TextToSpeechConfig = TextToAudioConfig

type TextToSpeechOption added in v0.8.1

type TextToSpeechOption = TextToAudioOption

func WithTextToSpeechSampleRate added in v0.8.1

func WithTextToSpeechSampleRate(sampleRate int) TextToSpeechOption

type TextToSpeechOutput added in v0.8.1

type TextToSpeechOutput = TextToAudioOutput

TextToSpeechOutput is an alias for TextToAudioOutput.

type TextToSpeechPipeline added in v0.8.1

type TextToSpeechPipeline = TextToAudioPipeline

TextToSpeechPipeline is the supported text-to-speech alias for text-to-audio.

func NewTextToSpeechPipeline added in v0.8.1

func NewTextToSpeechPipeline(ctx context.Context, config TextToSpeechConfig, model *backends.Model) (*TextToSpeechPipeline, error)

type TokenClassificationOutput

type TokenClassificationOutput struct {
	Entities [][]Entity
}

func (*TokenClassificationOutput) GetOutput added in v0.0.5

func (t *TokenClassificationOutput) GetOutput() []any

type TokenClassificationPipeline

type TokenClassificationPipeline struct {
	*backends.BasePipeline
	IDLabelMap          map[int]string
	AggregationStrategy string
	UnknownToken        string
	IgnoreLabels        []string
	SplitWords          bool
	// WordSplitter, when set, splits each Run input into the words the model labels. See
	// [WithWordSplitter].
	WordSplitter WordSplitter
}

TokenClassificationPipeline is a go version of huggingface tokenClassificationPipeline. https://github.com/huggingface/transformers/blob/main/src/transformers/pipelines/token_classification.py

func NewTokenClassificationPipeline

func NewTokenClassificationPipeline(sessionContext context.Context, config backends.PipelineConfig[*TokenClassificationPipeline], model *backends.Model) (*TokenClassificationPipeline, error)

NewTokenClassificationPipeline Initializes a feature extraction pipeline.

func (*TokenClassificationPipeline) GetMetadata added in v0.1.4

GetMetadata returns metadata information about the pipeline, in particular: OutputInfo: names and dimensions of the output layer used for token classification.

func (*TokenClassificationPipeline) GetModel added in v0.3.0

func (*TokenClassificationPipeline) GetStatistics added in v0.5.9

GetStatistics returns the runtime statistics for the pipeline.

func (*TokenClassificationPipeline) IsGenerative added in v0.6.0

func (p *TokenClassificationPipeline) IsGenerative() bool

func (*TokenClassificationPipeline) Run

Run the pipeline on a string batch.

func (*TokenClassificationPipeline) RunPipeline added in v0.0.6

RunPipeline is like Run but returns the concrete type rather than the interface.

func (*TokenClassificationPipeline) RunWords added in v0.5.9

RunWords runs the pipeline for pre-split word inputs. Each input is a slice of words representing a pretokenized sentence. This is particularly useful when the user wants to control tokenization because of special tokens, hashtags, or other domain-specific tokenization needs.

func (*TokenClassificationPipeline) SplitText added in v0.8.4

func (p *TokenClassificationPipeline) SplitText(text string) ([]string, error)

SplitText splits text into words with the pipeline's word splitter.

func (*TokenClassificationPipeline) Validate added in v0.0.5

func (p *TokenClassificationPipeline) Validate() error

Validate checks that the pipeline is valid.

type VideoClassificationConfig added in v0.8.4

type VideoClassificationConfig = backends.PipelineConfig[*VideoClassificationPipeline]

type VideoClassificationOption added in v0.8.4

type VideoClassificationOption = backends.PipelineOption[*VideoClassificationPipeline]

func WithVideoClassificationFunction added in v0.8.4

func WithVideoClassificationFunction(function string) VideoClassificationOption

func WithVideoClassificationTopK added in v0.8.4

func WithVideoClassificationTopK(k int) VideoClassificationOption

func WithVideoDecoder added in v0.8.4

func WithVideoDecoder(decoder VideoDecoder) VideoClassificationOption

func WithVideoSampling added in v0.8.4

func WithVideoSampling(numFrames, rate int) VideoClassificationOption

func WithVideoTensorLayout added in v0.8.4

func WithVideoTensorLayout(layout string) VideoClassificationOption

WithVideoTensorLayout explicitly selects BTCHW (VideoMAE) or BCTHW.

type VideoClassificationOutput added in v0.8.4

type VideoClassificationOutput = ImageClassificationOutput

type VideoClassificationPipeline added in v0.8.4

type VideoClassificationPipeline struct {
	*backends.BasePipeline
	NumFrames         int
	FrameSamplingRate int
	TopK              int
	FunctionToApply   string
	Layout            string
	Decoder           VideoDecoder
	// contains filtered or unexported fields
}

func NewVideoClassificationPipeline added in v0.8.4

func NewVideoClassificationPipeline(ctx context.Context, config VideoClassificationConfig, model *backends.Model) (*VideoClassificationPipeline, error)

func (*VideoClassificationPipeline) GetMetadata added in v0.8.4

func (*VideoClassificationPipeline) GetModel added in v0.8.4

func (*VideoClassificationPipeline) GetStatistics added in v0.8.4

func (*VideoClassificationPipeline) IsGenerative added in v0.8.4

func (*VideoClassificationPipeline) IsGenerative() bool

func (*VideoClassificationPipeline) Run added in v0.8.4

func (*VideoClassificationPipeline) RunFiles added in v0.8.4

func (*VideoClassificationPipeline) RunFrames added in v0.8.4

RunFrames processes videos individually so each graph call has batch size one.

func (*VideoClassificationPipeline) Validate added in v0.8.4

func (p *VideoClassificationPipeline) Validate() error

type VideoDecoder added in v0.8.4

type VideoDecoder interface {
	Decode(context.Context, string, int) (VideoInput, error)
}

VideoDecoder decodes at most maxFrames frames from the start of a video. Implementations must honor cancellation and return frames in presentation order.

type VideoInput added in v0.8.4

type VideoInput struct {
	Frames     []image.Image
	Timestamps []time.Duration
}

VideoInput contains decoded frames in presentation order. Timestamps, when present, must have one entry per frame. Sampling uses frame indices, as in the v5.20.2 VideoMAE image-processor path, even for variable frame rates.

type WordSplitter added in v0.8.4

type WordSplitter func(text string) []string

WordSplitter splits a raw input into the words a token classification model labels, one tag per word. Models fine-tuned on custom word boundaries (for example "Row7" split into "Row" and "7") need the same split at inference, or the model sees inputs it was not trained on and labels words that do not line up with the training tags.

type ZeroShotAudioClassificationConfig added in v0.8.1

type ZeroShotAudioClassificationConfig = backends.PipelineConfig[*ZeroShotAudioClassificationPipeline]

ZeroShotAudioClassificationConfig configures a zero-shot audio pipeline.

type ZeroShotAudioClassificationOption added in v0.8.1

type ZeroShotAudioClassificationOption = backends.PipelineOption[*ZeroShotAudioClassificationPipeline]

ZeroShotAudioClassificationConfig configures a zero-shot audio pipeline.

func WithAudioLabels added in v0.8.1

func WithAudioLabels(labels []string) ZeroShotAudioClassificationOption

func WithZeroShotAudioHypothesisTemplate added in v0.8.2

func WithZeroShotAudioHypothesisTemplate(template string) ZeroShotAudioClassificationOption

WithZeroShotAudioHypothesisTemplate sets the text template used to describe each candidate label.

func WithZeroShotAudioLabels added in v0.8.1

func WithZeroShotAudioLabels(labels []string) ZeroShotAudioClassificationOption

WithZeroShotAudioLabels is the family-specific spelling of WithAudioLabels.

func WithZeroShotAudioSampleRate added in v0.8.1

func WithZeroShotAudioSampleRate(sampleRate int) ZeroShotAudioClassificationOption

WithZeroShotAudioSampleRate sets the sample rate expected by the model.

func WithZeroShotAudioTopK added in v0.8.1

func WithZeroShotAudioTopK(k int) ZeroShotAudioClassificationOption

type ZeroShotAudioClassificationOutput added in v0.8.1

type ZeroShotAudioClassificationOutput struct {
	Predictions [][]ZeroShotAudioClassificationResult
}

func (*ZeroShotAudioClassificationOutput) GetOutput added in v0.8.1

func (o *ZeroShotAudioClassificationOutput) GetOutput() []any

type ZeroShotAudioClassificationPipeline added in v0.8.1

type ZeroShotAudioClassificationPipeline struct {
	*backends.BasePipeline
	Labels             []string
	TopK               int
	Input              backends.InputOutputInfo
	SampleRate         int
	HypothesisTemplate string
}

ZeroShotAudioClassificationPipeline scores candidate labels against audio. The model compares an audio input with tokenized candidate text and returns pairwise similarities.

func NewZeroShotAudioClassificationPipeline added in v0.8.1

func NewZeroShotAudioClassificationPipeline(ctx context.Context, config ZeroShotAudioClassificationConfig, model *backends.Model) (*ZeroShotAudioClassificationPipeline, error)

func (*ZeroShotAudioClassificationPipeline) GetMetadata added in v0.8.1

func (*ZeroShotAudioClassificationPipeline) GetModel added in v0.8.1

func (*ZeroShotAudioClassificationPipeline) GetStatistics added in v0.8.1

func (*ZeroShotAudioClassificationPipeline) IsGenerative added in v0.8.1

func (p *ZeroShotAudioClassificationPipeline) IsGenerative() bool

func (*ZeroShotAudioClassificationPipeline) Run added in v0.8.1

func (*ZeroShotAudioClassificationPipeline) RunFiles added in v0.8.1

func (*ZeroShotAudioClassificationPipeline) RunWaveforms added in v0.8.1

func (*ZeroShotAudioClassificationPipeline) RunWithAudio added in v0.8.1

RunWithAudio executes mono samples already sampled at the pipeline's configured SampleRate.

func (*ZeroShotAudioClassificationPipeline) Validate added in v0.8.1

type ZeroShotAudioClassificationResult added in v0.8.1

type ZeroShotAudioClassificationResult struct {
	Label      string
	Score      float32
	ClassIndex int
}

ZeroShotAudioClassificationResult is the score for one candidate label.

type ZeroShotClassificationOutput added in v0.1.4

type ZeroShotClassificationOutput struct {
	Sequence     string
	SortedValues []struct {
		Key   string
		Value float64
	}
}

type ZeroShotClassificationPipeline added in v0.1.4

type ZeroShotClassificationPipeline struct {
	*backends.BasePipeline
	HypothesisTemplate string
	Sequences          []string
	Labels             []string
	EntailmentID       int
	Multilabel         bool
}

func NewZeroShotClassificationPipeline added in v0.1.4

func NewZeroShotClassificationPipeline(sessionContext context.Context, config backends.PipelineConfig[*ZeroShotClassificationPipeline], model *backends.Model) (*ZeroShotClassificationPipeline, error)

NewZeroShotClassificationPipeline create new Zero Shot Classification Pipeline.

func (*ZeroShotClassificationPipeline) GetMetadata added in v0.1.4

func (*ZeroShotClassificationPipeline) GetModel added in v0.3.0

func (*ZeroShotClassificationPipeline) GetStatistics added in v0.5.9

GetStatistics returns the runtime statistics for the pipeline.

func (*ZeroShotClassificationPipeline) IsGenerative added in v0.6.0

func (p *ZeroShotClassificationPipeline) IsGenerative() bool

func (*ZeroShotClassificationPipeline) Run added in v0.1.4

func (*ZeroShotClassificationPipeline) RunPipeline added in v0.1.4

func (p *ZeroShotClassificationPipeline) RunPipeline(ctx context.Context, inputs []string) (*ZeroShotOutput, error)

func (*ZeroShotClassificationPipeline) RunSingle added in v0.7.8

RunSingle runs zero-shot classification for one sequence.

func (*ZeroShotClassificationPipeline) Validate added in v0.1.4

func (p *ZeroShotClassificationPipeline) Validate() error

type ZeroShotImageClassificationOutput added in v0.8.1

type ZeroShotImageClassificationOutput struct {
	Predictions [][]ZeroShotImageClassificationResult
}

func (*ZeroShotImageClassificationOutput) GetOutput added in v0.8.1

func (o *ZeroShotImageClassificationOutput) GetOutput() []any

type ZeroShotImageClassificationPipeline added in v0.8.1

type ZeroShotImageClassificationPipeline struct {
	*backends.BasePipeline
	Labels []string
	TopK   int
	// contains filtered or unexported fields
}

func (*ZeroShotImageClassificationPipeline) GetMetadata added in v0.8.1

func (*ZeroShotImageClassificationPipeline) GetModel added in v0.8.1

func (*ZeroShotImageClassificationPipeline) GetStatistics added in v0.8.1

func (*ZeroShotImageClassificationPipeline) IsGenerative added in v0.8.1

func (p *ZeroShotImageClassificationPipeline) IsGenerative() bool

func (*ZeroShotImageClassificationPipeline) Run added in v0.8.1

Run is intentionally unavailable because []string cannot express paired image/text inputs.

func (*ZeroShotImageClassificationPipeline) RunWithImageText added in v0.8.1

func (*ZeroShotImageClassificationPipeline) RunWithImagesAndLabels added in v0.8.1

func (p *ZeroShotImageClassificationPipeline) RunWithImagesAndLabels(ctx context.Context, images []image.Image, labels []string) (*ZeroShotImageClassificationOutput, error)

func (*ZeroShotImageClassificationPipeline) Validate added in v0.8.1

type ZeroShotImageClassificationResult added in v0.8.1

type ZeroShotImageClassificationResult struct {
	Label string
	Score float32
}

type ZeroShotObjectDetectionOutput added in v0.8.1

type ZeroShotObjectDetectionOutput = ObjectDetectionOutput

type ZeroShotObjectDetectionPipeline added in v0.8.1

type ZeroShotObjectDetectionPipeline struct {
	*ObjectDetectionPipeline
	Labels []string
}

ZeroShotObjectDetectionPipeline describes object detection models whose categories are supplied at runtime. Models must expose an image/text contract; the regular object detector is used when labels are provided by the model's ID-to-label map.

func (*ZeroShotObjectDetectionPipeline) IsGenerative added in v0.8.1

func (p *ZeroShotObjectDetectionPipeline) IsGenerative() bool

func (*ZeroShotObjectDetectionPipeline) Run added in v0.8.1

Run is unavailable because []string cannot carry candidate labels. Use RunWithLabels for a request-specific label set.

func (*ZeroShotObjectDetectionPipeline) RunWithImagesAndLabels added in v0.8.1

func (p *ZeroShotObjectDetectionPipeline) RunWithImagesAndLabels(ctx context.Context, inputs []image.Image, labels []string) (*ZeroShotObjectDetectionOutput, error)

func (*ZeroShotObjectDetectionPipeline) RunWithLabels added in v0.8.1

func (p *ZeroShotObjectDetectionPipeline) RunWithLabels(ctx context.Context, inputs []string, labels []string) (*ZeroShotObjectDetectionOutput, error)

RunWithLabels validates the paired request. A backend with an explicit image/text tensor contract can implement the model-specific execution; current generic image execution cannot encode candidate labels safely.

func (*ZeroShotObjectDetectionPipeline) Validate added in v0.8.1

func (p *ZeroShotObjectDetectionPipeline) Validate() error

type ZeroShotOutput added in v0.1.4

type ZeroShotOutput struct {
	ClassificationOutputs []ZeroShotClassificationOutput
}

func (*ZeroShotOutput) GetOutput added in v0.1.4

func (t *ZeroShotOutput) GetOutput() []any

GetOutput converts raw output to readable output.

Jump to

Keyboard shortcuts

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