--- library_name: setfit tags: - setfit - sentence-transformers - text-classification - generated_from_setfit_trainer metrics: - accuracy widget: - text: The aim of this study was to investigate the effect of diets of extreme macronutrient composition on DIT under near physiological conditions in a respiration chamber over the duration of a full day. - text: It can be seen from the figure that the blue boundaries divide the spectrum into too many areas. - text: It may be the case that the seller commits to selling the product to the buyer immediately after checking the order. - text: These subjects were excluded from the study. - text: While the chemical shift predictions that are used always have some level of error, a key benefit of this approach is that individual errors of large magnitude are easily identified and tolerated due to redundancy in the network of moving peaks. pipeline_tag: text-classification inference: true base_model: sentence-transformers/all-MiniLM-L6-v2 model-index: - name: SetFit with sentence-transformers/all-MiniLM-L6-v2 results: - task: type: text-classification name: Text Classification dataset: name: Unknown type: unknown split: test metrics: - type: accuracy value: 0.9755555555555555 name: Accuracy --- # SetFit with sentence-transformers/all-MiniLM-L6-v2 This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-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/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance - **Maximum Sequence Length:** 256 tokens - **Number of Classes:** 9 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 | |:------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 | | | 2 | | | 3 | | | 4 | | | 5 | | | 6 | | | 7 | | | 8 | | | 9 | | ## Evaluation ### Metrics | Label | Accuracy | |:--------|:---------| | **all** | 0.9756 | ## 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("Corran/SciFunctions") # Run inference preds = model("These subjects were excluded from the study.") ``` ## Training Details ### Training Set Metrics | Training set | Min | Median | Max | |:-------------|:----|:--------|:----| | Word count | 5 | 26.0891 | 245 | | Label | Training Sample Count | |:------|:----------------------| | 1 | 450 | | 2 | 450 | | 3 | 450 | | 4 | 450 | | 5 | 450 | | 6 | 450 | | 7 | 450 | | 8 | 450 | | 9 | 450 | ### Training Hyperparameters - batch_size: (75, 75) - num_epochs: (1, 1) - 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.0005 | 1 | 0.3763 | - | | 0.0231 | 50 | 0.317 | - | | 0.0463 | 100 | 0.2252 | - | | 0.0694 | 150 | 0.189 | - | | 0.0926 | 200 | 0.1505 | - | | 0.1157 | 250 | 0.105 | - | | 0.1389 | 300 | 0.1024 | - | | 0.1620 | 350 | 0.0867 | - | | 0.1852 | 400 | 0.0659 | - | | 0.2083 | 450 | 0.0532 | - | | 0.2315 | 500 | 0.0366 | - | | 0.2546 | 550 | 0.0622 | - | | 0.2778 | 600 | 0.0241 | - | | 0.3009 | 650 | 0.0315 | - | | 0.3241 | 700 | 0.025 | - | | 0.3472 | 750 | 0.0412 | - | | 0.3704 | 800 | 0.0274 | - | | 0.3935 | 850 | 0.0203 | - | | 0.4167 | 900 | 0.0302 | - | | 0.4398 | 950 | 0.0152 | - | | 0.4630 | 1000 | 0.0103 | - | | 0.4861 | 1050 | 0.0102 | - | | 0.5093 | 1100 | 0.0208 | - | | 0.5324 | 1150 | 0.0168 | - | | 0.5556 | 1200 | 0.0158 | - | | 0.5787 | 1250 | 0.0045 | - | | 0.6019 | 1300 | 0.014 | - | | 0.625 | 1350 | 0.0061 | - | | 0.6481 | 1400 | 0.0125 | - | | 0.6713 | 1450 | 0.0048 | - | | 0.6944 | 1500 | 0.0042 | - | | 0.7176 | 1550 | 0.0055 | - | | 0.7407 | 1600 | 0.0058 | - | | 0.7639 | 1650 | 0.0032 | - | | 0.7870 | 1700 | 0.0041 | - | | 0.8102 | 1750 | 0.0042 | - | | 0.8333 | 1800 | 0.0018 | - | | 0.8565 | 1850 | 0.0094 | - | | 0.8796 | 1900 | 0.0096 | - | | 0.9028 | 1950 | 0.0043 | - | | 0.9259 | 2000 | 0.003 | - | | 0.9491 | 2050 | 0.0029 | - | | 0.9722 | 2100 | 0.0016 | - | | 0.9954 | 2150 | 0.0084 | - | ### Framework Versions - Python: 3.10.12 - SetFit: 1.0.1 - Sentence Transformers: 2.2.2 - Transformers: 4.35.2 - PyTorch: 2.1.0+cu121 - Datasets: 2.16.1 - Tokenizers: 0.15.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} } ```