pipelines

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 16 Imported by: 9

Documentation

Index

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

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

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

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

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 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 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 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 WithTopKAnswers added in v0.7.0

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 WithoutAggregation

WithoutAggregation returns the token labels.

Types

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], s *options.Options, 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 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 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 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

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) 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 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 (*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 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 (*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 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

type QuestionAnsweringInput struct {
	Question string
	Context  string
}

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

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

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

Run implements the Pipeline interface. Inputs are interleaved [question0, context0, question1, context1, …].

func (*QuestionAnsweringPipeline) RunPipeline added in v0.7.0

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

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

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 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 (*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) 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

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) 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 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], s *options.Options, 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) 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.

Jump to

Keyboard shortcuts

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