setfit safetensors bert sentence-transformers text-classification generated_from_setfit_trainer arxiv:2209.11055 region:us
---
library_name: setfit
metrics:
- accuracy
pipeline_tag: text-classification
tags:
- setfit
- sentence-transformers
- text-classification
- generated_from_setfit_trainer
widget:
- text: Lewis Hamilton pide perdón tras ser acusado de sexista por burlarse de su
    sobrino
- text: 'Nuevas revelaciones del FIFA Gate: una cuenta ultra secreta y el temor reverencial
    a Julio Grondona'
- text: Hallaron una inmensa `huella digital` en el espacio
- text: Qué hacía Gastón Pauls viendo a la Selección con Lionel Messi y Sergio Agüero
- text: 'Bitcoin: la volatilidad de las últimas semanas abre el debate sobre el futuro
    de la moneda'
inference: true
---

# SetFit

This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. A [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance is used for classification.

The model has been trained using an efficient few-shot learning technique that involves:

1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
2. Training a classification head with features from the fine-tuned Sentence Transformer.

## Model Details

### Model Description
- **Model Type:** SetFit
<!-- - **Sentence Transformer:** [Unknown](https://huggingface.co/unknown) -->
- **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
- **Maximum Sequence Length:** 512 tokens
- **Number of Classes:** 2 classes
<!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
<!-- - **Language:** Unknown -->
<!-- - **License:** Unknown -->

### Model Sources

- **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
- **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
- **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)

### Model Labels
| Label       | Examples                                                                                                                                                                                                                                                                  |
|:------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Evento      | <ul><li>'El dólar vuelve a subir a la espera de una decisión clave del Banco Central'</li><li>'Viernes caluroso y sin lluvias'</li><li>'ARA San Juan | El dolor de los familiares tras la retirada de EEUU: `Nos están dejando sin recursos para buscar`'</li></ul>       |
| Perspectiva | <ul><li>'El futuro de la educación tras la pandemia: ¿hacia un modelo híbrido permanente?'</li><li>'¿Cómo impacta la automatización en los trabajos de baja calificación?'</li><li>'Feminicidios: Falta una construcción social y cultural contra la violencia'</li></ul> |

## Uses

### Direct Use for Inference

First install the SetFit library:

```bash
pip install setfit
```

Then you can load this model and run inference.

```python
from setfit import SetFitModel

# Download from the 🤗 Hub
model = SetFitModel.from_pretrained("EmanuelOrler/setfit-spanish-event-perspective")
# Run inference
preds = model("Hallaron una inmensa `huella digital` en el espacio")
```

<!--
### Downstream Use

*List how someone could finetune this model on their own dataset.*
-->

<!--
### Out-of-Scope Use

*List how the model may foreseeably be misused and address what users ought not to do with the model.*
-->

<!--
## Bias, Risks and Limitations

*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
-->

<!--
### Recommendations

*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
-->

## Training Details

### Training Set Metrics
| Training set | Min | Median  | Max |
|:-------------|:----|:--------|:----|
| Word count   | 5   | 12.9231 | 24  |

| Label       | Training Sample Count |
|:------------|:----------------------|
| Evento      | 22                    |
| Perspectiva | 17                    |

### Training Hyperparameters
- batch_size: (12, 12)
- num_epochs: (4, 16)
- max_steps: -1
- sampling_strategy: undersampling
- body_learning_rate: (2e-05, 1e-05)
- head_learning_rate: 0.01
- loss: CosineSimilarityLoss
- distance_metric: cosine_distance
- margin: 0.25
- end_to_end: False
- use_amp: False
- warmup_proportion: 0.1
- l2_weight: 0.01
- seed: 42
- evaluation_strategy: steps
- eval_max_steps: -1
- load_best_model_at_end: True

### Training Results
| Epoch  | Step | Training Loss | Validation Loss |
|:------:|:----:|:-------------:|:---------------:|
| 0.0159 | 1    | 0.0885        | -               |
| 0.1587 | 10   | 0.3927        | 0.2944          |
| 0.3175 | 20   | 0.3039        | 0.2387          |
| 0.4762 | 30   | 0.2466        | 0.1807          |
| 0.6349 | 40   | 0.2049        | 0.1686          |
| 0.7937 | 50   | 0.1803        | 0.1786          |
| 0.9524 | 60   | 0.1319        | 0.2002          |
| 1.1111 | 70   | 0.045         | 0.3103          |
| 1.2698 | 80   | 0.0099        | 0.3200          |
| 1.4286 | 90   | 0.0036        | 0.3845          |
| 1.5873 | 100  | 0.0021        | 0.4078          |
| 1.7460 | 110  | 0.0011        | 0.4184          |
| 1.9048 | 120  | 0.0011        | 0.4186          |
| 2.0635 | 130  | 0.0009        | 0.4282          |
| 2.2222 | 140  | 0.0008        | 0.4242          |
| 2.3810 | 150  | 0.0008        | 0.4269          |
| 2.5397 | 160  | 0.0007        | 0.4303          |
| 2.6984 | 170  | 0.0006        | 0.4301          |
| 2.8571 | 180  | 0.0006        | 0.4321          |
| 3.0159 | 190  | 0.0006        | 0.4311          |
| 3.1746 | 200  | 0.0005        | 0.4291          |
| 3.3333 | 210  | 0.0006        | 0.4322          |
| 3.4921 | 220  | 0.0005        | 0.4315          |
| 3.6508 | 230  | 0.0005        | 0.4308          |
| 3.8095 | 240  | 0.0005        | 0.4307          |
| 3.9683 | 250  | 0.0004        | 0.4312          |

### Framework Versions
- Python: 3.10.14
- SetFit: 1.1.0
- Sentence Transformers: 3.2.1
- Transformers: 4.44.0
- PyTorch: 2.4.0
- Datasets: 2.21.0
- Tokenizers: 0.19.1

## Citation

### BibTeX
```bibtex
@article{https://doi.org/10.48550/arxiv.2209.11055,
    doi = {10.48550/ARXIV.2209.11055},
    url = {https://arxiv.org/abs/2209.11055},
    author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
    keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
    title = {Efficient Few-Shot Learning Without Prompts},
    publisher = {arXiv},
    year = {2022},
    copyright = {Creative Commons Attribution 4.0 International}
}
```

<!--
## Glossary

*Clearly define terms in order to be accessible across audiences.*
-->

<!--
## Model Card Authors

*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
-->

<!--
## Model Card Contact

*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
-->