---
tags:
- setfit
- sentence-transformers
- text-classification
- generated_from_setfit_trainer
widget:
- text: A young researcher presenting their findings on a novel approach to information
retrieval
- text: A cartoonist specializing in educational materials
- text: A fellow child actor who shares the excitement and challenges of being part
of research
- text: A teenage daughter who excels in her studies due to the integration of technology
in her education
- text: An under 16 teenager who lost the chance to be selected for the national team
in U-15 championship
metrics:
- accuracy
pipeline_tag: text-classification
library_name: setfit
inference: true
base_model: BAAI/bge-small-en-v1.5
model-index:
- name: SetFit with BAAI/bge-small-en-v1.5
results:
- task:
type: text-classification
name: Text Classification
dataset:
name: Unknown
type: unknown
split: test
metrics:
- type: accuracy
value: 0.96
name: Accuracy
---
# SetFit with BAAI/bge-small-en-v1.5
This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [BAAI/bge-small-en-v1.5](https://huggingface.co/BAAI/bge-small-en-v1.5) 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:** [BAAI/bge-small-en-v1.5](https://huggingface.co/BAAI/bge-small-en-v1.5)
- **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 |
|:----------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| not_minor |
- 'A young manager in her very first leadership position.'
- 'A detail-oriented student who excels in organizing group study sessions in the library'
- 'A fellow student involved in a book club who prefers physical copies for annotation and discussion'
|
| minor | - 'A teenage girl from a disadvantaged background who is empowered by the health education programs'
- "A young child from a diverse family background who is involved in the candidate's research studies"
- 'A child with a passion for music who learns best through creative and interactive activities'
|
## Evaluation
### Metrics
| Label | Accuracy |
|:--------|:---------|
| **all** | 0.96 |
## 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("setfit_model_id")
# Run inference
preds = model("A cartoonist specializing in educational materials")
```
## Training Details
### Training Set Metrics
| Training set | Min | Median | Max |
|:-------------|:----|:-------|:----|
| Word count | 3 | 14.34 | 26 |
| Label | Training Sample Count |
|:----------|:----------------------|
| not_minor | 100 |
| minor | 100 |
### Training Hyperparameters
- batch_size: (64, 64)
- num_epochs: (4, 4)
- max_steps: -1
- sampling_strategy: oversampling
- 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: True
### Training Results
| Epoch | Step | Training Loss | Validation Loss |
|:------:|:----:|:-------------:|:---------------:|
| 0.0032 | 1 | 0.2636 | - |
| 0.1582 | 50 | 0.2471 | - |
| 0.3165 | 100 | 0.2067 | - |
| 0.4747 | 150 | 0.0207 | - |
| 0.6329 | 200 | 0.0021 | - |
| 0.7911 | 250 | 0.0015 | - |
| 0.9494 | 300 | 0.0013 | - |
| 1.0 | 316 | - | 0.0825 |
| 1.1076 | 350 | 0.0011 | - |
| 1.2658 | 400 | 0.001 | - |
| 1.4241 | 450 | 0.0009 | - |
| 1.5823 | 500 | 0.0008 | - |
| 1.7405 | 550 | 0.0008 | - |
| 1.8987 | 600 | 0.0007 | - |
| 2.0 | 632 | - | 0.0813 |
| 2.0570 | 650 | 0.001 | - |
| 2.2152 | 700 | 0.0007 | - |
| 2.3734 | 750 | 0.0007 | - |
| 2.5316 | 800 | 0.0006 | - |
| 2.6899 | 850 | 0.0006 | - |
| 2.8481 | 900 | 0.0006 | - |
| 3.0 | 948 | - | 0.0736 |
| 3.0063 | 950 | 0.0006 | - |
| 3.1646 | 1000 | 0.0006 | - |
| 3.3228 | 1050 | 0.0005 | - |
| 3.4810 | 1100 | 0.0006 | - |
| 3.6392 | 1150 | 0.0005 | - |
| 3.7975 | 1200 | 0.0006 | - |
| 3.9557 | 1250 | 0.0005 | - |
| 4.0 | 1264 | - | 0.0754 |
### Framework Versions
- Python: 3.12.4
- SetFit: 1.1.0
- Sentence Transformers: 3.2.1
- Transformers: 4.45.2
- PyTorch: 2.5.1
- Datasets: 3.1.0
- Tokenizers: 0.20.3
## 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}
}
```