--- tags: - setfit - sentence-transformers - text-classification - generated_from_setfit_trainer widget: - text: Tennengebirge Reef - text: Outcrop next to I-84 East - text: scenic overview - text: Ruby Star for sale now Please contact us for more details. Regards - text: torre rocosa de grans dimensions. 3 blocs partits metrics: - accuracy pipeline_tag: text-classification library_name: setfit inference: true base_model: BAAI/bge-small-en-v1.5 --- # 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 | |:------|:----------------------------------------------------------------------------------------------------------------------------------| | 0 | | | 1 | | ## 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("scenic overview") ``` ## Training Details ### Training Set Metrics | Training set | Min | Median | Max | |:-------------|:----|:-------|:-----| | Word count | 1 | 7.2788 | 1899 | | Label | Training Sample Count | |:------|:----------------------| | 0 | 2997 | | 1 | 783 | ### Training Hyperparameters - batch_size: (32, 32) - 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.2331 | - | | 0.0106 | 50 | 0.2391 | - | | 0.0212 | 100 | 0.238 | - | | 0.0317 | 150 | 0.2309 | - | | 0.0423 | 200 | 0.2117 | - | | 0.0529 | 250 | 0.1879 | - | | 0.0635 | 300 | 0.1745 | - | | 0.0741 | 350 | 0.1708 | - | | 0.0847 | 400 | 0.1402 | - | | 0.0952 | 450 | 0.1349 | - | | 0.1058 | 500 | 0.1092 | - | | 0.1164 | 550 | 0.1031 | - | | 0.1270 | 600 | 0.0828 | - | | 0.1376 | 650 | 0.0756 | - | | 0.1481 | 700 | 0.0587 | - | | 0.1587 | 750 | 0.0487 | - | | 0.1693 | 800 | 0.0557 | - | | 0.1799 | 850 | 0.0456 | - | | 0.1905 | 900 | 0.0371 | - | | 0.2011 | 950 | 0.0412 | - | | 0.2116 | 1000 | 0.0382 | - | | 0.2222 | 1050 | 0.0376 | - | | 0.2328 | 1100 | 0.0353 | - | | 0.2434 | 1150 | 0.0346 | - | | 0.2540 | 1200 | 0.0364 | - | | 0.2646 | 1250 | 0.0317 | - | | 0.2751 | 1300 | 0.0374 | - | | 0.2857 | 1350 | 0.0282 | - | | 0.2963 | 1400 | 0.0255 | - | | 0.3069 | 1450 | 0.023 | - | | 0.3175 | 1500 | 0.0287 | - | | 0.3280 | 1550 | 0.025 | - | | 0.3386 | 1600 | 0.0216 | - | | 0.3492 | 1650 | 0.0241 | - | | 0.3598 | 1700 | 0.0234 | - | | 0.3704 | 1750 | 0.0279 | - | | 0.3810 | 1800 | 0.0239 | - | | 0.3915 | 1850 | 0.0199 | - | | 0.4021 | 1900 | 0.0252 | - | | 0.4127 | 1950 | 0.0219 | - | | 0.4233 | 2000 | 0.0228 | - | | 0.4339 | 2050 | 0.0204 | - | | 0.4444 | 2100 | 0.0231 | - | | 0.4550 | 2150 | 0.0144 | - | | 0.4656 | 2200 | 0.0229 | - | | 0.4762 | 2250 | 0.0129 | - | | 0.4868 | 2300 | 0.0219 | - | | 0.4974 | 2350 | 0.0194 | - | | 0.5079 | 2400 | 0.0172 | - | | 0.5185 | 2450 | 0.0177 | - | | 0.5291 | 2500 | 0.0252 | - | | 0.5397 | 2550 | 0.0251 | - | | 0.5503 | 2600 | 0.014 | - | | 0.5608 | 2650 | 0.0204 | - | | 0.5714 | 2700 | 0.0248 | - | | 0.5820 | 2750 | 0.0146 | - | | 0.5926 | 2800 | 0.0191 | - | | 0.6032 | 2850 | 0.0223 | - | | 0.6138 | 2900 | 0.0206 | - | | 0.6243 | 2950 | 0.0163 | - | | 0.6349 | 3000 | 0.0235 | - | | 0.6455 | 3050 | 0.0245 | - | | 0.6561 | 3100 | 0.0199 | - | | 0.6667 | 3150 | 0.0145 | - | | 0.6772 | 3200 | 0.016 | - | | 0.6878 | 3250 | 0.0143 | - | | 0.6984 | 3300 | 0.0206 | - | | 0.7090 | 3350 | 0.0187 | - | | 0.7196 | 3400 | 0.0168 | - | | 0.7302 | 3450 | 0.0148 | - | | 0.7407 | 3500 | 0.0212 | - | | 0.7513 | 3550 | 0.0185 | - | | 0.7619 | 3600 | 0.015 | - | | 0.7725 | 3650 | 0.0187 | - | | 0.7831 | 3700 | 0.0161 | - | | 0.7937 | 3750 | 0.0204 | - | | 0.8042 | 3800 | 0.0182 | - | | 0.8148 | 3850 | 0.0157 | - | | 0.8254 | 3900 | 0.0197 | - | | 0.8360 | 3950 | 0.0133 | - | | 0.8466 | 4000 | 0.0211 | - | | 0.8571 | 4050 | 0.0155 | - | | 0.8677 | 4100 | 0.0197 | - | | 0.8783 | 4150 | 0.0168 | - | | 0.8889 | 4200 | 0.0139 | - | | 0.8995 | 4250 | 0.0132 | - | | 0.9101 | 4300 | 0.018 | - | | 0.9206 | 4350 | 0.014 | - | | 0.9312 | 4400 | 0.017 | - | | 0.9418 | 4450 | 0.0173 | - | | 0.9524 | 4500 | 0.0163 | - | | 0.9630 | 4550 | 0.0178 | - | | 0.9735 | 4600 | 0.0176 | - | | 0.9841 | 4650 | 0.0126 | - | | 0.9947 | 4700 | 0.0194 | - | ### Framework Versions - Python: 3.12.9 - SetFit: 1.1.2 - Sentence Transformers: 4.1.0 - Transformers: 4.52.4 - PyTorch: 2.7.1 - Datasets: 3.6.0 - Tokenizers: 0.21.1 ## 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} } ```