Documentation
¶
Index ¶
- func WithAverageAggregation() pipelineBackends.PipelineOption[*TokenClassificationPipeline]
- func WithFirstAggregation() pipelineBackends.PipelineOption[*TokenClassificationPipeline]
- func WithHypothesisTemplate(hypothesisTemplate string) pipelineBackends.PipelineOption[*ZeroShotClassificationPipeline]
- func WithIgnoreLabels(ignoreLabels []string) pipelineBackends.PipelineOption[*TokenClassificationPipeline]
- func WithLabels(labels []string) pipelineBackends.PipelineOption[*ZeroShotClassificationPipeline]
- func WithMaxAggregation() pipelineBackends.PipelineOption[*TokenClassificationPipeline]
- func WithMultiLabel() pipelineBackends.PipelineOption[*TextClassificationPipeline]
- func WithMultilabel(multilabel bool) pipelineBackends.PipelineOption[*ZeroShotClassificationPipeline]
- func WithNormalization() pipelineBackends.PipelineOption[*FeatureExtractionPipeline]
- func WithOutputName(outputName string) pipelineBackends.PipelineOption[*FeatureExtractionPipeline]
- func WithSigmoid() pipelineBackends.PipelineOption[*TextClassificationPipeline]
- func WithSimpleAggregation() pipelineBackends.PipelineOption[*TokenClassificationPipeline]
- func WithSingleLabel() pipelineBackends.PipelineOption[*TextClassificationPipeline]
- func WithSoftmax() pipelineBackends.PipelineOption[*TextClassificationPipeline]
- func WithoutAggregation() pipelineBackends.PipelineOption[*TokenClassificationPipeline]
- type ClassificationOutput
- type Entity
- type FeatureExtractionOutput
- type FeatureExtractionPipeline
- func (p *FeatureExtractionPipeline) Forward(batch *pipelineBackends.PipelineBatch) error
- func (p *FeatureExtractionPipeline) GetMetadata() pipelineBackends.PipelineMetadata
- func (p *FeatureExtractionPipeline) GetModel() *pipelineBackends.Model
- func (p *FeatureExtractionPipeline) GetStats() []string
- func (p *FeatureExtractionPipeline) Postprocess(batch *pipelineBackends.PipelineBatch) (*FeatureExtractionOutput, error)
- func (p *FeatureExtractionPipeline) Preprocess(batch *pipelineBackends.PipelineBatch, inputs []string) error
- func (p *FeatureExtractionPipeline) Run(inputs []string) (pipelineBackends.PipelineBatchOutput, error)
- func (p *FeatureExtractionPipeline) RunPipeline(inputs []string) (*FeatureExtractionOutput, error)
- func (p *FeatureExtractionPipeline) Validate() error
- type TextClassificationOutput
- type TextClassificationPipeline
- func (p *TextClassificationPipeline) Forward(batch *pipelineBackends.PipelineBatch) error
- func (p *TextClassificationPipeline) GetMetadata() pipelineBackends.PipelineMetadata
- func (p *TextClassificationPipeline) GetModel() *pipelineBackends.Model
- func (p *TextClassificationPipeline) GetStats() []string
- func (p *TextClassificationPipeline) Postprocess(batch *pipelineBackends.PipelineBatch) (*TextClassificationOutput, error)
- func (p *TextClassificationPipeline) Preprocess(batch *pipelineBackends.PipelineBatch, inputs []string) error
- func (p *TextClassificationPipeline) Run(inputs []string) (pipelineBackends.PipelineBatchOutput, error)
- func (p *TextClassificationPipeline) RunPipeline(inputs []string) (*TextClassificationOutput, error)
- func (p *TextClassificationPipeline) Validate() error
- type TextClassificationPipelineConfig
- type TokenClassificationOutput
- type TokenClassificationPipeline
- func (p *TokenClassificationPipeline) Aggregate(input pipelineBackends.TokenizedInput, preEntities []Entity) ([]Entity, error)
- func (p *TokenClassificationPipeline) Forward(batch *pipelineBackends.PipelineBatch) error
- func (p *TokenClassificationPipeline) GatherPreEntities(input pipelineBackends.TokenizedInput, output [][]float32) []Entity
- func (p *TokenClassificationPipeline) GetMetadata() pipelineBackends.PipelineMetadata
- func (p *TokenClassificationPipeline) GetModel() *pipelineBackends.Model
- func (p *TokenClassificationPipeline) GetStats() []string
- func (p *TokenClassificationPipeline) GroupEntities(entities []Entity) ([]Entity, error)
- func (p *TokenClassificationPipeline) Postprocess(batch *pipelineBackends.PipelineBatch) (*TokenClassificationOutput, error)
- func (p *TokenClassificationPipeline) Preprocess(batch *pipelineBackends.PipelineBatch, inputs []string) error
- func (p *TokenClassificationPipeline) Run(inputs []string) (pipelineBackends.PipelineBatchOutput, error)
- func (p *TokenClassificationPipeline) RunPipeline(inputs []string) (*TokenClassificationOutput, error)
- func (p *TokenClassificationPipeline) Validate() error
- type TokenClassificationPipelineConfig
- type ZeroShotClassificationOutput
- type ZeroShotClassificationPipeline
- func (p *ZeroShotClassificationPipeline) Forward(batch *pipelineBackends.PipelineBatch) error
- func (p *ZeroShotClassificationPipeline) GetMetadata() pipelineBackends.PipelineMetadata
- func (p *ZeroShotClassificationPipeline) GetModel() *pipelineBackends.Model
- func (p *ZeroShotClassificationPipeline) GetStats() []string
- func (p *ZeroShotClassificationPipeline) Postprocess(outputTensors [][][]float32, labels []string, sequences []string) (*ZeroShotOutput, error)
- func (p *ZeroShotClassificationPipeline) Preprocess(batch *pipelineBackends.PipelineBatch, inputs []string) error
- func (p *ZeroShotClassificationPipeline) Run(inputs []string) (pipelineBackends.PipelineBatchOutput, error)
- func (p *ZeroShotClassificationPipeline) RunPipeline(inputs []string) (*ZeroShotOutput, error)
- func (p *ZeroShotClassificationPipeline) Validate() error
- type ZeroShotClassificationPipelineConfig
- type ZeroShotOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithAverageAggregation ¶
func WithAverageAggregation() pipelineBackends.PipelineOption[*TokenClassificationPipeline]
WithAverageAggregation sets the aggregation strategy for the token labels to average It reproduces simple aggregation from the huggingface implementation.
func WithFirstAggregation ¶
func WithFirstAggregation() pipelineBackends.PipelineOption[*TokenClassificationPipeline]
WithFirstAggregation sets the aggregation strategy for the token labels to first It reproduces first aggregation from the huggingface implementation.
func WithHypothesisTemplate ¶
func WithHypothesisTemplate(hypothesisTemplate string) pipelineBackends.PipelineOption[*ZeroShotClassificationPipeline]
WithHypothesisTemplate can be used to set the hypothesis template for classification.
func WithIgnoreLabels ¶
func WithIgnoreLabels(ignoreLabels []string) pipelineBackends.PipelineOption[*TokenClassificationPipeline]
func WithLabels ¶
func WithLabels(labels []string) pipelineBackends.PipelineOption[*ZeroShotClassificationPipeline]
WithLabels can be used to set the labels to classify the examples.
func WithMaxAggregation ¶
func WithMaxAggregation() pipelineBackends.PipelineOption[*TokenClassificationPipeline]
WithMaxAggregation sets the aggregation strategy for the token labels to Max It reproduces max aggregation from the huggingface implementation.
func WithMultiLabel ¶
func WithMultiLabel() pipelineBackends.PipelineOption[*TextClassificationPipeline]
func WithMultilabel ¶
func WithMultilabel(multilabel bool) pipelineBackends.PipelineOption[*ZeroShotClassificationPipeline]
WithMultilabel can be used to set whether the pipeline is multilabel.
func WithNormalization ¶
func WithNormalization() pipelineBackends.PipelineOption[*FeatureExtractionPipeline]
WithNormalization applies normalization to the mean pooled output of the feature pipeline.
func WithOutputName ¶
func WithOutputName(outputName string) pipelineBackends.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 WithSigmoid ¶
func WithSigmoid() pipelineBackends.PipelineOption[*TextClassificationPipeline]
func WithSimpleAggregation ¶
func WithSimpleAggregation() pipelineBackends.PipelineOption[*TokenClassificationPipeline]
WithSimpleAggregation sets the aggregation strategy for the token labels to simple It reproduces simple aggregation from the huggingface implementation.
func WithSingleLabel ¶
func WithSingleLabel() pipelineBackends.PipelineOption[*TextClassificationPipeline]
func WithSoftmax ¶
func WithSoftmax() pipelineBackends.PipelineOption[*TextClassificationPipeline]
func WithoutAggregation ¶
func WithoutAggregation() pipelineBackends.PipelineOption[*TokenClassificationPipeline]
WithoutAggregation returns the token labels.
Types ¶
type ClassificationOutput ¶
type FeatureExtractionOutput ¶
type FeatureExtractionOutput struct {
Embeddings [][]float32
}
func (*FeatureExtractionOutput) GetOutput ¶
func (t *FeatureExtractionOutput) GetOutput() []any
type FeatureExtractionPipeline ¶
type FeatureExtractionPipeline struct { *pipelineBackends.BasePipeline Normalization bool OutputName string Output pipelineBackends.InputOutputInfo }
FeatureExtractionPipeline A feature extraction pipeline is a go version of https://github.com/huggingface/transformers/blob/main/src/transformers/pipelines/feature_extraction.py
func NewFeatureExtractionPipeline ¶
func NewFeatureExtractionPipeline(config pipelineBackends.PipelineConfig[*FeatureExtractionPipeline], s *options.Options, model *pipelineBackends.Model) (*FeatureExtractionPipeline, error)
NewFeatureExtractionPipeline init a feature extraction pipeline.
func (*FeatureExtractionPipeline) Forward ¶
func (p *FeatureExtractionPipeline) Forward(batch *pipelineBackends.PipelineBatch) error
Forward performs the forward inference of the feature extraction pipeline.
func (*FeatureExtractionPipeline) GetMetadata ¶
func (p *FeatureExtractionPipeline) GetMetadata() pipelineBackends.PipelineMetadata
GetMetadata returns metadata information about the pipeline, in particular: OutputInfo: names and dimensions of the output layer.
func (*FeatureExtractionPipeline) GetModel ¶
func (p *FeatureExtractionPipeline) GetModel() *pipelineBackends.Model
func (*FeatureExtractionPipeline) GetStats ¶
func (p *FeatureExtractionPipeline) GetStats() []string
GetStats returns the runtime statistics for the pipeline.
func (*FeatureExtractionPipeline) Postprocess ¶
func (p *FeatureExtractionPipeline) Postprocess(batch *pipelineBackends.PipelineBatch) (*FeatureExtractionOutput, error)
Postprocess parses the first output from the network similar to the transformers' implementation.
func (*FeatureExtractionPipeline) Preprocess ¶
func (p *FeatureExtractionPipeline) Preprocess(batch *pipelineBackends.PipelineBatch, inputs []string) error
Preprocess tokenizes the input strings.
func (*FeatureExtractionPipeline) Run ¶
func (p *FeatureExtractionPipeline) Run(inputs []string) (pipelineBackends.PipelineBatchOutput, error)
Run the pipeline on a batch of strings.
func (*FeatureExtractionPipeline) RunPipeline ¶
func (p *FeatureExtractionPipeline) RunPipeline(inputs []string) (*FeatureExtractionOutput, error)
RunPipeline is like Run, but returns the concrete feature extraction output type rather than the interface.
func (*FeatureExtractionPipeline) Validate ¶
func (p *FeatureExtractionPipeline) Validate() error
Validate checks that the pipeline is valid.
type TextClassificationOutput ¶
type TextClassificationOutput struct {
ClassificationOutputs [][]ClassificationOutput
}
func (*TextClassificationOutput) GetOutput ¶
func (t *TextClassificationOutput) GetOutput() []any
type TextClassificationPipeline ¶
type TextClassificationPipeline struct { *pipelineBackends.BasePipeline IDLabelMap map[int]string AggregationFunctionName string ProblemType string }
func NewTextClassificationPipeline ¶
func NewTextClassificationPipeline(config pipelineBackends.PipelineConfig[*TextClassificationPipeline], s *options.Options, model *pipelineBackends.Model) (*TextClassificationPipeline, error)
NewTextClassificationPipeline initializes a new text classification pipeline.
func (*TextClassificationPipeline) Forward ¶
func (p *TextClassificationPipeline) Forward(batch *pipelineBackends.PipelineBatch) error
func (*TextClassificationPipeline) GetMetadata ¶
func (p *TextClassificationPipeline) GetMetadata() pipelineBackends.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 ¶
func (p *TextClassificationPipeline) GetModel() *pipelineBackends.Model
func (*TextClassificationPipeline) GetStats ¶
func (p *TextClassificationPipeline) GetStats() []string
GetStats returns the runtime statistics for the pipeline.
func (*TextClassificationPipeline) Postprocess ¶
func (p *TextClassificationPipeline) Postprocess(batch *pipelineBackends.PipelineBatch) (*TextClassificationOutput, error)
func (*TextClassificationPipeline) Preprocess ¶
func (p *TextClassificationPipeline) Preprocess(batch *pipelineBackends.PipelineBatch, inputs []string) error
Preprocess tokenizes the input strings.
func (*TextClassificationPipeline) Run ¶
func (p *TextClassificationPipeline) Run(inputs []string) (pipelineBackends.PipelineBatchOutput, error)
Run the pipeline on a string batch.
func (*TextClassificationPipeline) RunPipeline ¶
func (p *TextClassificationPipeline) RunPipeline(inputs []string) (*TextClassificationOutput, error)
func (*TextClassificationPipeline) Validate ¶
func (p *TextClassificationPipeline) Validate() error
Validate checks that the pipeline is valid.
type TokenClassificationOutput ¶
type TokenClassificationOutput struct {
Entities [][]Entity
}
func (*TokenClassificationOutput) GetOutput ¶
func (t *TokenClassificationOutput) GetOutput() []any
type TokenClassificationPipeline ¶
type TokenClassificationPipeline struct { *pipelineBackends.BasePipeline IDLabelMap map[int]string AggregationStrategy string IgnoreLabels []string }
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(config pipelineBackends.PipelineConfig[*TokenClassificationPipeline], s *options.Options, model *pipelineBackends.Model) (*TokenClassificationPipeline, error)
NewTokenClassificationPipeline Initializes a feature extraction pipeline.
func (*TokenClassificationPipeline) Aggregate ¶
func (p *TokenClassificationPipeline) Aggregate(input pipelineBackends.TokenizedInput, preEntities []Entity) ([]Entity, error)
func (*TokenClassificationPipeline) Forward ¶
func (p *TokenClassificationPipeline) Forward(batch *pipelineBackends.PipelineBatch) error
Forward performs the forward inference of the pipeline.
func (*TokenClassificationPipeline) GatherPreEntities ¶
func (p *TokenClassificationPipeline) GatherPreEntities(input pipelineBackends.TokenizedInput, output [][]float32) []Entity
GatherPreEntities from batch of logits to list of pre-aggregated outputs.
func (*TokenClassificationPipeline) GetMetadata ¶
func (p *TokenClassificationPipeline) GetMetadata() pipelineBackends.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 ¶
func (p *TokenClassificationPipeline) GetModel() *pipelineBackends.Model
func (*TokenClassificationPipeline) GetStats ¶
func (p *TokenClassificationPipeline) GetStats() []string
GetStats returns the runtime statistics for the pipeline.
func (*TokenClassificationPipeline) GroupEntities ¶
func (p *TokenClassificationPipeline) GroupEntities(entities []Entity) ([]Entity, error)
GroupEntities group together adjacent tokens with the same entity predicted.
func (*TokenClassificationPipeline) Postprocess ¶
func (p *TokenClassificationPipeline) Postprocess(batch *pipelineBackends.PipelineBatch) (*TokenClassificationOutput, error)
Postprocess function for a token classification pipeline.
func (*TokenClassificationPipeline) Preprocess ¶
func (p *TokenClassificationPipeline) Preprocess(batch *pipelineBackends.PipelineBatch, inputs []string) error
Preprocess tokenizes the input strings.
func (*TokenClassificationPipeline) Run ¶
func (p *TokenClassificationPipeline) Run(inputs []string) (pipelineBackends.PipelineBatchOutput, error)
Run the pipeline on a string batch.
func (*TokenClassificationPipeline) RunPipeline ¶
func (p *TokenClassificationPipeline) RunPipeline(inputs []string) (*TokenClassificationOutput, error)
RunPipeline is like Run but returns the concrete type rather than the interface.
func (*TokenClassificationPipeline) Validate ¶
func (p *TokenClassificationPipeline) Validate() error
Validate checks that the pipeline is valid.
type ZeroShotClassificationPipeline ¶
type ZeroShotClassificationPipeline struct { *pipelineBackends.BasePipeline IDLabelMap map[int]string Sequences []string Labels []string HypothesisTemplate string Multilabel bool // contains filtered or unexported fields }
func NewZeroShotClassificationPipeline ¶
func NewZeroShotClassificationPipeline(config pipelineBackends.PipelineConfig[*ZeroShotClassificationPipeline], s *options.Options, model *pipelineBackends.Model) (*ZeroShotClassificationPipeline, error)
NewZeroShotClassificationPipeline create new Zero Shot Classification Pipeline.
func (*ZeroShotClassificationPipeline) Forward ¶
func (p *ZeroShotClassificationPipeline) Forward(batch *pipelineBackends.PipelineBatch) error
func (*ZeroShotClassificationPipeline) GetMetadata ¶
func (p *ZeroShotClassificationPipeline) GetMetadata() pipelineBackends.PipelineMetadata
func (*ZeroShotClassificationPipeline) GetModel ¶
func (p *ZeroShotClassificationPipeline) GetModel() *pipelineBackends.Model
func (*ZeroShotClassificationPipeline) GetStats ¶
func (p *ZeroShotClassificationPipeline) GetStats() []string
func (*ZeroShotClassificationPipeline) Postprocess ¶
func (p *ZeroShotClassificationPipeline) Postprocess(outputTensors [][][]float32, labels []string, sequences []string) (*ZeroShotOutput, error)
func (*ZeroShotClassificationPipeline) Preprocess ¶
func (p *ZeroShotClassificationPipeline) Preprocess(batch *pipelineBackends.PipelineBatch, inputs []string) error
func (*ZeroShotClassificationPipeline) Run ¶
func (p *ZeroShotClassificationPipeline) Run(inputs []string) (pipelineBackends.PipelineBatchOutput, error)
func (*ZeroShotClassificationPipeline) RunPipeline ¶
func (p *ZeroShotClassificationPipeline) RunPipeline(inputs []string) (*ZeroShotOutput, error)
func (*ZeroShotClassificationPipeline) Validate ¶
func (p *ZeroShotClassificationPipeline) Validate() error
type ZeroShotOutput ¶
type ZeroShotOutput struct {
ClassificationOutputs []ZeroShotClassificationOutput
}
func (*ZeroShotOutput) GetOutput ¶
func (t *ZeroShotOutput) GetOutput() []any
GetOutput converts raw output to readable output.