🚀 Zero-shot SELECTRA: A zero-shot classifier based on SELECTRA
Zero-shot SELECTRA is a SELECTRA model fine-tuned on the Spanish portion of the XNLI dataset. It can be used with Hugging Face's Zero-shot pipeline to perform zero-shot classifications.
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
✨ Features
- Based on the SELECTRA model fine-tuned on the Spanish part of the XNLI dataset.
- Can be used with Hugging Face's Zero-shot pipeline for zero-shot classifications.
- More lightweight compared to the previous BETO-based zero-shot classifier.
📦 Installation
No specific installation steps are provided in the original document, so this section is skipped.
💻 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', 'salud', 'economia', 'deportes'],
'scores': [0.3711881935596466,
0.25650349259376526,
0.17355826497077942,
0.1641489565372467,
0.03460107371211052]}
"""
⚠️ 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
Metrics
Property |
Details |
Model Type |
zs BETO, zs SELECTRA medium, zs SELECTRA small |
Params |
110M (zs BETO), 41M (zs SELECTRA medium), 22M (zs SELECTRA small) |
XNLI (acc) |
0.799 (zs BETO), 0.807 (zs SELECTRA medium), 0.795 (zs SELECTRA small) |
MLSUM (acc) |
0.530 (zs BETO), 0.589 (zs SELECTRA medium), 0.446 (zs SELECTRA small) |
- 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
Training
Check out our training notebook for all the details.
Authors
📄 License
This project is licensed under the apache-2.0 license.