langtest.modelhandler.spacy_modelhandler.PretrainedModelForTextClassification#

class PretrainedModelForTextClassification(model)#

Bases: ModelAPI

SpaCy pretrained model for text classification tasks

Parameters:

model – Pretrained SpaCy pipeline.

__init__(model)#

Constructor method

Parameters:

model – pretrained SpaCy pipeline

Methods

__init__(model)

Constructor method

load_model(path)

Load and return SpaCy pipeline

predict(text[, return_all_scores])

Perform text classification predictions on the input text.

predict_raw(text)

Perform classification predictions on input text.

Attributes

labels

Return classification labels of SpaCy model.

model_registry

property labels#

Return classification labels of SpaCy model.

classmethod load_model(path: str)#

Load and return SpaCy pipeline

Parameters:

path (str) – name of path to model to load

predict(text: str, return_all_scores: bool = False, *args, **kwargs) SequenceClassificationOutput#

Perform text classification predictions on the input text.

Parameters:
  • text (str) – Input text to classify.

  • return_all_scores (bool) – Option to return score for all labels.

Returns:

Text classification predictions from the input text.

Return type:

SequenceClassificationOutput

predict_raw(text: str) List[str]#

Perform classification predictions on input text.

Parameters:

text (str) – Input text to classify.

Returns:

Predictions of the model.

Return type:

List[str]