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 ¶
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.
Click to show internal directories.
Click to hide internal directories.