textclassification

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 (
	// DefaultModelForItalianNewsClassification is a model fine-tuned for news headlines classification in Italian.
	// It predicts the top-level category of the IPTC subject taxonomy: https://cv.iptc.org/newscodes/subjectcode
	// Model card: https://huggingface.co/nlpodyssey/bert-italian-uncased-iptc-headlines
	DefaultModelForItalianNewsClassification = "nlpodyssey/bert-italian-uncased-iptc-headlines"

	// DefaultModelForGeographicCategorizationMulti is a multilingual model fine-tuned to perform geographic
	// classification of news headlines. It predicts the ISO 3166-1 alpha-3 country codes.
	// Model card: https://huggingface.co/nlpodyssey/bert-multilingual-uncased-geo-countries-headlines
	DefaultModelForGeographicCategorizationMulti = "nlpodyssey/bert-multilingual-uncased-geo-countries-headlines"
)

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

func Filter

func Filter(keepThreshold, keepSumThreshold float64) func(r Response) Response

Filter returns a function to filter the classification response with respect to two parameters, keepThreshold and keepSumThreshold, which are used to check whether to consider the single prediction, and to check whether the sum of all collected prediction scores allows a result to be returned or not, respectively.

Types

type Interface

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

Interface defines the main functions for text classification task.

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 text classification.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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