Documentation
¶
Index ¶
- func WithAverageAggregation() backends.PipelineOption[*TokenClassificationPipeline]
- func WithBatchSize(size int) backends.PipelineOption[*CrossEncoderPipeline]
- func WithBoxesOutput(name string) backends.PipelineOption[*ObjectDetectionPipeline]
- func WithClassification() backends.PipelineOption[*TabularPipeline]
- func WithDetectionIouThreshold(th float32) backends.PipelineOption[*ObjectDetectionPipeline]
- func WithDetectionScoreThreshold(th float32) backends.PipelineOption[*ObjectDetectionPipeline]
- func WithDetectionTopK(k int) backends.PipelineOption[*ObjectDetectionPipeline]
- func WithFirstAggregation() backends.PipelineOption[*TokenClassificationPipeline]
- func WithFixedPadding(fixedPaddingLength int) backends.PipelineOption[*TextClassificationPipeline]
- func WithGuidance(guidance *backends.Guidance) backends.PipelineOption[*TextGenerationPipeline]
- func WithHypothesisTemplate(hypothesisTemplate string) backends.PipelineOption[*ZeroShotClassificationPipeline]
- func WithIDLabelMap(labels map[int]string) backends.PipelineOption[*TabularPipeline]
- func WithIgnoreLabels(ignoreLabels []string) backends.PipelineOption[*TokenClassificationPipeline]
- func WithImageMode() backends.PipelineOption[*FeatureExtractionPipeline]
- func WithLabels(labels []string) backends.PipelineOption[*ZeroShotClassificationPipeline]
- func WithMaxAggregation() backends.PipelineOption[*TokenClassificationPipeline]
- func WithMaxAnswerLength(n int) backends.PipelineOption[*QuestionAnsweringPipeline]
- func WithMaxLength(maxLength int) backends.PipelineOption[*TextGenerationPipeline]
- func WithMultiLabel() backends.PipelineOption[*TextClassificationPipeline]
- func WithMultilabel(multilabel bool) backends.PipelineOption[*ZeroShotClassificationPipeline]
- func WithNCHWFormat[T imagePipeline]() backends.PipelineOption[T]
- func WithNHWCFormat[T imagePipeline]() backends.PipelineOption[T]
- func WithNormalization() backends.PipelineOption[*FeatureExtractionPipeline]
- func WithNormalizationSteps[T imagePipeline](steps ...imageutil.NormalizationStep) backends.PipelineOption[T]
- func WithOutputName(outputName string) backends.PipelineOption[*FeatureExtractionPipeline]
- func WithPreprocessSteps[T imagePipeline](steps ...imageutil.PreprocessStep) backends.PipelineOption[T]
- func WithRegression() backends.PipelineOption[*TabularPipeline]
- func WithScoreThreshold(threshold float32) backends.PipelineOption[*CrossEncoderPipeline]
- func WithScoresOutput(name string) backends.PipelineOption[*ObjectDetectionPipeline]
- func WithSeed(seed int) backends.PipelineOption[*TextGenerationPipeline]
- func WithSigmoid() backends.PipelineOption[*TextClassificationPipeline]
- func WithSimpleAggregation() backends.PipelineOption[*TokenClassificationPipeline]
- func WithSingleLabel() backends.PipelineOption[*TextClassificationPipeline]
- func WithSoftmax() backends.PipelineOption[*TextClassificationPipeline]
- func WithSortResults() backends.PipelineOption[*CrossEncoderPipeline]
- func WithSplitWords() backends.PipelineOption[*TokenClassificationPipeline]
- func WithStopSequences(stopSequences []string) backends.PipelineOption[*TextGenerationPipeline]
- func WithStreaming() backends.PipelineOption[*TextGenerationPipeline]
- func WithSystemPrompt(systemPrompt string) backends.PipelineOption[*TextGenerationPipeline]
- func WithTabularSigmoid() backends.PipelineOption[*TabularPipeline]
- func WithTabularSoftmax() backends.PipelineOption[*TabularPipeline]
- func WithTemperature(temperature float64) backends.PipelineOption[*TextGenerationPipeline]
- func WithTools(tools []string) backends.PipelineOption[*TextGenerationPipeline]
- func WithTopK(topK int) backends.PipelineOption[*ImageClassificationPipeline]
- func WithTopKAnswers(k int) backends.PipelineOption[*QuestionAnsweringPipeline]
- func WithTopP(topP float64) backends.PipelineOption[*TextGenerationPipeline]
- func WithoutAggregation() backends.PipelineOption[*TokenClassificationPipeline]
- type ClassificationOutput
- type CrossEncoderOutput
- type CrossEncoderPipeline
- func (p *CrossEncoderPipeline) GetMetadata() backends.PipelineMetadata
- func (p *CrossEncoderPipeline) GetModel() *backends.Model
- func (p *CrossEncoderPipeline) GetStatistics() backends.PipelineStatistics
- func (p *CrossEncoderPipeline) IsGenerative() bool
- func (p *CrossEncoderPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
- func (p *CrossEncoderPipeline) RunPipeline(ctx context.Context, query string, documents []string) (*CrossEncoderOutput, error)
- func (p *CrossEncoderPipeline) Validate() error
- type CrossEncoderResult
- type CrossEncoderStatistics
- type Detection
- type Entity
- type FeatureExtractionOutput
- type FeatureExtractionPipeline
- func (p *FeatureExtractionPipeline) GetMetadata() backends.PipelineMetadata
- func (p *FeatureExtractionPipeline) GetModel() *backends.Model
- func (p *FeatureExtractionPipeline) GetStatistics() backends.PipelineStatistics
- func (p *FeatureExtractionPipeline) IsGenerative() bool
- func (p *FeatureExtractionPipeline) PreprocessImages(batch *backends.PipelineBatch, inputs []image.Image) error
- func (p *FeatureExtractionPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
- func (p *FeatureExtractionPipeline) RunPipeline(ctx context.Context, inputs []string) (*FeatureExtractionOutput, error)
- func (p *FeatureExtractionPipeline) RunWithImagePaths(ctx context.Context, paths []string) (*FeatureExtractionOutput, error)
- func (p *FeatureExtractionPipeline) RunWithImages(ctx context.Context, images []image.Image) (*FeatureExtractionOutput, error)
- func (p *FeatureExtractionPipeline) Validate() error
- type ImageClassificationOutput
- type ImageClassificationPipeline
- func (p *ImageClassificationPipeline) GetMetadata() backends.PipelineMetadata
- func (p *ImageClassificationPipeline) GetModel() *backends.Model
- func (p *ImageClassificationPipeline) GetStatistics() backends.PipelineStatistics
- func (p *ImageClassificationPipeline) IsGenerative() bool
- func (p *ImageClassificationPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
- func (p *ImageClassificationPipeline) RunPipeline(ctx context.Context, inputs []string) (*ImageClassificationOutput, error)
- func (p *ImageClassificationPipeline) RunWithImages(ctx context.Context, inputs []image.Image) (*ImageClassificationOutput, error)
- func (p *ImageClassificationPipeline) Validate() error
- type ImageClassificationResult
- type ObjectDetectionOutput
- type ObjectDetectionPipeline
- func (p *ObjectDetectionPipeline) GetMetadata() backends.PipelineMetadata
- func (p *ObjectDetectionPipeline) GetModel() *backends.Model
- func (p *ObjectDetectionPipeline) GetStatistics() backends.PipelineStatistics
- func (p *ObjectDetectionPipeline) GetStats() []string
- func (p *ObjectDetectionPipeline) IsGenerative() bool
- func (p *ObjectDetectionPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
- func (p *ObjectDetectionPipeline) RunPipeline(ctx context.Context, inputs []string) (*ObjectDetectionOutput, error)
- func (p *ObjectDetectionPipeline) RunWithImages(ctx context.Context, inputs []image.Image) (*ObjectDetectionOutput, error)
- func (p *ObjectDetectionPipeline) Validate() error
- type QuestionAnsweringBatchOutput
- type QuestionAnsweringInput
- type QuestionAnsweringOutput
- type QuestionAnsweringPipeline
- func (p *QuestionAnsweringPipeline) GetMetadata() backends.PipelineMetadata
- func (p *QuestionAnsweringPipeline) GetModel() *backends.Model
- func (p *QuestionAnsweringPipeline) GetStatistics() backends.PipelineStatistics
- func (p *QuestionAnsweringPipeline) IsGenerative() bool
- func (p *QuestionAnsweringPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
- func (p *QuestionAnsweringPipeline) RunPipeline(ctx context.Context, inputs []QuestionAnsweringInput) (*QuestionAnsweringBatchOutput, error)
- func (p *QuestionAnsweringPipeline) Validate() error
- type TabularClassificationOutput
- type TabularOutput
- type TabularPipeline
- func (p *TabularPipeline) GetMetadata() backends.PipelineMetadata
- func (p *TabularPipeline) GetModel() *backends.Model
- func (p *TabularPipeline) GetStatistics() backends.PipelineStatistics
- func (p *TabularPipeline) IsGenerative() bool
- func (p *TabularPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
- func (p *TabularPipeline) RunPipeline(ctx context.Context, inputs [][]float32) (*TabularOutput, error)
- func (p *TabularPipeline) Validate() error
- type TextClassificationOutput
- type TextClassificationPipeline
- func (p *TextClassificationPipeline) GetMetadata() backends.PipelineMetadata
- func (p *TextClassificationPipeline) GetModel() *backends.Model
- func (p *TextClassificationPipeline) GetStatistics() backends.PipelineStatistics
- func (p *TextClassificationPipeline) IsGenerative() bool
- func (p *TextClassificationPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
- func (p *TextClassificationPipeline) RunPipeline(ctx context.Context, inputs []string) (*TextClassificationOutput, error)
- func (p *TextClassificationPipeline) Validate() error
- type TextGenerationOutput
- type TextGenerationPipeline
- func (p *TextGenerationPipeline) GetMetadata() backends.PipelineMetadata
- func (p *TextGenerationPipeline) GetModel() *backends.Model
- func (p *TextGenerationPipeline) GetStatistics() backends.PipelineStatistics
- func (p *TextGenerationPipeline) IsGenerative() bool
- func (p *TextGenerationPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
- func (p *TextGenerationPipeline) RunMessages(ctx context.Context, inputs [][]backends.Message) (*TextGenerationOutput, error)
- func (p *TextGenerationPipeline) RunMessagesWithOverrides(ctx context.Context, inputs [][]backends.Message, tools []string, ...) (*TextGenerationOutput, error)
- func (p *TextGenerationPipeline) RunPipeline(ctx context.Context, inputs []string) (*TextGenerationOutput, error)
- func (p *TextGenerationPipeline) Validate() error
- type TokenClassificationOutput
- type TokenClassificationPipeline
- func (p *TokenClassificationPipeline) GetMetadata() backends.PipelineMetadata
- func (p *TokenClassificationPipeline) GetModel() *backends.Model
- func (p *TokenClassificationPipeline) GetStatistics() backends.PipelineStatistics
- func (p *TokenClassificationPipeline) IsGenerative() bool
- func (p *TokenClassificationPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
- func (p *TokenClassificationPipeline) RunPipeline(ctx context.Context, inputs []string) (*TokenClassificationOutput, error)
- func (p *TokenClassificationPipeline) RunWords(ctx context.Context, inputs [][]string) (*TokenClassificationOutput, error)
- func (p *TokenClassificationPipeline) Validate() error
- type ZeroShotClassificationOutput
- type ZeroShotClassificationPipeline
- func (p *ZeroShotClassificationPipeline) GetMetadata() backends.PipelineMetadata
- func (p *ZeroShotClassificationPipeline) GetModel() *backends.Model
- func (p *ZeroShotClassificationPipeline) GetStatistics() backends.PipelineStatistics
- func (p *ZeroShotClassificationPipeline) IsGenerative() bool
- func (p *ZeroShotClassificationPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
- func (p *ZeroShotClassificationPipeline) RunPipeline(ctx context.Context, inputs []string) (*ZeroShotOutput, error)
- func (p *ZeroShotClassificationPipeline) Validate() error
- type ZeroShotOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 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 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 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 WithGuidance ¶ added in v0.7.0
func WithGuidance(guidance *backends.Guidance) backends.PipelineOption[*TextGenerationPipeline]
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 WithImageMode ¶ added in v0.6.0
func WithImageMode() backends.PipelineOption[*FeatureExtractionPipeline]
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 WithLabels ¶ added in v0.1.4
func WithLabels(labels []string) backends.PipelineOption[*ZeroShotClassificationPipeline]
WithLabels can be used to set the labels to classify the examples.
func WithMaxAggregation ¶ added in v0.3.4
func WithMaxAggregation() backends.PipelineOption[*TokenClassificationPipeline]
WithMaxAggregation sets the aggregation strategy for the token labels to Max It reproduces max aggregation from the huggingface implementation.
func WithMaxAnswerLength ¶ added in v0.7.0
func WithMaxAnswerLength(n int) backends.PipelineOption[*QuestionAnsweringPipeline]
WithMaxAnswerLength sets the maximum number of tokens that the answer span may cover.
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 WithMultiLabel ¶ added in v0.0.9
func WithMultiLabel() backends.PipelineOption[*TextClassificationPipeline]
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
func WithNormalization() backends.PipelineOption[*FeatureExtractionPipeline]
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 WithSeed(seed int) backends.PipelineOption[*TextGenerationPipeline]
func WithSigmoid ¶ added in v0.0.9
func WithSigmoid() backends.PipelineOption[*TextClassificationPipeline]
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 WithSingleLabel() backends.PipelineOption[*TextClassificationPipeline]
func WithSoftmax ¶ added in v0.0.9
func WithSoftmax() backends.PipelineOption[*TextClassificationPipeline]
func WithSortResults ¶ added in v0.5.0
func WithSortResults() backends.PipelineOption[*CrossEncoderPipeline]
func WithSplitWords ¶ added in v0.5.9
func WithSplitWords() backends.PipelineOption[*TokenClassificationPipeline]
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
func WithStreaming() backends.PipelineOption[*TextGenerationPipeline]
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
func WithTools(tools []string) backends.PipelineOption[*TextGenerationPipeline]
WithTools sets the list of Hermes-style tool definition JSON strings to include in the chat template.
func WithTopK ¶ added in v0.5.0
func WithTopK(topK int) backends.PipelineOption[*ImageClassificationPipeline]
WithTopK sets the number of top classifications to return.
func WithTopKAnswers ¶ added in v0.7.0
func WithTopKAnswers(k int) backends.PipelineOption[*QuestionAnsweringPipeline]
WithTopKAnswers sets the number of ranked answer spans to return per input. When k > 1 each element of QuestionAnsweringBatchOutput.Outputs is a slice of up to k answers sorted by score descending.
func WithTopP ¶ added in v0.6.3
func WithTopP(topP float64) backends.PipelineOption[*TextGenerationPipeline]
func WithoutAggregation ¶
func WithoutAggregation() backends.PipelineOption[*TokenClassificationPipeline]
WithoutAggregation returns the token labels.
Types ¶
type ClassificationOutput ¶
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], s *options.Options, model *backends.Model) (*CrossEncoderPipeline, error)
func (*CrossEncoderPipeline) GetMetadata ¶ added in v0.5.0
func (p *CrossEncoderPipeline) GetMetadata() backends.PipelineMetadata
func (*CrossEncoderPipeline) GetModel ¶ added in v0.5.0
func (p *CrossEncoderPipeline) GetModel() *backends.Model
func (*CrossEncoderPipeline) GetStatistics ¶ added in v0.5.9
func (p *CrossEncoderPipeline) GetStatistics() backends.PipelineStatistics
func (*CrossEncoderPipeline) IsGenerative ¶ added in v0.6.0
func (p *CrossEncoderPipeline) IsGenerative() bool
func (*CrossEncoderPipeline) Run ¶ added in v0.5.0
func (p *CrossEncoderPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
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 CrossEncoderStatistics ¶ added in v0.5.9
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], s *options.Options, model *backends.Model) (*FeatureExtractionPipeline, error)
NewFeatureExtractionPipeline init a feature extraction pipeline.
func (*FeatureExtractionPipeline) GetMetadata ¶ added in v0.1.4
func (p *FeatureExtractionPipeline) GetMetadata() backends.PipelineMetadata
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
func (p *FeatureExtractionPipeline) GetStatistics() backends.PipelineStatistics
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 ¶
func (p *FeatureExtractionPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
Run the pipeline on a batch of strings.
func (*FeatureExtractionPipeline) RunPipeline ¶ added in v0.0.6
func (p *FeatureExtractionPipeline) RunPipeline(ctx context.Context, inputs []string) (*FeatureExtractionOutput, error)
RunPipeline is like Run, but returns the concrete feature extraction output type rather than the interface.
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
func (p *FeatureExtractionPipeline) RunWithImages(ctx context.Context, images []image.Image) (*FeatureExtractionOutput, error)
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 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], s *options.Options, model *backends.Model) (*ImageClassificationPipeline, error)
NewImageClassificationPipeline initializes an image classification pipeline.
func (*ImageClassificationPipeline) GetMetadata ¶ added in v0.5.0
func (p *ImageClassificationPipeline) GetMetadata() backends.PipelineMetadata
func (*ImageClassificationPipeline) GetModel ¶ added in v0.5.0
func (p *ImageClassificationPipeline) GetModel() *backends.Model
func (*ImageClassificationPipeline) GetStatistics ¶ added in v0.5.9
func (p *ImageClassificationPipeline) GetStatistics() backends.PipelineStatistics
func (*ImageClassificationPipeline) IsGenerative ¶ added in v0.6.0
func (p *ImageClassificationPipeline) IsGenerative() bool
func (*ImageClassificationPipeline) Run ¶ added in v0.5.0
func (p *ImageClassificationPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
Run runs the pipeline on a batch of image file paths.
func (*ImageClassificationPipeline) RunPipeline ¶ added in v0.5.0
func (p *ImageClassificationPipeline) RunPipeline(ctx context.Context, inputs []string) (*ImageClassificationOutput, error)
RunPipeline returns the concrete output type.
func (*ImageClassificationPipeline) RunWithImages ¶ added in v0.5.0
func (p *ImageClassificationPipeline) RunWithImages(ctx context.Context, inputs []image.Image) (*ImageClassificationOutput, error)
func (*ImageClassificationPipeline) Validate ¶ added in v0.5.0
func (p *ImageClassificationPipeline) Validate() error
type ImageClassificationResult ¶ added in v0.5.0
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], s *options.Options, model *backends.Model) (*ObjectDetectionPipeline, error)
NewObjectDetectionPipeline initializes an object detection pipeline.
func (*ObjectDetectionPipeline) GetMetadata ¶ added in v0.6.0
func (p *ObjectDetectionPipeline) GetMetadata() backends.PipelineMetadata
func (*ObjectDetectionPipeline) GetModel ¶ added in v0.6.0
func (p *ObjectDetectionPipeline) GetModel() *backends.Model
func (*ObjectDetectionPipeline) GetStatistics ¶ added in v0.6.0
func (p *ObjectDetectionPipeline) GetStatistics() backends.PipelineStatistics
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
func (p *ObjectDetectionPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
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 QuestionAnsweringBatchOutput ¶ added in v0.7.0
type QuestionAnsweringBatchOutput struct {
Outputs [][]QuestionAnsweringOutput
}
QuestionAnsweringBatchOutput holds results for a whole batch. Each element of Outputs corresponds to one input and contains answers ranked by score (best first). With the default TopK=1 each inner slice has exactly one element.
func (*QuestionAnsweringBatchOutput) GetOutput ¶ added in v0.7.0
func (o *QuestionAnsweringBatchOutput) GetOutput() []any
type QuestionAnsweringInput ¶ added in v0.7.0
QuestionAnsweringInput holds a single question/context pair.
type QuestionAnsweringOutput ¶ added in v0.7.0
type QuestionAnsweringOutput struct {
// Answer is the extracted answer string from Context.
Answer string
// Score is start_prob[best_start] * end_prob[best_end].
Score float32
// Start is the byte offset of the answer start inside Context.
Start uint
// End is the byte offset (exclusive) of the answer end inside Context.
End uint
}
QuestionAnsweringOutput holds the result for a single question/context pair.
type QuestionAnsweringPipeline ¶ added in v0.7.0
type QuestionAnsweringPipeline struct {
*backends.BasePipeline
// MaxAnswerLength is the maximum number of tokens allowed in the answer span (default 15).
MaxAnswerLength int
// TopK is the number of ranked answer spans to return per input (default 1).
TopK int
}
QuestionAnsweringPipeline holds the pipeline configuration.
func NewQuestionAnsweringPipeline ¶ added in v0.7.0
func NewQuestionAnsweringPipeline(sessionContext context.Context, config backends.PipelineConfig[*QuestionAnsweringPipeline], s *options.Options, model *backends.Model) (*QuestionAnsweringPipeline, error)
NewQuestionAnsweringPipeline initialises a question answering pipeline.
func (*QuestionAnsweringPipeline) GetMetadata ¶ added in v0.7.0
func (p *QuestionAnsweringPipeline) GetMetadata() backends.PipelineMetadata
GetMetadata returns metadata for both output tensors (start_logits, end_logits).
func (*QuestionAnsweringPipeline) GetModel ¶ added in v0.7.0
func (p *QuestionAnsweringPipeline) GetModel() *backends.Model
func (*QuestionAnsweringPipeline) GetStatistics ¶ added in v0.7.0
func (p *QuestionAnsweringPipeline) GetStatistics() backends.PipelineStatistics
GetStatistics returns runtime statistics for the pipeline.
func (*QuestionAnsweringPipeline) IsGenerative ¶ added in v0.7.0
func (p *QuestionAnsweringPipeline) IsGenerative() bool
func (*QuestionAnsweringPipeline) Run ¶ added in v0.7.0
func (p *QuestionAnsweringPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
Run implements the Pipeline interface. Inputs are interleaved [question0, context0, question1, context1, …].
func (*QuestionAnsweringPipeline) RunPipeline ¶ added in v0.7.0
func (p *QuestionAnsweringPipeline) RunPipeline(ctx context.Context, inputs []QuestionAnsweringInput) (*QuestionAnsweringBatchOutput, error)
RunPipeline is the typed entry point for the question answering pipeline.
func (*QuestionAnsweringPipeline) Validate ¶ added in v0.7.0
func (p *QuestionAnsweringPipeline) Validate() error
Validate checks that the pipeline configuration is valid.
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
AggregationFunctionName string // for classification: SOFTMAX or SIGMOID
ProblemType string // "classification" or "regression"
IDLabelMap map[int]string // optional mapping from class IDs to labels
}
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], s *options.Options, 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
func (p *TabularPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
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], s *options.Options, model *backends.Model) (*TextClassificationPipeline, error)
NewTextClassificationPipeline initializes a new text classification pipeline.
func (*TextClassificationPipeline) GetMetadata ¶ added in v0.1.4
func (p *TextClassificationPipeline) GetMetadata() backends.PipelineMetadata
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
func (p *TextClassificationPipeline) GetStatistics() backends.PipelineStatistics
GetStatistics returns the runtime statistics for the pipeline.
func (*TextClassificationPipeline) IsGenerative ¶ added in v0.6.0
func (p *TextClassificationPipeline) IsGenerative() bool
func (*TextClassificationPipeline) Run ¶
func (p *TextClassificationPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
Run the pipeline on a string batch.
func (*TextClassificationPipeline) RunPipeline ¶ added in v0.0.6
func (p *TextClassificationPipeline) RunPipeline(ctx context.Context, inputs []string) (*TextClassificationOutput, error)
func (*TextClassificationPipeline) Validate ¶ added in v0.0.5
func (p *TextClassificationPipeline) Validate() error
Validate checks that the pipeline is valid.
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
SystemPrompt string
MaxLength int
Streaming bool
Temperature *float64
TopP *float64
Seed *int
StopSequences []string
Tools []string
Guidance *backends.Guidance
}
func NewTextGenerationPipeline ¶ added in v0.5.0
func NewTextGenerationPipeline(sessionContext context.Context, config backends.PipelineConfig[*TextGenerationPipeline], s *options.Options, model *backends.Model) (*TextGenerationPipeline, error)
NewTextGenerationPipeline initializes a new text generation pipeline.
func (*TextGenerationPipeline) GetMetadata ¶ added in v0.5.0
func (p *TextGenerationPipeline) GetMetadata() backends.PipelineMetadata
func (*TextGenerationPipeline) GetModel ¶ added in v0.5.0
func (p *TextGenerationPipeline) GetModel() *backends.Model
func (*TextGenerationPipeline) GetStatistics ¶ added in v0.5.9
func (p *TextGenerationPipeline) GetStatistics() backends.PipelineStatistics
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 (p *TextGenerationPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
func (*TextGenerationPipeline) RunMessages ¶ added in v0.6.0
func (p *TextGenerationPipeline) RunMessages(ctx context.Context, inputs [][]backends.Message) (*TextGenerationOutput, error)
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) Validate ¶ added in v0.5.0
func (p *TextGenerationPipeline) Validate() 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
IgnoreLabels []string
SplitWords bool
}
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], s *options.Options, model *backends.Model) (*TokenClassificationPipeline, error)
NewTokenClassificationPipeline Initializes a feature extraction pipeline.
func (*TokenClassificationPipeline) GetMetadata ¶ added in v0.1.4
func (p *TokenClassificationPipeline) GetMetadata() backends.PipelineMetadata
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 (p *TokenClassificationPipeline) GetModel() *backends.Model
func (*TokenClassificationPipeline) GetStatistics ¶ added in v0.5.9
func (p *TokenClassificationPipeline) GetStatistics() backends.PipelineStatistics
GetStatistics returns the runtime statistics for the pipeline.
func (*TokenClassificationPipeline) IsGenerative ¶ added in v0.6.0
func (p *TokenClassificationPipeline) IsGenerative() bool
func (*TokenClassificationPipeline) Run ¶
func (p *TokenClassificationPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
Run the pipeline on a string batch.
func (*TokenClassificationPipeline) RunPipeline ¶ added in v0.0.6
func (p *TokenClassificationPipeline) RunPipeline(ctx context.Context, inputs []string) (*TokenClassificationOutput, error)
RunPipeline is like Run but returns the concrete type rather than the interface.
func (*TokenClassificationPipeline) RunWords ¶ added in v0.5.9
func (p *TokenClassificationPipeline) RunWords(ctx context.Context, inputs [][]string) (*TokenClassificationOutput, error)
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) Validate ¶ added in v0.0.5
func (p *TokenClassificationPipeline) Validate() error
Validate checks that the pipeline is valid.
type ZeroShotClassificationOutput ¶ added in v0.1.4
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], s *options.Options, model *backends.Model) (*ZeroShotClassificationPipeline, error)
NewZeroShotClassificationPipeline create new Zero Shot Classification Pipeline.
func (*ZeroShotClassificationPipeline) GetMetadata ¶ added in v0.1.4
func (p *ZeroShotClassificationPipeline) GetMetadata() backends.PipelineMetadata
func (*ZeroShotClassificationPipeline) GetModel ¶ added in v0.3.0
func (p *ZeroShotClassificationPipeline) GetModel() *backends.Model
func (*ZeroShotClassificationPipeline) GetStatistics ¶ added in v0.5.9
func (p *ZeroShotClassificationPipeline) GetStatistics() backends.PipelineStatistics
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 (p *ZeroShotClassificationPipeline) Run(ctx context.Context, inputs []string) (backends.PipelineBatchOutput, error)
func (*ZeroShotClassificationPipeline) RunPipeline ¶ added in v0.1.4
func (p *ZeroShotClassificationPipeline) RunPipeline(ctx context.Context, inputs []string) (*ZeroShotOutput, error)
func (*ZeroShotClassificationPipeline) Validate ¶ added in v0.1.4
func (p *ZeroShotClassificationPipeline) 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.