
# SetFit with sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2

This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2) as the Sentence Transformer embedding model. 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 body:** [sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2)
- **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
- **Maximum Sequence Length:** 128 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
|:------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 0     | <ul><li>'O kit se chama GD Plus, a caixa preta é onde a energia da placa fica armazenada, ela tem três saídas para lâmpadas e uma USB para carregar qualquer coisa...'</li><li>'Faz uma oração antes e tenta conversar com ela'</li><li>'Vagabunda 🤮🤮🤮🤮💩💩💩💩, bruxa escrota...'</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| 1     | <ul><li>'Sério, ela era MUITO FEIA. Sabe a fêmea do macaco nesse nível, favelada e com linguajar de negra'</li><li>'Se tirar esse cabelo duro e clarear essa subaca preta encardida.... dá pra comer beijando'</li><li>'A verdade seja dita uma raça que foi introduzida no país, uma raça que em nenhum continente existia a não ser no africano, onde suq introdução serviu somente para um trabalho escravo e sem valor, de baixo custo operacional onde poderia ser substituido por outro, a qualquer momento, com o passar dos anos o trabalho escravo abolido, não foi desenvolvida nenhuma lei de devolução desta raça ao seu continente de origem, onde aqui ficando, se aglomeraram dando origem às favelas e toda vida marginal que temos hoje, e isto é fato, como hoje aceitar como normal, como igualar um negro a um branco, com toda essa agenda globalista, pra nos fazer aceitar goela abaixo isso como normal, em campanhas publicitárias, tv, novelas, filmes. Toda essa merda que vemos hoje no mundo é por colocar o negro numa posição social que não lhe convem, pois eles mesmos quando em ascensão são cheios de revoltas. Cada qual em seu lugar.'</li></ul> |

## Evaluation

### Metrics
| Label   | Accuracy |
|:--------|:---------|
| **all** | 0.8723   |

## 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("leofn3/modelo_racismo_setfit_5jan24")
# Run inference
preds = model("macacos são mais espertos que homens pretos")
```

<!--
### 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   | 1   | 21.8855 | 467 |

| Label | Training Sample Count |
|:------|:----------------------|
| 0     | 690                   |
| 1     | 786                   |

### Training Hyperparameters
- batch_size: (16, 16)
- num_epochs: (4, 4)
- max_steps: -1
- sampling_strategy: oversampling
- num_iterations: 10
- 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
- seed: 42
- eval_max_steps: -1
- load_best_model_at_end: True

### Training Results
| Epoch   | Step     | Training Loss | Validation Loss |
|:-------:|:--------:|:-------------:|:---------------:|
| 0.0005  | 1        | 0.264         | -               |
| 0.0271  | 50       | 0.308         | -               |
| 0.0542  | 100      | 0.2289        | -               |
| 0.0813  | 150      | 0.2137        | -               |
| 0.1084  | 200      | 0.1707        | -               |
| 0.1355  | 250      | 0.2175        | -               |
| 0.1626  | 300      | 0.2153        | -               |
| 0.1897  | 350      | 0.2007        | -               |
| 0.2168  | 400      | 0.2162        | -               |
| 0.2439  | 450      | 0.205         | -               |
| 0.2710  | 500      | 0.1994        | -               |
| 0.2981  | 550      | 0.1056        | -               |
| 0.3252  | 600      | 0.1551        | -               |
| 0.3523  | 650      | 0.0454        | -               |
| 0.3794  | 700      | 0.0636        | -               |
| 0.4065  | 750      | 0.0928        | -               |
| 0.4336  | 800      | 0.0191        | -               |
| 0.4607  | 850      | 0.0279        | -               |
| 0.4878  | 900      | 0.0395        | -               |
| 0.5149  | 950      | 0.0124        | -               |
| 0.5420  | 1000     | 0.0117        | -               |
| 0.5691  | 1050     | 0.0037        | -               |
| 0.5962  | 1100     | 0.0018        | -               |
| 0.6233  | 1150     | 0.0004        | -               |
| 0.6504  | 1200     | 0.0016        | -               |
| 0.6775  | 1250     | 0.0012        | -               |
| 0.7046  | 1300     | 0.0008        | -               |
| 0.7317  | 1350     | 0.0006        | -               |
| 0.7588  | 1400     | 0.0025        | -               |
| 0.7859  | 1450     | 0.0003        | -               |
| 0.8130  | 1500     | 0.0001        | -               |
| 0.8401  | 1550     | 0.0002        | -               |
| 0.8672  | 1600     | 0.0002        | -               |
| 0.8943  | 1650     | 0.0002        | -               |
| 0.9214  | 1700     | 0.0002        | -               |
| 0.9485  | 1750     | 0.0001        | -               |
| 0.9756  | 1800     | 0.0001        | -               |
| 1.0     | 1845     | -             | 0.2148          |
| 1.0027  | 1850     | 0.0014        | -               |
| 1.0298  | 1900     | 0.0001        | -               |
| 1.0569  | 1950     | 0.0001        | -               |
| 1.0840  | 2000     | 0.0001        | -               |
| 1.1111  | 2050     | 0.0001        | -               |
| 1.1382  | 2100     | 0.0002        | -               |
| 1.1653  | 2150     | 0.0001        | -               |
| 1.1924  | 2200     | 0.0001        | -               |
| 1.2195  | 2250     | 0.0001        | -               |
| 1.2466  | 2300     | 0.0002        | -               |
| 1.2737  | 2350     | 0.0001        | -               |
| 1.3008  | 2400     | 0.0           | -               |
| 1.3279  | 2450     | 0.0001        | -               |
| 1.3550  | 2500     | 0.0001        | -               |
| 1.3821  | 2550     | 0.0           | -               |
| 1.4092  | 2600     | 0.0001        | -               |
| 1.4363  | 2650     | 0.0002        | -               |
| 1.4634  | 2700     | 0.0001        | -               |
| 1.4905  | 2750     | 0.0           | -               |
| 1.5176  | 2800     | 0.0           | -               |
| 1.5447  | 2850     | 0.0001        | -               |
| 1.5718  | 2900     | 0.0           | -               |
| 1.5989  | 2950     | 0.0           | -               |
| 1.6260  | 3000     | 0.0001        | -               |
| 1.6531  | 3050     | 0.0001        | -               |
| 1.6802  | 3100     | 0.0           | -               |
| 1.7073  | 3150     | 0.0           | -               |
| 1.7344  | 3200     | 0.0001        | -               |
| 1.7615  | 3250     | 0.0           | -               |
| 1.7886  | 3300     | 0.0           | -               |
| 1.8157  | 3350     | 0.0007        | -               |
| 1.8428  | 3400     | 0.0001        | -               |
| 1.8699  | 3450     | 0.0002        | -               |
| 1.8970  | 3500     | 0.0           | -               |
| 1.9241  | 3550     | 0.0           | -               |
| 1.9512  | 3600     | 0.0           | -               |
| 1.9783  | 3650     | 0.0           | -               |
| 2.0     | 3690     | -             | 0.2065          |
| 2.0054  | 3700     | 0.0           | -               |
| 2.0325  | 3750     | 0.0           | -               |
| 2.0596  | 3800     | 0.0           | -               |
| 2.0867  | 3850     | 0.0002        | -               |
| 2.1138  | 3900     | 0.0           | -               |
| 2.1409  | 3950     | 0.0           | -               |
| 2.1680  | 4000     | 0.0           | -               |
| 2.1951  | 4050     | 0.0           | -               |
| 2.2222  | 4100     | 0.0           | -               |
| 2.2493  | 4150     | 0.0           | -               |
| 2.2764  | 4200     | 0.0002        | -               |
| 2.3035  | 4250     | 0.0           | -               |
| 2.3306  | 4300     | 0.0           | -               |
| 2.3577  | 4350     | 0.0           | -               |
| 2.3848  | 4400     | 0.0           | -               |
| 2.4119  | 4450     | 0.0001        | -               |
| 2.4390  | 4500     | 0.0           | -               |
| 2.4661  | 4550     | 0.0           | -               |
| 2.4932  | 4600     | 0.0           | -               |
| 2.5203  | 4650     | 0.0           | -               |
| 2.5474  | 4700     | 0.0           | -               |
| 2.5745  | 4750     | 0.0           | -               |
| 2.6016  | 4800     | 0.0           | -               |
| 2.6287  | 4850     | 0.0           | -               |
| 2.6558  | 4900     | 0.0           | -               |
| 2.6829  | 4950     | 0.0           | -               |
| 2.7100  | 5000     | 0.0           | -               |
| 2.7371  | 5050     | 0.0           | -               |
| 2.7642  | 5100     | 0.0           | -               |
| 2.7913  | 5150     | 0.0           | -               |
| 2.8184  | 5200     | 0.0           | -               |
| 2.8455  | 5250     | 0.0           | -               |
| 2.8726  | 5300     | 0.0           | -               |
| 2.8997  | 5350     | 0.0           | -               |
| 2.9268  | 5400     | 0.0           | -               |
| 2.9539  | 5450     | 0.0           | -               |
| 2.9810  | 5500     | 0.0           | -               |
| 3.0     | 5535     | -             | 0.2189          |
| 3.0081  | 5550     | 0.0           | -               |
| 3.0352  | 5600     | 0.0           | -               |
| 3.0623  | 5650     | 0.0           | -               |
| 3.0894  | 5700     | 0.0           | -               |
| 3.1165  | 5750     | 0.0           | -               |
| 3.1436  | 5800     | 0.0           | -               |
| 3.1707  | 5850     | 0.0           | -               |
| 3.1978  | 5900     | 0.0           | -               |
| 3.2249  | 5950     | 0.0           | -               |
| 3.2520  | 6000     | 0.0           | -               |
| 3.2791  | 6050     | 0.0           | -               |
| 3.3062  | 6100     | 0.0           | -               |
| 3.3333  | 6150     | 0.0           | -               |
| 3.3604  | 6200     | 0.0           | -               |
| 3.3875  | 6250     | 0.0           | -               |
| 3.4146  | 6300     | 0.0           | -               |
| 3.4417  | 6350     | 0.0           | -               |
| 3.4688  | 6400     | 0.0           | -               |
| 3.4959  | 6450     | 0.0           | -               |
| 3.5230  | 6500     | 0.0           | -               |
| 3.5501  | 6550     | 0.0           | -               |
| 3.5772  | 6600     | 0.0           | -               |
| 3.6043  | 6650     | 0.0           | -               |
| 3.6314  | 6700     | 0.0           | -               |
| 3.6585  | 6750     | 0.0365        | -               |
| 3.6856  | 6800     | 0.0           | -               |
| 3.7127  | 6850     | 0.0           | -               |
| 3.7398  | 6900     | 0.0           | -               |
| 3.7669  | 6950     | 0.0           | -               |
| 3.7940  | 7000     | 0.0           | -               |
| 3.8211  | 7050     | 0.0           | -               |
| 3.8482  | 7100     | 0.0           | -               |
| 3.8753  | 7150     | 0.0           | -               |
| 3.9024  | 7200     | 0.0           | -               |
| 3.9295  | 7250     | 0.0           | -               |
| 3.9566  | 7300     | 0.0           | -               |
| 3.9837  | 7350     | 0.0           | -               |
| **4.0** | **7380** | **-**         | **0.206**       |

* The bold row denotes the saved checkpoint.
### Framework Versions
- Python: 3.10.12
- SetFit: 1.0.1
- Sentence Transformers: 2.2.2
- Transformers: 4.35.2
- PyTorch: 2.1.0+cu121
- Datasets: 2.16.1
- Tokenizers: 0.15.0

## 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.*
-->
{"library_name": "setfit", "tags": ["setfit", "sentence-transformers", "text-classification", "generated_from_setfit_trainer"], "metrics": ["accuracy"], "widget": [{"text": "Janice Bryant Howroyd se tornou a primeira mulher negra a construir um neg\u00f3cio de mais de US$ 1 bilh\u00e3o.\n\nCriada no sul dos Estados Unidos, em meio \u00e0 segrega\u00e7\u00e3o racial, ela enfrentou dificuldades na hora de buscar emprego e usou sua experi\u00eancia quando decidiu abrir sua pr\u00f3pria empresa de recursos humanos."}, {"text": "O final q foi bom um homem igual a ele ia meter a porrada nele q pena q separaram \ud83d\ude2d tinha q tomar muita porrada pra aprender a ser homem literalmente"}, {"text": "macacos s\u00e3o mais espertos que homens pretos"}, {"text": "Vai ser bom na primeira jogatina do jogo, tu j\u00e1 explodir cabe\u00e7a de preto no asfalta Vou sentir os cara da ROTA aqui em SP \"Matei mais um neguinho\""}, {"text": "al\u00e9m disso, faz um trabalho desonesto(e \u00e9 pra isso que ele t\u00e1 l\u00e1) tentando igualar a escraviza\u00e7\u00e3o negra no quilombo dos palmares, com a escraviza\u00e7\u00e3o negra no Brasil, est\u00e1 que \u00e9 puramente baseada em teorias supremacistas brancas."}], "pipeline_tag": "text-classification", "inference": true, "base_model": "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2", "model-index": [{"name": "SetFit with sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2", "results": [{"task": {"type": "text-classification", "name": "Text Classification"}, "dataset": {"name": "Unknown", "type": "unknown", "split": "test"}, "metrics": [{"type": "accuracy", "value": 0.8723404255319149, "name": "Accuracy"}]}]}]}
setfit safetensors bert sentence-transformers text-classification generated_from_setfit_trainer arxiv:2209.11055 base_model:sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 model-index region:us