ZeroShotClassificationPipeline
The pipeline allows easily run zero-shot text classification with fine-tuned cross-encoders.
(args_parser=ZeroShotClassificationArgumentHandler(), *args, **kwargs)Using ZeroShotClassificationPipeline:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from liqfit.pipeline import ZeroShotClassificationPipeline
sequence_to_classify = "one day I will see the world"
candidate_labels = ['travel', 'cooking', 'dancing']
template = 'This example is {}.'
model_path = 'knowledgator/comprehend_it-base'
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForSequenceClassification.from_pretrained(model_path)
classifier = ZeroShotClassificationPipeline(model=self.model,
tokenizer=self.tokenizer,
hypothesis_template = self.template
)
results = classifier(self.sequence_to_classify, self.candidate_labels, multi_label=True)
print(results)Last updated