zeroshotclassifier

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultHypothesisTemplate is the string template that is interpolated with each class to predict.
	DefaultHypothesisTemplate = "This example is {}."
)
View Source
const (
	// DefaultModel is a model for Natural Language Inference (NLI) that can be used for zero-shot classification.
	// Model card: https://huggingface.co/valhalla/distilbart-mnli-12-3
	DefaultModel = "valhalla/distilbart-mnli-12-3"
)

Variables

View Source
var ErrInputSequenceTooLong = errors.New("input sequence too long")

ErrInputSequenceTooLong means that pre-processing the input text produced a sequence that exceeds the maximum allowed length.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// Classify returns the classification of the given example.
	Classify(ctx context.Context, text string, parameters Parameters) (Response, error)
}

Interface defines the main functions for zero-shot classification task.

type Parameters

type Parameters struct {
	// A list of strings that are potential classes for inputs. (required)
	CandidateLabels []string
	// HypothesisTemplate is the string template that is interpolated with each class to predict.
	// For example, “this text is about {}”. (optional)
	HypothesisTemplate string
	// MultiLabel set to True if classes can overlap (default: false)
	MultiLabel bool
}

Parameters contains the parameters for zero-shot classification.

type Response

type Response struct {
	// The list of labels sent in the request, sorted in descending order
	// by probability that the input corresponds to the label.
	Labels []string
	// a list of floats that correspond the probability of label, in the same order as labels.
	Scores []float64
}

Response contains the response from zero-shot classification.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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