---
base_model: akhooli/sbert_ar_nli_500k_norm
library_name: setfit
metrics:
- accuracy
pipeline_tag: text-classification
tags:
- setfit
- sentence-transformers
- text-classification
- generated_from_setfit_trainer
widget:
- text: الطريقة الأفضل لتحصل على ريتويت ولايك هل ايام تقتطع جزء من مقابلة للوزير
باسيل طبعا جزء غير مكتمل ثم تغرد به وتقول جبران مع التطبيع
- text: ما بعرف كيف بدي خبركن ياها بس غير إنو واطي طلع عرص
- text: سد نيعك يا صرمايت بشار
- text: بتفهّم فهم وحدة فهما متدنّي هههه 😎
- text: للاسف لدينا في الخليج بعض من الكتاب والدكاتره والمحللين كالبغال والجحاش ينهق
ويهرف بما لايعرف
inference: true
model-index:
- name: SetFit with akhooli/sbert_ar_nli_500k_norm
results:
- task:
type: text-classification
name: Text Classification
dataset:
name: Unknown
type: unknown
split: test
metrics:
- type: accuracy
value: 0.8544600938967136
name: Accuracy
---
# usage
Usage:
```python
pip install setfit
from setfit import SetFitModel
from unicodedata import normalize
# Download model from Hub
model = SetFitModel.from_pretrained("akhooli/setfit_ar_hs")
# Run inference
queries = [
"سكت دهراً و نطق كفراً",
"الخلاف ﻻ يفسد للود قضية.",
"أنت شخص منبوذ. احترم أسيادك.",
"دع المكارم ﻻ ترحل لبغيتها واقعد فإنك أنت الطاعم الكاسي",
]
queries_n = [normalize('NFKC', query) for query in queries]
preds = model.predict(queries_n)
print(preds)
# if you want to see the probabilities for each label
probas = model.predict_proba(queries_n)
print(probas)
```
The rest of this content is auto-generated.
# SetFit with akhooli/sbert_ar_nli_500k_norm
This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [akhooli/sbert_ar_nli_500k_norm](https://huggingface.co/akhooli/sbert_ar_nli_500k_norm) 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:** [akhooli/sbert_ar_nli_500k_norm](https://huggingface.co/akhooli/sbert_ar_nli_500k_norm)
- **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
### 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 |
|:---------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| negative |
- 'كلامي ان حزب الله الحامي الوحيد للبنان معناه ان في لبنان'
- 'يا غايظهن يا جبران باسيل انت حبيب القلب'
- 'يسعد صباحك معالي الوزير'
|
| positive | - 'الى وزير خارجية لبنان جبران باسيل اذا أردت ان تكون مثل الشيخ بشير الجميل عليك ان تستشهد الآن يا اخي فقط إستشهد و لك'
- 'شو ضعيف وشو مقهور ومش قادر تعمل شيطز فيكم كلكن كلكن بتصبوا بخانة الكذب والنفاق بتدعسوا عا الناس لمصالحهم وفسادكم'
- 'ولك الله انتو شعب بجم روح جبلي مصاري للشعب بعدين احكي'
|
## Evaluation
### Metrics
| Label | Accuracy |
|:--------|:---------|
| **all** | 0.8545 |
## 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("akhooli/setfit_ar_hs")
# Run inference
preds = model("سد نيعك يا صرمايت بشار")
```
## Training Details
### Training Set Metrics
| Training set | Min | Median | Max |
|:-------------|:----|:--------|:----|
| Word count | 1 | 12.2912 | 52 |
| Label | Training Sample Count |
|:---------|:----------------------|
| negative | 2015 |
| positive | 2800 |
### Training Hyperparameters
- batch_size: (32, 32)
- num_epochs: (1, 1)
- max_steps: 8000
- 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
- run_name: setfit_hate_25kv8
- eval_max_steps: -1
- load_best_model_at_end: False
### Training Results
| Epoch | Step | Training Loss | Validation Loss |
|:------:|:----:|:-------------:|:---------------:|
| 0.0003 | 1 | 0.3359 | - |
| 0.025 | 100 | 0.2843 | - |
| 0.05 | 200 | 0.2376 | - |
| 0.075 | 300 | 0.2067 | - |
| 0.1 | 400 | 0.1591 | - |
| 0.125 | 500 | 0.108 | - |
| 0.15 | 600 | 0.0736 | - |
| 0.175 | 700 | 0.0513 | - |
| 0.2 | 800 | 0.0384 | - |
| 0.225 | 900 | 0.0364 | - |
| 0.25 | 1000 | 0.0296 | - |
| 0.275 | 1100 | 0.0207 | - |
| 0.3 | 1200 | 0.0212 | - |
| 0.325 | 1300 | 0.0164 | - |
| 0.35 | 1400 | 0.0122 | - |
| 0.375 | 1500 | 0.0163 | - |
| 0.4 | 1600 | 0.01 | - |
| 0.425 | 1700 | 0.0085 | - |
| 0.45 | 1800 | 0.0081 | - |
| 0.475 | 1900 | 0.0083 | - |
| 0.5 | 2000 | 0.0057 | - |
| 0.525 | 2100 | 0.0061 | - |
| 0.55 | 2200 | 0.0046 | - |
| 0.575 | 2300 | 0.0049 | - |
| 0.6 | 2400 | 0.007 | - |
| 0.625 | 2500 | 0.0048 | - |
| 0.65 | 2600 | 0.0057 | - |
| 0.675 | 2700 | 0.0058 | - |
| 0.7 | 2800 | 0.0046 | - |
| 0.725 | 2900 | 0.0044 | - |
| 0.75 | 3000 | 0.0042 | - |
| 0.775 | 3100 | 0.0042 | - |
| 0.8 | 3200 | 0.0057 | - |
| 0.825 | 3300 | 0.003 | - |
| 0.85 | 3400 | 0.0041 | - |
| 0.875 | 3500 | 0.0052 | - |
| 0.9 | 3600 | 0.004 | - |
| 0.925 | 3700 | 0.0042 | - |
| 0.95 | 3800 | 0.0058 | - |
| 0.975 | 3900 | 0.0049 | - |
| 1.0 | 4000 | 0.0052 | - |
| 1.025 | 4100 | 0.0031 | - |
| 1.05 | 4200 | 0.0025 | - |
| 1.075 | 4300 | 0.003 | - |
| 1.1 | 4400 | 0.0018 | - |
| 1.125 | 4500 | 0.0015 | - |
| 1.15 | 4600 | 0.0038 | - |
| 1.175 | 4700 | 0.0033 | - |
| 1.2 | 4800 | 0.0031 | - |
| 1.225 | 4900 | 0.0022 | - |
| 1.25 | 5000 | 0.0023 | - |
| 1.275 | 5100 | 0.0022 | - |
| 1.3 | 5200 | 0.0027 | - |
| 1.325 | 5300 | 0.0017 | - |
| 1.35 | 5400 | 0.0027 | - |
| 1.375 | 5500 | 0.0019 | - |
| 1.4 | 5600 | 0.0024 | - |
| 1.425 | 5700 | 0.0015 | - |
| 1.45 | 5800 | 0.0023 | - |
| 1.475 | 5900 | 0.0021 | - |
| 1.5 | 6000 | 0.0009 | - |
| 1.525 | 6100 | 0.0015 | - |
| 1.55 | 6200 | 0.0009 | - |
| 1.575 | 6300 | 0.001 | - |
| 1.6 | 6400 | 0.0002 | - |
| 1.625 | 6500 | 0.0004 | - |
| 1.65 | 6600 | 0.0012 | - |
| 1.675 | 6700 | 0.0011 | - |
| 1.7 | 6800 | 0.0008 | - |
| 1.725 | 6900 | 0.0013 | - |
| 1.75 | 7000 | 0.0004 | - |
| 1.775 | 7100 | 0.0004 | - |
| 1.8 | 7200 | 0.0008 | - |
| 1.825 | 7300 | 0.0007 | - |
| 1.85 | 7400 | 0.0007 | - |
| 1.875 | 7500 | 0.001 | - |
| 1.9 | 7600 | 0.001 | - |
| 1.925 | 7700 | 0.0002 | - |
| 1.95 | 7800 | 0.0005 | - |
| 1.975 | 7900 | 0.0009 | - |
| 2.0 | 8000 | 0.0002 | - |
### Framework Versions
- Python: 3.10.14
- SetFit: 1.2.0.dev0
- Sentence Transformers: 3.2.1
- Transformers: 4.45.1
- PyTorch: 2.4.0
- Datasets: 3.0.1
- Tokenizers: 0.20.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}
}
```