Documentation
¶
Index ¶
- func PrintTokenEntities(o TokenClassificationOutput)
- type BasePipeline
- func (p *BasePipeline) Destroy() error
- func (p *BasePipeline) Forward(batch PipelineBatch) (PipelineBatch, error)
- func (p *BasePipeline) GetOutputDim() int
- func (p *BasePipeline) GetStats() []string
- func (p *BasePipeline) Preprocess(inputs []string) PipelineBatch
- func (p *BasePipeline) SetSessionOptions() error
- type ClassificationOutput
- type FeatureExtractionOutput
- type FeatureExtractionPipeline
- type Pipeline
- type PipelineBatch
- type TextClassificationOption
- type TextClassificationOutput
- type TextClassificationPipeline
- type TextClassificationPipelineConfig
- type Timings
- type TokenClassificationOption
- type TokenClassificationOutput
- type TokenClassificationPipeline
- func (p *TokenClassificationPipeline) Aggregate(input TokenizedInput, preEntities []entity) ([]entity, error)
- func (p *TokenClassificationPipeline) GatherPreEntities(input TokenizedInput, output [][]float32) []entity
- func (p *TokenClassificationPipeline) GroupEntities(entities []entity) ([]entity, error)
- func (p *TokenClassificationPipeline) Postprocess(batch PipelineBatch) (TokenClassificationOutput, error)
- func (p *TokenClassificationPipeline) Run(inputs []string) (TokenClassificationOutput, error)
- type TokenClassificationPipelineConfig
- type TokenizedInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintTokenEntities ¶
func PrintTokenEntities(o TokenClassificationOutput)
Types ¶
type BasePipeline ¶
type BasePipeline struct { ModelPath string PipelineName string OrtSession *ort.DynamicAdvancedSession OrtOptions *ort.SessionOptions Tokenizer *tokenizers.Tokenizer TokenizerOptions []tokenizers.EncodeOption InputsMeta []ort.InputOutputInfo OutputsMeta []ort.InputOutputInfo OutputDim int TokenizerTimings *Timings PipelineTimings *Timings // contains filtered or unexported fields }
BasePipeline is a basic pipeline type used for struct composition in the other pipelines
func (*BasePipeline) Destroy ¶
func (p *BasePipeline) Destroy() error
func (*BasePipeline) Forward ¶
func (p *BasePipeline) Forward(batch PipelineBatch) (PipelineBatch, error)
Forward pass of the neural network on the tokenized input
func (*BasePipeline) GetOutputDim ¶
func (p *BasePipeline) GetOutputDim() int
func (*BasePipeline) GetStats ¶
func (p *BasePipeline) GetStats() []string
func (*BasePipeline) Preprocess ¶
func (p *BasePipeline) Preprocess(inputs []string) PipelineBatch
Preprocess the input strings in the batch
func (*BasePipeline) SetSessionOptions ¶
func (p *BasePipeline) SetSessionOptions() error
type ClassificationOutput ¶
type FeatureExtractionOutput ¶
type FeatureExtractionOutput [][]float32
type FeatureExtractionPipeline ¶
type FeatureExtractionPipeline struct {
BasePipeline
}
func NewFeatureExtractionPipeline ¶
func NewFeatureExtractionPipeline(modelPath string, name string) (*FeatureExtractionPipeline, error)
NewFeatureExtractionPipeline Initialize a feature extraction pipeline
func (*FeatureExtractionPipeline) Postprocess ¶
func (p *FeatureExtractionPipeline) Postprocess(batch PipelineBatch) (FeatureExtractionOutput, error)
Postprocess Parse the results of the forward pass into the output. Token embeddings are mean pooled.
func (*FeatureExtractionPipeline) Run ¶
func (p *FeatureExtractionPipeline) Run(inputs []string) (FeatureExtractionOutput, error)
Run the pipeline on a string batch
type PipelineBatch ¶
type TextClassificationOption ¶
type TextClassificationOption func(eo *TextClassificationPipeline)
func WithAggregationFunction ¶
func WithAggregationFunction(aggregationFunction func([]float32) []float32) TextClassificationOption
type TextClassificationOutput ¶
type TextClassificationOutput [][]ClassificationOutput
type TextClassificationPipeline ¶
type TextClassificationPipeline struct { BasePipeline IdLabelMap map[int]string AggregationFunction func([]float32) []float32 }
func NewTextClassificationPipeline ¶
func NewTextClassificationPipeline(modelPath string, name string, opts ...TextClassificationOption) (*TextClassificationPipeline, error)
NewTextClassificationPipeline initializes a new text classification pipeline
func (*TextClassificationPipeline) Forward ¶
func (p *TextClassificationPipeline) Forward(batch PipelineBatch) (PipelineBatch, error)
func (*TextClassificationPipeline) Postprocess ¶
func (p *TextClassificationPipeline) Postprocess(batch PipelineBatch) (TextClassificationOutput, error)
func (*TextClassificationPipeline) Run ¶
func (p *TextClassificationPipeline) Run(inputs []string) (TextClassificationOutput, error)
Run the pipeline on a string batch
type TokenClassificationOption ¶
type TokenClassificationOption func(eo *TokenClassificationPipeline)
func WithIgnoreLabels ¶
func WithIgnoreLabels(ignoreLabels []string) TokenClassificationOption
func WithSimpleAggregation ¶
func WithSimpleAggregation() TokenClassificationOption
func WithoutAggregation ¶
func WithoutAggregation() TokenClassificationOption
type TokenClassificationOutput ¶
type TokenClassificationOutput [][]entity
type TokenClassificationPipeline ¶
type TokenClassificationPipeline struct { BasePipeline IdLabelMap map[int]string AggregationStrategy string IgnoreLabels []string }
func NewTokenClassificationPipeline ¶
func NewTokenClassificationPipeline(modelPath string, name string, opts ...TokenClassificationOption) (*TokenClassificationPipeline, error)
NewTokenClassificationPipeline Initializes a feature extraction pipeline
func (*TokenClassificationPipeline) Aggregate ¶
func (p *TokenClassificationPipeline) Aggregate(input TokenizedInput, preEntities []entity) ([]entity, error)
func (*TokenClassificationPipeline) GatherPreEntities ¶
func (p *TokenClassificationPipeline) GatherPreEntities(input TokenizedInput, output [][]float32) []entity
GatherPreEntities from batch of logits to list of pre-aggregated outputs
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 PipelineBatch) (TokenClassificationOutput, error)
Postprocess function for a token classification pipeline
func (*TokenClassificationPipeline) Run ¶
func (p *TokenClassificationPipeline) Run(inputs []string) (TokenClassificationOutput, error)
Run the pipeline on a string batch