Compared to our previous zero-shot classifier based on BETO, zero-shot SELECTRA is much more lightweight. As shown in the Metrics section, the small version (with 5 times fewer parameters) performs slightly worse, while the medium version (with 3 times fewer parameters) outperforms the BETO-based zero-shot classifier.
🚀 Quick Start
Get started with the Zero-shot SELECTRA classifier right away.
✨ Features
Lightweight: Significantly reduces the number of parameters compared to the previous BETO-based classifier.
High Performance: The medium version outperforms the BETO-based zero-shot classifier.
Zero-shot Classification: Enables classifications without the need for task-specific training data.
📦 Installation
No specific installation steps are provided in the original document.
💻 Usage Examples
Basic Usage
from transformers import pipeline
classifier = pipeline("zero-shot-classification",
model="Recognai/zeroshot_selectra_medium")
classifier(
"El autor se perfila, a los 50 años de su muerte, como uno de los grandes de su siglo",
candidate_labels=["cultura", "sociedad", "economia", "salud", "deportes"],
hypothesis_template="Este ejemplo es {}."
)
"""Output
{'sequence': 'El autor se perfila, a los 50 años de su muerte, como uno de los grandes de su siglo',
'labels': ['sociedad', 'cultura', 'economia', 'salud', 'deportes'],
'scores': [0.6450043320655823,
0.16710571944713593,
0.08507631719112396,
0.0759836807847023,
0.026829993352293968]}
"""
⚠️ Important Note
The hypothesis_template parameter is important and should be in Spanish. In the widget on the right, this parameter is set to its default value: "This example is {}.", so different results are expected.
📚 Documentation
Demo and tutorial
If you want to see this model in action, we have created a basic tutorial using Rubrix, a free and open-source tool to explore, annotate, and monitor data for NLP.
The tutorial shows you how to evaluate this classifier for news categorization in Spanish, and how it could be used to build a training set for training a supervised classifier (which might be useful if you want obtain more precise results or improve the model over time).
XNLI: The stated accuracy refers to the test portion of the XNLI dataset, after finetuning the model on the training portion.
MLSUM: For this accuracy we take the test set of the MLSUM dataset and classify the summaries of 5 selected labels. For details, check out our evaluation notebook