--- library_name: setfit tags: - setfit - sentence-transformers - text-classification - generated_from_setfit_trainer metrics: - accuracy widget: - text: Me dirijo a ustedes para solicitar la anulación de la multa recibida por aparcar en un espacio reservado para personas con movilidad reducida, ya que la tarjeta se encontraba en el lugar habitual en el vehículo y era perfectamente visible. - text: Solicito informe del denunciante para que explique las razones por las que se considera que la infracción no se cometió. - text: ay que alegar que con el presente expediente se vulnera el PRINCIPIO DE PROPORCIONALIDAD - text: La notificación posterior a la infracción es inválida, ya que no se cumplió con el procedimiento establecido. - text: La denuncia no fue notificada dentro del plazo establecido, por lo que se considera prescrita la acción para sancionar la supuesta infracción pipeline_tag: text-classification inference: true model-index: - name: SetFit results: - task: type: text-classification name: Text Classification dataset: name: Unknown type: unknown split: test metrics: - type: accuracy value: 0.8421052631578947 name: Accuracy --- # SetFit This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. 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 - **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:** 20 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 | |:------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 2014 | | | 2001 | | | 2026 | | | 2013 | | | 1001 | | | 304 | | | 237 | | | 2038 | | | 49 | | | 357 | | | 2022 | | | 2017 | | | 78 | | | 2037 | | | 2039 | | | 353 | | | 2002 | | | 2010 | | | 994 | | | 2060 | | ## Evaluation ### Metrics | Label | Accuracy | |:--------|:---------| | **all** | 0.8421 | ## 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("desarrolloasesoreslocales/bert-leg-al-setfit") # Run inference preds = model("ay que alegar que con el presente expediente se vulnera el PRINCIPIO DE PROPORCIONALIDAD") ``` ## Training Details ### Training Set Metrics | Training set | Min | Median | Max | |:-------------|:----|:--------|:----| | Word count | 3 | 43.1938 | 195 | | Label | Training Sample Count | |:------|:----------------------| | 49 | 8 | | 78 | 8 | | 237 | 8 | | 304 | 8 | | 353 | 8 | | 357 | 8 | | 994 | 8 | | 1001 | 8 | | 2001 | 8 | | 2002 | 8 | | 2010 | 8 | | 2013 | 8 | | 2014 | 8 | | 2017 | 8 | | 2022 | 8 | | 2026 | 8 | | 2037 | 8 | | 2038 | 8 | | 2039 | 8 | | 2060 | 8 | ### Training Hyperparameters - batch_size: (16, 16) - num_epochs: (1, 1) - max_steps: -1 - sampling_strategy: oversampling - num_iterations: 300 - body_learning_rate: (2e-05, 1e-05) - head_learning_rate: 0.0001 - loss: CosineSimilarityLoss - distance_metric: cosine_distance - margin: 0.25 - end_to_end: False - use_amp: True - warmup_proportion: 0.1 - seed: 42 - eval_max_steps: 100 - load_best_model_at_end: True ### Training Results | Epoch | Step | Training Loss | Validation Loss | |:----------:|:-------:|:-------------:|:---------------:| | 0.0002 | 1 | 0.0014 | - | | 0.0167 | 100 | 0.0001 | 0.0625 | | 0.0333 | 200 | 0.0001 | 0.0635 | | 0.05 | 300 | 0.0078 | 0.0606 | | **0.0667** | **400** | **0.0034** | **0.0587** | | 0.0833 | 500 | 0.0 | 0.0706 | | 0.1 | 600 | 0.035 | 0.0672 | | 0.1167 | 700 | 0.0385 | 0.0639 | | 0.1333 | 800 | 0.0031 | 0.0685 | | 0.15 | 900 | 0.007 | 0.0817 | | 0.1667 | 1000 | 0.0001 | 0.0721 | | 0.1833 | 1100 | 0.0005 | 0.0616 | | 0.2 | 1200 | 0.0001 | 0.0774 | | 0.2167 | 1300 | 0.0034 | 0.0692 | | 0.2333 | 1400 | 0.0001 | 0.0715 | | 0.25 | 1500 | 0.0043 | 0.0714 | | 0.2667 | 1600 | 0.001 | 0.0657 | | 0.2833 | 1700 | 0.0001 | 0.0718 | | 0.3 | 1800 | 0.0068 | 0.0681 | | 0.3167 | 1900 | 0.0 | 0.0704 | | 0.3333 | 2000 | 0.0 | 0.0677 | | 0.35 | 2100 | 0.0099 | 0.0673 | | 0.3667 | 2200 | 0.0029 | 0.0671 | | 0.3833 | 2300 | 0.0001 | 0.0677 | | 0.4 | 2400 | 0.0064 | 0.0689 | | 0.4167 | 2500 | 0.0029 | 0.0718 | | 0.4333 | 2600 | 0.0619 | 0.0611 | | 0.45 | 2700 | 0.0027 | 0.074 | | 0.4667 | 2800 | 0.0 | 0.0685 | | 0.4833 | 2900 | 0.0152 | 0.0696 | | 0.5 | 3000 | 0.0001 | 0.0672 | | 0.5167 | 3100 | 0.0023 | 0.063 | | 0.5333 | 3200 | 0.0 | 0.0722 | | 0.55 | 3300 | 0.0139 | 0.0706 | | 0.5667 | 3400 | 0.0031 | 0.0762 | | 0.5833 | 3500 | 0.0001 | 0.0662 | | 0.6 | 3600 | 0.0064 | 0.0691 | | 0.6167 | 3700 | 0.0001 | 0.0749 | | 0.6333 | 3800 | 0.0 | 0.0721 | | 0.65 | 3900 | 0.0 | 0.0717 | | 0.6667 | 4000 | 0.003 | 0.0674 | | 0.6833 | 4100 | 0.0 | 0.0695 | | 0.7 | 4200 | 0.0063 | 0.0739 | | 0.7167 | 4300 | 0.0462 | 0.0697 | | 0.7333 | 4400 | 0.0 | 0.066 | | 0.75 | 4500 | 0.0055 | 0.0691 | | 0.7667 | 4600 | 0.0 | 0.0721 | | 0.7833 | 4700 | 0.0065 | 0.0749 | | 0.8 | 4800 | 0.0 | 0.0725 | | 0.8167 | 4900 | 0.0027 | 0.0745 | | 0.8333 | 5000 | 0.0 | 0.0703 | | 0.85 | 5100 | 0.0056 | 0.0651 | | 0.8667 | 5200 | 0.0069 | 0.073 | | 0.8833 | 5300 | 0.0 | 0.0692 | | 0.9 | 5400 | 0.0108 | 0.0725 | | 0.9167 | 5500 | 0.0 | 0.0672 | | 0.9333 | 5600 | 0.0039 | 0.0691 | | 0.95 | 5700 | 0.0 | 0.0721 | | 0.9667 | 5800 | 0.0021 | 0.0715 | | 0.9833 | 5900 | 0.0 | 0.073 | | 1.0 | 6000 | 0.0061 | 0.0663 | * The bold row denotes the saved checkpoint. ### Framework Versions - Python: 3.10.12 - SetFit: 1.0.3 - Sentence Transformers: 3.0.1 - Transformers: 4.40.2 - PyTorch: 2.3.0+cu121 - Datasets: 2.20.0 - Tokenizers: 0.19.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} } ```