File size: 17,204 Bytes
8d59486
 
 
 
 
 
 
 
 
 
a18acfc
 
 
 
 
 
 
 
8d59486
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1d0fef3
 
 
 
 
 
 
 
 
 
 
 
 
 
8d59486
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a18acfc
8d59486
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a18acfc
8d59486
1d0fef3
 
a18acfc
 
 
 
 
 
 
 
 
 
 
 
8d59486
 
 
5192cfc
8d59486
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5192cfc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8d59486
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
---
library_name: setfit
tags:
- setfit
- sentence-transformers
- text-classification
- generated_from_setfit_trainer
metrics:
- accuracy
widget:
- text: The development of smart cities is leveraging technology to improve urban
    living conditions.
- text: Climate change is causing a significant rise in sea levels.
- text: Fans are speculating about the plot of the upcoming season of Stranger Things.
- text: Fashion branding and marketing campaigns shape consumer perceptions and influence
    purchasing decisions.
- text: Volunteering abroad provides a unique opportunity to experience different
    cultures while giving back to society.
pipeline_tag: text-classification
inference: true
base_model: sentence-transformers/paraphrase-mpnet-base-v2
---

# SetFit with sentence-transformers/paraphrase-mpnet-base-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-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-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-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2)
- **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:** 12 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                                                                                                                                                                                                                                                                          |
|:--------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Politics      | <ul><li>'The mayor announced a new initiative to improve public transportation.'</li><li>'The senator is facing criticism for her stance on the recent bill.'</li><li>'The upcoming election has sparked intense debates among the candidates.'</li></ul>                         |
| Health        | <ul><li>'Regular exercise and a balanced diet are key to maintaining good health.'</li><li>'The World Health Organization has issued new guidelines on COVID-19.'</li><li>'A new study reveals the benefits of meditation for mental health.'</li></ul>                           |
| Finance       | <ul><li>'The stock market saw a significant drop following the announcement.'</li><li>'Investing in real estate can be a profitable venture if done correctly.'</li><li>"The company's profits have doubled since the launch of their new product."</li></ul>                     |
| Travel        | <ul><li>'Visiting the Grand Canyon is a breathtaking experience.'</li><li>'The tourism industry has been severely impacted by the pandemic.'</li><li>'Backpacking through Europe is a popular choice for young travelers.'</li></ul>                                              |
| Food          | <ul><li>'The new restaurant in town offers a fusion of Italian and Japanese cuisine.'</li><li>'Drinking eight glasses of water a day is essential for staying hydrated.'</li><li>'Cooking classes are a fun way to learn new recipes and techniques.'</li></ul>                   |
| Education     | <ul><li>'The school district is implementing a new curriculum for the upcoming year.'</li><li>'Online learning has become increasingly popular during the pandemic.'</li><li>'The university is offering scholarships for students in financial need.'</li></ul>                  |
| Environment   | <ul><li>'Climate change is causing a significant rise in sea levels.'</li><li>'Recycling and composting are effective ways to reduce waste.'</li><li>'The Amazon rainforest is home to millions of unique species.'</li></ul>                                                     |
| Fashion       | <ul><li>'The new fashion trend is all about sustainability and eco-friendly materials.'</li><li>'The annual Met Gala is a major event in the fashion world.'</li><li>'Vintage clothing has made a comeback in recent years.'</li></ul>                                            |
| Science       | <ul><li>"NASA's Mars Rover has made significant discoveries about the red planet."</li><li>'The Nobel Prize in Physics was awarded for breakthroughs in black hole research.'</li><li>'Genetic engineering is opening up new possibilities in medical treatment.'</li></ul>       |
| Sports        | <ul><li>'The NBA Finals are set to begin next week with the top two teams in the league.'</li><li>'Serena Williams continues to dominate the tennis world with her powerful serve.'</li><li>'The World Cup is the most prestigious tournament in international soccer.'</li></ul> |
| Technology    | <ul><li>'Artificial intelligence is changing the way we live and work.'</li><li>'The latest iPhone has a number of exciting new features.'</li><li>'Cybersecurity is becoming increasingly important as more and more data moves online.'</li></ul>                               |
| Entertainment | <ul><li>'The new Marvel movie is breaking box office records.'</li><li>'The Grammy Awards are a celebration of the best music of the year.'</li><li>'The latest season of Game of Thrones had fans on the edge of their seats.'</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("EmeraldMP/ANLP_kaggle")
# Run inference
preds = model("Climate change is causing a significant rise in sea levels.")
```

<!--
### 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   | 7   | 12.8073 | 24  |

| Label         | Training Sample Count |
|:--------------|:----------------------|
| Education     | 23                    |
| Entertainment | 23                    |
| Environment   | 23                    |
| Fashion       | 23                    |
| Finance       | 23                    |
| Food          | 23                    |
| Health        | 23                    |
| Politics      | 22                    |
| Science       | 23                    |
| Sports        | 23                    |
| Technology    | 23                    |
| Travel        | 23                    |

### Training Hyperparameters
- batch_size: (16, 16)
- num_epochs: (10, 10)
- max_steps: -1
- sampling_strategy: oversampling
- num_iterations: 20
- body_learning_rate: (2e-05, 2e-05)
- head_learning_rate: 2e-05
- 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: False

### Training Results
| Epoch  | Step | Training Loss | Validation Loss |
|:------:|:----:|:-------------:|:---------------:|
| 0.0015 | 1    | 0.2748        | -               |
| 0.0727 | 50   | 0.2537        | -               |
| 0.1453 | 100  | 0.1734        | -               |
| 0.2180 | 150  | 0.1086        | -               |
| 0.2907 | 200  | 0.062         | -               |
| 0.3634 | 250  | 0.046         | -               |
| 0.4360 | 300  | 0.017         | -               |
| 0.5087 | 350  | 0.0104        | -               |
| 0.5814 | 400  | 0.006         | -               |
| 0.6541 | 450  | 0.0021        | -               |
| 0.7267 | 500  | 0.0052        | -               |
| 0.7994 | 550  | 0.0045        | -               |
| 0.8721 | 600  | 0.0012        | -               |
| 0.9448 | 650  | 0.0007        | -               |
| 1.0174 | 700  | 0.0006        | -               |
| 1.0901 | 750  | 0.0006        | -               |
| 1.1628 | 800  | 0.0006        | -               |
| 1.2355 | 850  | 0.0005        | -               |
| 1.3081 | 900  | 0.0004        | -               |
| 1.3808 | 950  | 0.0003        | -               |
| 1.4535 | 1000 | 0.0004        | -               |
| 1.5262 | 1050 | 0.0004        | -               |
| 1.5988 | 1100 | 0.0004        | -               |
| 1.6715 | 1150 | 0.0003        | -               |
| 1.7442 | 1200 | 0.0002        | -               |
| 1.8169 | 1250 | 0.0002        | -               |
| 1.8895 | 1300 | 0.0005        | -               |
| 1.9622 | 1350 | 0.0004        | -               |
| 2.0349 | 1400 | 0.0002        | -               |
| 2.1076 | 1450 | 0.0004        | -               |
| 2.1802 | 1500 | 0.0002        | -               |
| 2.2529 | 1550 | 0.0002        | -               |
| 2.3256 | 1600 | 0.0004        | -               |
| 2.3983 | 1650 | 0.0002        | -               |
| 2.4709 | 1700 | 0.0002        | -               |
| 2.5436 | 1750 | 0.0002        | -               |
| 2.6163 | 1800 | 0.0002        | -               |
| 2.6890 | 1850 | 0.0002        | -               |
| 2.7616 | 1900 | 0.0003        | -               |
| 2.8343 | 1950 | 0.0001        | -               |
| 2.9070 | 2000 | 0.0002        | -               |
| 2.9797 | 2050 | 0.0002        | -               |
| 3.0523 | 2100 | 0.0003        | -               |
| 3.125  | 2150 | 0.0002        | -               |
| 3.1977 | 2200 | 0.0002        | -               |
| 3.2703 | 2250 | 0.0001        | -               |
| 3.3430 | 2300 | 0.0002        | -               |
| 3.4157 | 2350 | 0.0002        | -               |
| 3.4884 | 2400 | 0.0002        | -               |
| 3.5610 | 2450 | 0.0001        | -               |
| 3.6337 | 2500 | 0.0001        | -               |
| 3.7064 | 2550 | 0.0001        | -               |
| 3.7791 | 2600 | 0.0001        | -               |
| 3.8517 | 2650 | 0.0001        | -               |
| 3.9244 | 2700 | 0.0001        | -               |
| 3.9971 | 2750 | 0.0001        | -               |
| 4.0698 | 2800 | 0.0001        | -               |
| 4.1424 | 2850 | 0.0001        | -               |
| 4.2151 | 2900 | 0.0001        | -               |
| 4.2878 | 2950 | 0.0001        | -               |
| 4.3605 | 3000 | 0.0001        | -               |
| 4.4331 | 3050 | 0.0001        | -               |
| 4.5058 | 3100 | 0.0001        | -               |
| 4.5785 | 3150 | 0.0001        | -               |
| 4.6512 | 3200 | 0.0001        | -               |
| 4.7238 | 3250 | 0.0001        | -               |
| 4.7965 | 3300 | 0.0001        | -               |
| 4.8692 | 3350 | 0.0001        | -               |
| 4.9419 | 3400 | 0.0001        | -               |
| 5.0145 | 3450 | 0.0001        | -               |
| 5.0872 | 3500 | 0.0001        | -               |
| 5.1599 | 3550 | 0.0001        | -               |
| 5.2326 | 3600 | 0.0001        | -               |
| 5.3052 | 3650 | 0.0001        | -               |
| 5.3779 | 3700 | 0.0001        | -               |
| 5.4506 | 3750 | 0.0001        | -               |
| 5.5233 | 3800 | 0.0001        | -               |
| 5.5959 | 3850 | 0.0001        | -               |
| 5.6686 | 3900 | 0.0001        | -               |
| 5.7413 | 3950 | 0.0001        | -               |
| 5.8140 | 4000 | 0.0001        | -               |
| 5.8866 | 4050 | 0.0001        | -               |
| 5.9593 | 4100 | 0.0001        | -               |
| 6.0320 | 4150 | 0.0001        | -               |
| 6.1047 | 4200 | 0.0001        | -               |
| 6.1773 | 4250 | 0.0001        | -               |
| 6.25   | 4300 | 0.0001        | -               |
| 6.3227 | 4350 | 0.0001        | -               |
| 6.3953 | 4400 | 0.0001        | -               |
| 6.4680 | 4450 | 0.0001        | -               |
| 6.5407 | 4500 | 0.0001        | -               |
| 6.6134 | 4550 | 0.0001        | -               |
| 6.6860 | 4600 | 0.0001        | -               |
| 6.7587 | 4650 | 0.0001        | -               |
| 6.8314 | 4700 | 0.0001        | -               |
| 6.9041 | 4750 | 0.0001        | -               |
| 6.9767 | 4800 | 0.0           | -               |
| 7.0494 | 4850 | 0.0001        | -               |
| 7.1221 | 4900 | 0.0001        | -               |
| 7.1948 | 4950 | 0.0001        | -               |
| 7.2674 | 5000 | 0.0001        | -               |
| 7.3401 | 5050 | 0.0001        | -               |
| 7.4128 | 5100 | 0.0001        | -               |
| 7.4855 | 5150 | 0.0001        | -               |
| 7.5581 | 5200 | 0.0001        | -               |
| 7.6308 | 5250 | 0.0001        | -               |
| 7.7035 | 5300 | 0.0001        | -               |
| 7.7762 | 5350 | 0.0001        | -               |
| 7.8488 | 5400 | 0.0001        | -               |
| 7.9215 | 5450 | 0.0001        | -               |
| 7.9942 | 5500 | 0.0           | -               |
| 8.0669 | 5550 | 0.0001        | -               |
| 8.1395 | 5600 | 0.0001        | -               |
| 8.2122 | 5650 | 0.0001        | -               |
| 8.2849 | 5700 | 0.0           | -               |
| 8.3576 | 5750 | 0.0001        | -               |
| 8.4302 | 5800 | 0.0001        | -               |
| 8.5029 | 5850 | 0.0001        | -               |
| 8.5756 | 5900 | 0.0001        | -               |
| 8.6483 | 5950 | 0.0001        | -               |
| 8.7209 | 6000 | 0.0001        | -               |
| 8.7936 | 6050 | 0.0001        | -               |
| 8.8663 | 6100 | 0.0           | -               |
| 8.9390 | 6150 | 0.0           | -               |
| 9.0116 | 6200 | 0.0001        | -               |
| 9.0843 | 6250 | 0.0001        | -               |
| 9.1570 | 6300 | 0.0           | -               |
| 9.2297 | 6350 | 0.0           | -               |
| 9.3023 | 6400 | 0.0           | -               |
| 9.375  | 6450 | 0.0001        | -               |
| 9.4477 | 6500 | 0.0001        | -               |
| 9.5203 | 6550 | 0.0001        | -               |
| 9.5930 | 6600 | 0.0001        | -               |
| 9.6657 | 6650 | 0.0001        | -               |
| 9.7384 | 6700 | 0.0001        | -               |
| 9.8110 | 6750 | 0.0001        | -               |
| 9.8837 | 6800 | 0.0001        | -               |
| 9.9564 | 6850 | 0.0           | -               |

### Framework Versions
- Python: 3.10.12
- SetFit: 1.0.3
- Sentence Transformers: 2.7.0
- Transformers: 4.38.2
- PyTorch: 2.2.1+cu121
- Datasets: 2.18.0
- Tokenizers: 0.15.2

## 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.*
-->