SetFit with sentence-transformers/all-MiniLM-L6-v2
This is a SetFit model that can be used for Text Classification. This SetFit model uses sentence-transformers/all-MiniLM-L6-v2 as the Sentence Transformer embedding model. A LogisticRegression instance is used for classification.
The model has been trained using an efficient few-shot learning technique that involves:
- Fine-tuning a Sentence Transformer with contrastive learning.
- Training a classification head with features from the fine-tuned Sentence Transformer.
Model Details
Model Description
- Model Type: SetFit
- Sentence Transformer body: sentence-transformers/all-MiniLM-L6-v2
- Classification head: a LogisticRegression instance
- Maximum Sequence Length: 256 tokens
- Number of Classes: 3 classes
Model Sources
- Repository: SetFit on GitHub
- Paper: Efficient Few-Shot Learning Without Prompts
- Blogpost: SetFit: Efficient Few-Shot Learning Without Prompts
Model Labels
| Label | Examples |
|---|---|
| Solution or Action | 'The women of the community decided that they would not make the electricity bill and would send their children to school''Since the children did not have a father the mother decided to enroll them in school''Preeti Kumari age 18 does not want to appear for the matriculation examination due to failure Explain the solution to her parents and try to get her to appear for the examination and take her forward' |
| Challenge | 'Girls have work responsibilities so they dont get a chance to study''Due to poverty children are unable to pursue further studies''Kavita didis daughter has left her studies after the fifth lesson' |
| Other | 'The community woman shared that one childs birth certificate has not been made which could potentially affect their education''No community members should hold meetings with teachers at school''Regarding Siddhanta it was said that you must study only then your future will be bright and you will not face any problems in future' |
Uses
Direct Use for Inference
First install the SetFit library:
pip install setfit
Then you can load this model and run inference.
from setfit import SetFitModel
# Download from the 🤗 Hub
model = SetFitModel.from_pretrained("setfit_model_id")
# Run inference
preds = model("Education is very important for children in poverty and can also create a future")
Training Details
Training Set Metrics
| Training set | Min | Median | Max |
|---|---|---|---|
| Word count | 1 | 19.8416 | 402 |
| Label | Training Sample Count |
|---|---|
| Challenge | 1634 |
| Other | 440 |
| Solution or Action | 1852 |
Training Hyperparameters
- batch_size: (16, 16)
- num_epochs: (1, 1)
- max_steps: -1
- sampling_strategy: oversampling
- num_iterations: 20
- 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
- eval_max_steps: -1
- load_best_model_at_end: False
Training Results
| Epoch | Step | Training Loss | Validation Loss |
|---|---|---|---|
| 0.0002 | 1 | 0.2792 | - |
| 0.0102 | 50 | 0.2964 | - |
| 0.0204 | 100 | 0.2595 | - |
| 0.0306 | 150 | 0.23 | - |
| 0.0407 | 200 | 0.1881 | - |
| 0.0509 | 250 | 0.1349 | - |
| 0.0611 | 300 | 0.109 | - |
| 0.0713 | 350 | 0.1024 | - |
| 0.0815 | 400 | 0.0855 | - |
| 0.0917 | 450 | 0.0751 | - |
| 0.1019 | 500 | 0.0792 | - |
| 0.1121 | 550 | 0.074 | - |
| 0.1222 | 600 | 0.0643 | - |
| 0.1324 | 650 | 0.0668 | - |
| 0.1426 | 700 | 0.0624 | - |
| 0.1528 | 750 | 0.0604 | - |
| 0.1630 | 800 | 0.0513 | - |
| 0.1732 | 850 | 0.0455 | - |
| 0.1834 | 900 | 0.038 | - |
| 0.1936 | 950 | 0.0439 | - |
| 0.2037 | 1000 | 0.0331 | - |
| 0.2139 | 1050 | 0.0323 | - |
| 0.2241 | 1100 | 0.0269 | - |
| 0.2343 | 1150 | 0.0376 | - |
| 0.2445 | 1200 | 0.0256 | - |
| 0.2547 | 1250 | 0.0279 | - |
| 0.2649 | 1300 | 0.0276 | - |
| 0.2751 | 1350 | 0.0289 | - |
| 0.2852 | 1400 | 0.0241 | - |
| 0.2954 | 1450 | 0.0179 | - |
| 0.3056 | 1500 | 0.0177 | - |
| 0.3158 | 1550 | 0.0226 | - |
| 0.3260 | 1600 | 0.0176 | - |
| 0.3362 | 1650 | 0.0182 | - |
| 0.3464 | 1700 | 0.0171 | - |
| 0.3566 | 1750 | 0.0175 | - |
| 0.3667 | 1800 | 0.0141 | - |
| 0.3769 | 1850 | 0.0177 | - |
| 0.3871 | 1900 | 0.0136 | - |
| 0.3973 | 1950 | 0.0127 | - |
| 0.4075 | 2000 | 0.0173 | - |
| 0.4177 | 2050 | 0.0106 | - |
| 0.4279 | 2100 | 0.01 | - |
| 0.4381 | 2150 | 0.0113 | - |
| 0.4482 | 2200 | 0.0091 | - |
| 0.4584 | 2250 | 0.0071 | - |
| 0.4686 | 2300 | 0.01 | - |
| 0.4788 | 2350 | 0.0112 | - |
| 0.4890 | 2400 | 0.0104 | - |
| 0.4992 | 2450 | 0.0089 | - |
| 0.5094 | 2500 | 0.0096 | - |
| 0.5196 | 2550 | 0.0098 | - |
| 0.5297 | 2600 | 0.0113 | - |
| 0.5399 | 2650 | 0.005 | - |
| 0.5501 | 2700 | 0.0074 | - |
| 0.5603 | 2750 | 0.0078 | - |
| 0.5705 | 2800 | 0.007 | - |
| 0.5807 | 2850 | 0.0047 | - |
| 0.5909 | 2900 | 0.0111 | - |
| 0.6011 | 2950 | 0.0054 | - |
| 0.6112 | 3000 | 0.0088 | - |
| 0.6214 | 3050 | 0.0045 | - |
| 0.6316 | 3100 | 0.0031 | - |
| 0.6418 | 3150 | 0.0084 | - |
| 0.6520 | 3200 | 0.005 | - |
| 0.6622 | 3250 | 0.0058 | - |
| 0.6724 | 3300 | 0.0048 | - |
| 0.6826 | 3350 | 0.0057 | - |
| 0.6927 | 3400 | 0.0048 | - |
| 0.7029 | 3450 | 0.0059 | - |
| 0.7131 | 3500 | 0.0078 | - |
| 0.7233 | 3550 | 0.0057 | - |
| 0.7335 | 3600 | 0.0056 | - |
| 0.7437 | 3650 | 0.0039 | - |
| 0.7539 | 3700 | 0.0059 | - |
| 0.7641 | 3750 | 0.0058 | - |
| 0.7742 | 3800 | 0.0022 | - |
| 0.7844 | 3850 | 0.0064 | - |
| 0.7946 | 3900 | 0.0033 | - |
| 0.8048 | 3950 | 0.0037 | - |
| 0.8150 | 4000 | 0.003 | - |
| 0.8252 | 4050 | 0.0063 | - |
| 0.8354 | 4100 | 0.0047 | - |
| 0.8456 | 4150 | 0.0056 | - |
| 0.8557 | 4200 | 0.0026 | - |
| 0.8659 | 4250 | 0.0028 | - |
| 0.8761 | 4300 | 0.0066 | - |
| 0.8863 | 4350 | 0.0026 | - |
| 0.8965 | 4400 | 0.0045 | - |
| 0.9067 | 4450 | 0.0052 | - |
| 0.9169 | 4500 | 0.0017 | - |
| 0.9271 | 4550 | 0.0056 | - |
| 0.9372 | 4600 | 0.0043 | - |
| 0.9474 | 4650 | 0.0034 | - |
| 0.9576 | 4700 | 0.0042 | - |
| 0.9678 | 4750 | 0.0031 | - |
| 0.9780 | 4800 | 0.004 | - |
| 0.9882 | 4850 | 0.0064 | - |
| 0.9984 | 4900 | 0.0033 | - |
Framework Versions
- Python: 3.12.13
- SetFit: 1.1.0
- Sentence Transformers: 3.1.1
- Transformers: 4.45.2
- PyTorch: 2.10.0+cu128
- Datasets: 3.2.0
- Tokenizers: 0.20.3
Citation
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}
}