Zero-Shot Classification
Transformers
Safetensors
PyTorch
English
zero-shot
multi-label
text-classification
Instructions to use polodealvarado/polyencoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use polodealvarado/polyencoder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-classification", model="polodealvarado/polyencoder")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("polodealvarado/polyencoder", device_map="auto") - Notebooks
- Google Colab
- Kaggle
| language: | |
| - en | |
| license: mit | |
| library_name: transformers | |
| pipeline_tag: zero-shot-classification | |
| tags: | |
| - zero-shot | |
| - multi-label | |
| - text-classification | |
| - pytorch | |
| metrics: | |
| - precision | |
| - recall | |
| - f1 | |
| base_model: bert-base-uncased | |
| datasets: | |
| - polodealvarado/zeroshot-classification | |
| # Zero-Shot Text Classification — polyencoder | |
| Learnable poly-codes with label-conditioned cross-attention. | |
| This model encodes texts and candidate labels into a shared embedding space using BERT, | |
| enabling classification into arbitrary categories without retraining for new labels. | |
| ## Training Details | |
| | Parameter | Value | | |
| |-----------|-------| | |
| | Base model | `bert-base-uncased` | | |
| | Model variant | `polyencoder` | | |
| | Training steps | 1000 | | |
| | Batch size | 2 | | |
| | Learning rate | 2e-05 | | |
| | Trainable params | 109,494,528 | | |
| | Training time | 359.7s | | |
| ## Dataset | |
| Trained on [polodealvarado/zeroshot-classification](https://huggingface.co/datasets/polodealvarado/zeroshot-classification). | |
| ## Evaluation Results | |
| | Metric | Score | | |
| |--------|-------| | |
| | Precision | 0.9463 | | |
| | Recall | 0.9677 | | |
| | F1 Score | 0.9569 | | |
| ## Usage | |
| ```python | |
| from models.polyencoder import PolyEncoderModel | |
| model = PolyEncoderModel.from_pretrained("polodealvarado/polyencoder") | |
| predictions = model.predict( | |
| texts=["The stock market crashed yesterday."], | |
| labels=[["Finance", "Sports", "Biology", "Economy"]], | |
| ) | |
| print(predictions) | |
| # [{"text": "...", "scores": {"Finance": 0.98, "Economy": 0.85, ...}}] | |
| ``` | |