--- library_name: setfit tags: - setfit - absa - sentence-transformers - text-classification - generated_from_setfit_trainer base_model: cointegrated/rubert-tiny2 metrics: - accuracy widget: - text: Шеф - повар:Шеф - повар тоже с самого открытия . - text: 'ресторана:Сомнений по поводу выбора ресторана на свадьбу не возникло , надеюсь , что в самый важный день нашей жизни мы тоже останемся довольны , на этой неделе идем заказывать : ) .' - text: гребешки:Затем были гребешки вроде ничего , но отдавали уксусом , пюре вместе с ним было пересолено . - text: кафе:По кухне можно сказать , что это кафе для тех , кто любит соотношение цены и качества . - text: то:Я не ходила в этот ресторан в детстве , не знаю , как всё было когда - то , но сейчас это вполне симпатичное и уютное заведение с хорошей кухней . pipeline_tag: text-classification inference: false --- # SetFit Aspect Model with cointegrated/rubert-tiny2 This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Aspect Based Sentiment Analysis (ABSA). This SetFit model uses [cointegrated/rubert-tiny2](https://huggingface.co/cointegrated/rubert-tiny2) 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. In particular, this model is in charge of filtering aspect span candidates. 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. This model was trained within the context of a larger system for ABSA, which looks like so: 1. Use a spaCy model to select possible aspect span candidates. 2. **Use this SetFit model to filter these possible aspect span candidates.** 3. Use a SetFit model to classify the filtered aspect span candidates. ## Model Details ### Model Description - **Model Type:** SetFit - **Sentence Transformer body:** [cointegrated/rubert-tiny2](https://huggingface.co/cointegrated/rubert-tiny2) - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance - **spaCy Model:** en_core_web_lg - **SetFitABSA Aspect Model:** [isolation-forest/setfit-absa-aspect](https://huggingface.co/isolation-forest/setfit-absa-aspect) - **SetFitABSA Polarity Model:** [isolation-forest/setfit-absa-polarity](https://huggingface.co/isolation-forest/setfit-absa-polarity) - **Maximum Sequence Length:** 2048 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 | |:----------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | aspect | | | no aspect | | ## 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 AbsaModel # Download from the 🤗 Hub model = AbsaModel.from_pretrained( "isolation-forest/setfit-absa-aspect", "isolation-forest/setfit-absa-polarity", ) # Run inference preds = model("The food was great, but the venue is just way too busy.") ``` ## Training Details ### Training Set Metrics | Training set | Min | Median | Max | |:-------------|:----|:--------|:----| | Word count | 3 | 32.2987 | 171 | | Label | Training Sample Count | |:----------|:----------------------| | no aspect | 380 | | aspect | 256 | ### Training Hyperparameters - batch_size: (16, 2) - num_epochs: (1, 16) - 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 - seed: 42 - eval_max_steps: -1 - load_best_model_at_end: False ### Training Results | Epoch | Step | Training Loss | Validation Loss | |:------:|:-----:|:-------------:|:---------------:| | 0.0001 | 1 | 0.2618 | - | | 0.0038 | 50 | 0.2144 | - | | 0.0076 | 100 | 0.2504 | - | | 0.0114 | 150 | 0.2392 | - | | 0.0152 | 200 | 0.2717 | - | | 0.0190 | 250 | 0.2488 | - | | 0.0228 | 300 | 0.2256 | - | | 0.0266 | 350 | 0.2266 | - | | 0.0304 | 400 | 0.2203 | - | | 0.0342 | 450 | 0.2439 | - | | 0.0380 | 500 | 0.2463 | - | | 0.0418 | 550 | 0.3144 | - | | 0.0456 | 600 | 0.1814 | - | | 0.0494 | 650 | 0.1585 | - | | 0.0532 | 700 | 0.0941 | - | | 0.0570 | 750 | 0.1534 | - | | 0.0608 | 800 | 0.0915 | - | | 0.0646 | 850 | 0.1498 | - | | 0.0684 | 900 | 0.0862 | - | | 0.0722 | 950 | 0.0919 | - | | 0.0760 | 1000 | 0.0252 | - | | 0.0798 | 1050 | 0.0441 | - | | 0.0836 | 1100 | 0.0808 | - | | 0.0874 | 1150 | 0.1103 | - | | 0.0912 | 1200 | 0.0138 | - | | 0.0950 | 1250 | 0.052 | - | | 0.0988 | 1300 | 0.0564 | - | | 0.1026 | 1350 | 0.0058 | - | | 0.1064 | 1400 | 0.0177 | - | | 0.1102 | 1450 | 0.0651 | - | | 0.1140 | 1500 | 0.0046 | - | | 0.1178 | 1550 | 0.0046 | - | | 0.1216 | 1600 | 0.0053 | - | | 0.1254 | 1650 | 0.0464 | - | | 0.1292 | 1700 | 0.0043 | - | | 0.1330 | 1750 | 0.0403 | - | | 0.1368 | 1800 | 0.0609 | - | | 0.1406 | 1850 | 0.0093 | - | | 0.1444 | 1900 | 0.0027 | - | | 0.1482 | 1950 | 0.0041 | - | | 0.1520 | 2000 | 0.0028 | - | | 0.1558 | 2050 | 0.0072 | - | | 0.1596 | 2100 | 0.0033 | - | | 0.1634 | 2150 | 0.0029 | - | | 0.1672 | 2200 | 0.0036 | - | | 0.1710 | 2250 | 0.0019 | - | | 0.1748 | 2300 | 0.0026 | - | | 0.1786 | 2350 | 0.0544 | - | | 0.1824 | 2400 | 0.0024 | - | | 0.1862 | 2450 | 0.0028 | - | | 0.1900 | 2500 | 0.0025 | - | | 0.1938 | 2550 | 0.0018 | - | | 0.1976 | 2600 | 0.0021 | - | | 0.2014 | 2650 | 0.0023 | - | | 0.2052 | 2700 | 0.0021 | - | | 0.2090 | 2750 | 0.0026 | - | | 0.2127 | 2800 | 0.0016 | - | | 0.2165 | 2850 | 0.0023 | - | | 0.2203 | 2900 | 0.0032 | - | | 0.2241 | 2950 | 0.0019 | - | | 0.2279 | 3000 | 0.0027 | - | | 0.2317 | 3050 | 0.0035 | - | | 0.2355 | 3100 | 0.0022 | - | | 0.2393 | 3150 | 0.0019 | - | | 0.2431 | 3200 | 0.0017 | - | | 0.2469 | 3250 | 0.0016 | - | | 0.2507 | 3300 | 0.0016 | - | | 0.2545 | 3350 | 0.0017 | - | | 0.2583 | 3400 | 0.0029 | - | | 0.2621 | 3450 | 0.0017 | - | | 0.2659 | 3500 | 0.0016 | - | | 0.2697 | 3550 | 0.0019 | - | | 0.2735 | 3600 | 0.0093 | - | | 0.2773 | 3650 | 0.0023 | - | | 0.2811 | 3700 | 0.0012 | - | | 0.2849 | 3750 | 0.0016 | - | | 0.2887 | 3800 | 0.0016 | - | | 0.2925 | 3850 | 0.0021 | - | | 0.2963 | 3900 | 0.0016 | - | | 0.3001 | 3950 | 0.0017 | - | | 0.3039 | 4000 | 0.0013 | - | | 0.3077 | 4050 | 0.0017 | - | | 0.3115 | 4100 | 0.0011 | - | | 0.3153 | 4150 | 0.002 | - | | 0.3191 | 4200 | 0.0015 | - | | 0.3229 | 4250 | 0.001 | - | | 0.3267 | 4300 | 0.0017 | - | | 0.3305 | 4350 | 0.0011 | - | | 0.3343 | 4400 | 0.0061 | - | | 0.3381 | 4450 | 0.0057 | - | | 0.3419 | 4500 | 0.0465 | - | | 0.3457 | 4550 | 0.0016 | - | | 0.3495 | 4600 | 0.0014 | - | | 0.3533 | 4650 | 0.0013 | - | | 0.3571 | 4700 | 0.0014 | - | | 0.3609 | 4750 | 0.0018 | - | | 0.3647 | 4800 | 0.0014 | - | | 0.3685 | 4850 | 0.0013 | - | | 0.3723 | 4900 | 0.0009 | - | | 0.3761 | 4950 | 0.0008 | - | | 0.3799 | 5000 | 0.0011 | - | | 0.3837 | 5050 | 0.002 | - | | 0.3875 | 5100 | 0.0014 | - | | 0.3913 | 5150 | 0.001 | - | | 0.3951 | 5200 | 0.0012 | - | | 0.3989 | 5250 | 0.0017 | - | | 0.4027 | 5300 | 0.0011 | - | | 0.4065 | 5350 | 0.0012 | - | | 0.4103 | 5400 | 0.0009 | - | | 0.4141 | 5450 | 0.0015 | - | | 0.4179 | 5500 | 0.0009 | - | | 0.4217 | 5550 | 0.0012 | - | | 0.4255 | 5600 | 0.0013 | - | | 0.4293 | 5650 | 0.0465 | - | | 0.4331 | 5700 | 0.0011 | - | | 0.4369 | 5750 | 0.0008 | - | | 0.4407 | 5800 | 0.0012 | - | | 0.4445 | 5850 | 0.0008 | - | | 0.4483 | 5900 | 0.0013 | - | | 0.4521 | 5950 | 0.0011 | - | | 0.4559 | 6000 | 0.0229 | - | | 0.4597 | 6050 | 0.0012 | - | | 0.4635 | 6100 | 0.0009 | - | | 0.4673 | 6150 | 0.0011 | - | | 0.4711 | 6200 | 0.0011 | - | | 0.4749 | 6250 | 0.001 | - | | 0.4787 | 6300 | 0.0008 | - | | 0.4825 | 6350 | 0.0011 | - | | 0.4863 | 6400 | 0.0012 | - | | 0.4901 | 6450 | 0.0008 | - | | 0.4939 | 6500 | 0.0014 | - | | 0.4977 | 6550 | 0.001 | - | | 0.5015 | 6600 | 0.0014 | - | | 0.5053 | 6650 | 0.001 | - | | 0.5091 | 6700 | 0.0008 | - | | 0.5129 | 6750 | 0.0013 | - | | 0.5167 | 6800 | 0.0012 | - | | 0.5205 | 6850 | 0.0009 | - | | 0.5243 | 6900 | 0.0008 | - | | 0.5281 | 6950 | 0.001 | - | | 0.5319 | 7000 | 0.0012 | - | | 0.5357 | 7050 | 0.0009 | - | | 0.5395 | 7100 | 0.0007 | - | | 0.5433 | 7150 | 0.0008 | - | | 0.5471 | 7200 | 0.001 | - | | 0.5509 | 7250 | 0.0006 | - | | 0.5547 | 7300 | 0.0007 | - | | 0.5585 | 7350 | 0.0012 | - | | 0.5623 | 7400 | 0.0159 | - | | 0.5661 | 7450 | 0.0008 | - | | 0.5699 | 7500 | 0.0012 | - | | 0.5737 | 7550 | 0.0011 | - | | 0.5775 | 7600 | 0.0008 | - | | 0.5813 | 7650 | 0.0009 | - | | 0.5851 | 7700 | 0.0005 | - | | 0.5889 | 7750 | 0.0017 | - | | 0.5927 | 7800 | 0.0009 | - | | 0.5965 | 7850 | 0.0007 | - | | 0.6003 | 7900 | 0.0065 | - | | 0.6041 | 7950 | 0.0007 | - | | 0.6079 | 8000 | 0.0041 | - | | 0.6117 | 8050 | 0.0009 | - | | 0.6155 | 8100 | 0.038 | - | | 0.6193 | 8150 | 0.0005 | - | | 0.6231 | 8200 | 0.0356 | - | | 0.6269 | 8250 | 0.0007 | - | | 0.6307 | 8300 | 0.0008 | - | | 0.6345 | 8350 | 0.0009 | - | | 0.6382 | 8400 | 0.001 | - | | 0.6420 | 8450 | 0.0009 | - | | 0.6458 | 8500 | 0.0008 | - | | 0.6496 | 8550 | 0.0009 | - | | 0.6534 | 8600 | 0.0009 | - | | 0.6572 | 8650 | 0.0008 | - | | 0.6610 | 8700 | 0.0006 | - | | 0.6648 | 8750 | 0.0009 | - | | 0.6686 | 8800 | 0.0006 | - | | 0.6724 | 8850 | 0.0008 | - | | 0.6762 | 8900 | 0.0008 | - | | 0.6800 | 8950 | 0.0245 | - | | 0.6838 | 9000 | 0.0007 | - | | 0.6876 | 9050 | 0.0008 | - | | 0.6914 | 9100 | 0.0007 | - | | 0.6952 | 9150 | 0.0006 | - | | 0.6990 | 9200 | 0.0009 | - | | 0.7028 | 9250 | 0.0011 | - | | 0.7066 | 9300 | 0.0009 | - | | 0.7104 | 9350 | 0.0008 | - | | 0.7142 | 9400 | 0.0008 | - | | 0.7180 | 9450 | 0.0007 | - | | 0.7218 | 9500 | 0.0006 | - | | 0.7256 | 9550 | 0.0233 | - | | 0.7294 | 9600 | 0.0008 | - | | 0.7332 | 9650 | 0.0173 | - | | 0.7370 | 9700 | 0.0006 | - | | 0.7408 | 9750 | 0.0007 | - | | 0.7446 | 9800 | 0.0007 | - | | 0.7484 | 9850 | 0.001 | - | | 0.7522 | 9900 | 0.0007 | - | | 0.7560 | 9950 | 0.0006 | - | | 0.7598 | 10000 | 0.0006 | - | | 0.7636 | 10050 | 0.0008 | - | | 0.7674 | 10100 | 0.0005 | - | | 0.7712 | 10150 | 0.0007 | - | | 0.7750 | 10200 | 0.0007 | - | | 0.7788 | 10250 | 0.0009 | - | | 0.7826 | 10300 | 0.0008 | - | | 0.7864 | 10350 | 0.0007 | - | | 0.7902 | 10400 | 0.0009 | - | | 0.7940 | 10450 | 0.0007 | - | | 0.7978 | 10500 | 0.0007 | - | | 0.8016 | 10550 | 0.0008 | - | | 0.8054 | 10600 | 0.0007 | - | | 0.8092 | 10650 | 0.0007 | - | | 0.8130 | 10700 | 0.0007 | - | | 0.8168 | 10750 | 0.0007 | - | | 0.8206 | 10800 | 0.0005 | - | | 0.8244 | 10850 | 0.0007 | - | | 0.8282 | 10900 | 0.0005 | - | | 0.8320 | 10950 | 0.0005 | - | | 0.8358 | 11000 | 0.0006 | - | | 0.8396 | 11050 | 0.0008 | - | | 0.8434 | 11100 | 0.0008 | - | | 0.8472 | 11150 | 0.0137 | - | | 0.8510 | 11200 | 0.0008 | - | | 0.8548 | 11250 | 0.012 | - | | 0.8586 | 11300 | 0.0006 | - | | 0.8624 | 11350 | 0.0007 | - | | 0.8662 | 11400 | 0.0007 | - | | 0.8700 | 11450 | 0.0009 | - | | 0.8738 | 11500 | 0.0007 | - | | 0.8776 | 11550 | 0.0008 | - | | 0.8814 | 11600 | 0.0005 | - | | 0.8852 | 11650 | 0.0008 | - | | 0.8890 | 11700 | 0.0008 | - | | 0.8928 | 11750 | 0.0007 | - | | 0.8966 | 11800 | 0.0006 | - | | 0.9004 | 11850 | 0.0006 | - | | 0.9042 | 11900 | 0.0006 | - | | 0.9080 | 11950 | 0.0007 | - | | 0.9118 | 12000 | 0.0005 | - | | 0.9156 | 12050 | 0.0007 | - | | 0.9194 | 12100 | 0.0006 | - | | 0.9232 | 12150 | 0.0008 | - | | 0.9270 | 12200 | 0.0006 | - | | 0.9308 | 12250 | 0.0005 | - | | 0.9346 | 12300 | 0.0167 | - | | 0.9384 | 12350 | 0.0008 | - | | 0.9422 | 12400 | 0.0005 | - | | 0.9460 | 12450 | 0.0233 | - | | 0.9498 | 12500 | 0.001 | - | | 0.9536 | 12550 | 0.0006 | - | | 0.9574 | 12600 | 0.0007 | - | | 0.9612 | 12650 | 0.0007 | - | | 0.9650 | 12700 | 0.0006 | - | | 0.9688 | 12750 | 0.0008 | - | | 0.9726 | 12800 | 0.0006 | - | | 0.9764 | 12850 | 0.0177 | - | | 0.9802 | 12900 | 0.0008 | - | | 0.9840 | 12950 | 0.0007 | - | | 0.9878 | 13000 | 0.0131 | - | | 0.9916 | 13050 | 0.0007 | - | | 0.9954 | 13100 | 0.0006 | - | | 0.9992 | 13150 | 0.0004 | - | ### Framework Versions - Python: 3.10.13 - SetFit: 1.0.3 - Sentence Transformers: 2.6.1 - spaCy: 3.7.2 - Transformers: 4.39.3 - PyTorch: 2.1.2 - 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} } ```