Classifier models

more info here

Base Classifier

class src.models.classifier.base.ClassifierModel(config: Config, logger: Logger, model_id: str, taxonomy: Taxonomy)[source]

Bases: Model

Custom classifier base model

This model implements the custom base for classifier models, it has minor adaptations compared to the original base model

_load_model(model_id: str) None[source]

This function enables custom model preperations before executing the classification

Parameters:

model_id – model_id to pull

Returns:

classify(text: str, multi_label, **kwargs) dict[str, float][source]

Abstract function that executes the text classificatoin

Parameters:
  • text – the text to classify

  • multi_label – boolean to identify if it is a multilabel problem

  • kwargs – potential extra vars

Returns:

the results

Huggingface Classifier

class src.models.classifier.huggingface.HuggingfaceModel(config: Config, logger: Logger, model_id: str, taxonomy: Taxonomy, stage: str = 'Production')[source]

Bases: Model

_load_model(model_id: str, stage: str) None[source]

This function enables custom model preperations before executing the classification

Parameters:

model_id – model_id to pull

Returns:

classify(text: str, multi_label: bool = True, **kwargs) dict[str, float][source]

Abstract function that executes the text classificatoin

Parameters:
  • text – the text to classify

  • multi_label – boolean to identify if it is a multilabel problem

  • kwargs – potential extra vars

Returns:

the results

Setfit Classifier