diff --git "a/README.md" "b/README.md" --- "a/README.md" +++ "b/README.md" @@ -5,7 +5,6 @@ tags: - sentence-transformers - text-classification - generated_from_setfit_trainer -base_model: desarrolloasesoreslocales/bert-leg-al-corpus metrics: - accuracy widget: @@ -22,7 +21,7 @@ widget: pipeline_tag: text-classification inference: true model-index: -- name: SetFit with desarrolloasesoreslocales/bert-leg-al-corpus +- name: SetFit results: - task: type: text-classification @@ -37,9 +36,9 @@ model-index: name: Accuracy --- -# SetFit with desarrolloasesoreslocales/bert-leg-al-corpus +# SetFit -This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [desarrolloasesoreslocales/bert-leg-al-corpus](https://huggingface.co/desarrolloasesoreslocales/bert-leg-al-corpus) 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. +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: @@ -50,10 +49,10 @@ The model has been trained using an efficient few-shot learning technique that i ### Model Description - **Model Type:** SetFit -- **Sentence Transformer body:** [desarrolloasesoreslocales/bert-leg-al-corpus](https://huggingface.co/desarrolloasesoreslocales/bert-leg-al-corpus) + - **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:** 19 classes +- **Number of Classes:** 20 classes @@ -65,27 +64,28 @@ The model has been trained using an efficient few-shot learning technique that i - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit) ### Model Labels -| Label | Examples | -|:------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| 49 | | -| 2017 | | -| 994 | | -| 304 | | -| 2026 | | -| 2037 | | -| 2060 | | -| 2014 | | -| 2001 | | -| 2013 | | -| 2039 | | -| 353 | | -| 1001 | | -| 2002 | | -| 2022 | | -| 2038 | | -| 2010 | | -| 78 | | -| 357 | | +| Label | Examples | +|:------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 2014 | | +| 2001 | | +| 2026 | | +| 2013 | | +| 1001 | | +| 304 | | +| 237 | | +| 2038 | | +| 49 | | +| 357 | | +| 2022 | | +| 2017 | | +| 78 | | +| 2037 | | +| 2039 | | +| 353 | | +| 2002 | | +| 2010 | | +| 994 | | +| 2060 | | ## Evaluation @@ -144,230 +144,115 @@ preds = model("ay que alegar que con el presente expediente se vulnera el PRINCI ### Training Set Metrics | Training set | Min | Median | Max | |:-------------|:----|:--------|:----| -| Word count | 4 | 36.8856 | 231 | +| Word count | 3 | 43.1938 | 195 | | Label | Training Sample Count | |:------|:----------------------| -| 49 | 36 | -| 78 | 10 | -| 304 | 22 | -| 353 | 10 | -| 357 | 10 | -| 994 | 11 | -| 1001 | 10 | -| 2001 | 10 | -| 2002 | 10 | -| 2010 | 10 | -| 2013 | 10 | -| 2014 | 10 | -| 2017 | 11 | -| 2022 | 10 | -| 2026 | 21 | -| 2037 | 10 | -| 2038 | 10 | -| 2039 | 11 | -| 2060 | 39 | +| 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: (48, 48) +- batch_size: (16, 16) - num_epochs: (1, 1) -- max_steps: 5000 +- max_steps: -1 - sampling_strategy: oversampling -- body_learning_rate: (3e-06, 3e-06) -- head_learning_rate: 2e-05 +- 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: True +- end_to_end: False - use_amp: True - warmup_proportion: 0.1 - seed: 42 - eval_max_steps: 100 -- load_best_model_at_end: False +- load_best_model_at_end: True ### Training Results -| Epoch | Step | Training Loss | Validation Loss | -|:------:|:----:|:-------------:|:---------------:| -| 0.0001 | 1 | 0.371 | - | -| 0.0074 | 50 | 0.3118 | 0.3225 | -| 0.0148 | 100 | 0.2343 | 0.1789 | -| 0.0221 | 150 | 0.1885 | 0.1228 | -| 0.0295 | 200 | 0.1359 | 0.1067 | -| 0.0369 | 250 | 0.1251 | 0.0885 | -| 0.0443 | 300 | 0.0923 | 0.0795 | -| 0.0517 | 350 | 0.0274 | 0.0752 | -| 0.0590 | 400 | 0.1386 | 0.0648 | -| 0.0664 | 450 | 0.1388 | 0.058 | -| 0.0738 | 500 | 0.0181 | 0.0602 | -| 0.0812 | 550 | 0.0151 | 0.0657 | -| 0.0886 | 600 | 0.0054 | 0.0585 | -| 0.0959 | 650 | 0.005 | 0.0558 | -| 0.1033 | 700 | 0.0077 | 0.0605 | -| 0.1107 | 750 | 0.0038 | 0.0486 | -| 0.1181 | 800 | 0.1056 | 0.0571 | -| 0.1255 | 850 | 0.1113 | 0.0548 | -| 0.1328 | 900 | 0.001 | 0.0513 | -| 0.1402 | 950 | 0.0005 | 0.0581 | -| 0.1476 | 1000 | 0.0234 | 0.0607 | -| 0.1550 | 1050 | 0.0391 | 0.052 | -| 0.1624 | 1100 | 0.0025 | 0.0519 | -| 0.1697 | 1150 | 0.0467 | 0.0536 | -| 0.1771 | 1200 | 0.0657 | 0.0516 | -| 0.1845 | 1250 | 0.1097 | 0.0492 | -| 0.1919 | 1300 | 0.0007 | 0.054 | -| 0.1993 | 1350 | 0.0268 | 0.056 | -| 0.2066 | 1400 | 0.0008 | 0.0571 | -| 0.2140 | 1450 | 0.0013 | 0.0581 | -| 0.2214 | 1500 | 0.0008 | 0.0577 | -| 0.2288 | 1550 | 0.0003 | 0.0584 | -| 0.2362 | 1600 | 0.0022 | 0.0593 | -| 0.2435 | 1650 | 0.0058 | 0.0555 | -| 0.2509 | 1700 | 0.0026 | 0.0582 | -| 0.2583 | 1750 | 0.0009 | 0.0584 | -| 0.2657 | 1800 | 0.0003 | 0.0563 | -| 0.2731 | 1850 | 0.0004 | 0.0596 | -| 0.2804 | 1900 | 0.0004 | 0.0552 | -| 0.2878 | 1950 | 0.0001 | 0.0543 | -| 0.2952 | 2000 | 0.0046 | 0.0535 | -| 0.3026 | 2050 | 0.0004 | - | -| 0.0005 | 1 | 0.0017 | - | -| 0.0235 | 50 | 0.0209 | 0.0551 | -| 0.0469 | 100 | 0.0197 | 0.0525 | -| 0.0704 | 150 | 0.0099 | 0.0555 | -| 0.0939 | 200 | 0.0284 | 0.055 | -| 0.1174 | 250 | 0.0066 | 0.0482 | -| 0.1408 | 300 | 0.0065 | 0.0485 | -| 0.1643 | 350 | 0.0003 | 0.0453 | -| 0.1878 | 400 | 0.0164 | 0.048 | -| 0.2113 | 450 | 0.0044 | 0.0488 | -| 0.2347 | 500 | 0.0013 | 0.0447 | -| 0.2582 | 550 | 0.0107 | 0.0476 | -| 0.2817 | 600 | 0.0302 | 0.047 | -| 0.3052 | 650 | 0.0028 | 0.048 | -| 0.3286 | 700 | 0.0001 | 0.0462 | -| 0.3521 | 750 | 0.0009 | 0.0477 | -| 0.3756 | 800 | 0.0004 | 0.0488 | -| 0.3991 | 850 | 0.0035 | 0.0497 | -| 0.4225 | 900 | 0.0026 | 0.0479 | -| 0.4460 | 950 | 0.0033 | 0.0497 | -| 0.4695 | 1000 | 0.0001 | 0.0493 | -| 0.0005 | 1 | 0.0001 | - | -| 0.0235 | 50 | 0.0224 | 0.0499 | -| 0.0469 | 100 | 0.0168 | 0.0486 | -| 0.0704 | 150 | 0.0067 | 0.0542 | -| 0.0939 | 200 | 0.0048 | 0.0517 | -| 0.1174 | 250 | 0.0057 | 0.0485 | -| 0.1408 | 300 | 0.0052 | 0.0557 | -| 0.1643 | 350 | 0.0006 | 0.0468 | -| 0.1878 | 400 | 0.0147 | 0.0498 | -| 0.2113 | 450 | 0.0031 | 0.0539 | -| 0.2347 | 500 | 0.0008 | 0.0487 | -| 0.2582 | 550 | 0.0104 | 0.0504 | -| 0.2817 | 600 | 0.0298 | 0.05 | -| 0.3052 | 650 | 0.0016 | 0.0525 | -| 0.3286 | 700 | 0.0001 | 0.0478 | -| 0.3521 | 750 | 0.0012 | 0.0532 | -| 0.3756 | 800 | 0.0003 | 0.052 | -| 0.3991 | 850 | 0.004 | 0.0512 | -| 0.4225 | 900 | 0.0031 | 0.0491 | -| 0.4460 | 950 | 0.0029 | 0.0496 | -| 0.4695 | 1000 | 0.0001 | 0.0495 | -| 0.4930 | 1050 | 0.0003 | 0.0483 | -| 0.5164 | 1100 | 0.0001 | 0.0558 | -| 0.5399 | 1150 | 0.0023 | 0.0533 | -| 0.5634 | 1200 | 0.013 | 0.0526 | -| 0.5869 | 1250 | 0.0052 | 0.0498 | -| 0.6103 | 1300 | 0.0002 | 0.0532 | -| 0.6338 | 1350 | 0.0038 | 0.0531 | -| 0.6573 | 1400 | 0.0015 | 0.0515 | -| 0.6808 | 1450 | 0.0056 | 0.0591 | -| 0.7042 | 1500 | 0.001 | 0.0597 | -| 0.7277 | 1550 | 0.0068 | 0.0555 | -| 0.7512 | 1600 | 0.0006 | 0.0529 | -| 0.7746 | 1650 | 0.0011 | 0.0527 | -| 0.7981 | 1700 | 0.0011 | 0.0542 | -| 0.8216 | 1750 | 0.0001 | 0.0502 | -| 0.8451 | 1800 | 0.0029 | 0.0531 | -| 0.8685 | 1850 | 0.0003 | 0.0571 | -| 0.8920 | 1900 | 0.0003 | 0.0529 | -| 0.9155 | 1950 | 0.0012 | 0.051 | -| 0.9390 | 2000 | 0.002 | 0.0511 | -| 0.9624 | 2050 | 0.0038 | 0.0539 | -| 0.9859 | 2100 | 0.0014 | 0.0495 | -| 0.0007 | 1 | 0.0018 | - | -| 0.0352 | 50 | 0.0126 | 0.051 | -| 0.0704 | 100 | 0.0063 | 0.0511 | -| 0.1056 | 150 | 0.0026 | 0.0512 | -| 0.1408 | 200 | 0.0035 | 0.0519 | -| 0.1761 | 250 | 0.0033 | 0.0508 | -| 0.2113 | 300 | 0.0028 | 0.0505 | -| 0.2465 | 350 | 0.0002 | 0.0505 | -| 0.2817 | 400 | 0.0183 | 0.0501 | -| 0.3169 | 450 | 0.0021 | 0.0505 | -| 0.3521 | 500 | 0.0018 | 0.0507 | -| 0.3873 | 550 | 0.0175 | 0.0511 | -| 0.4225 | 600 | 0.0016 | 0.0513 | -| 0.4577 | 650 | 0.0006 | 0.0508 | -| 0.4930 | 700 | 0.0031 | 0.0504 | -| 0.5282 | 750 | 0.004 | 0.0509 | -| 0.5634 | 800 | 0.0044 | 0.0511 | -| 0.5986 | 850 | 0.0013 | 0.0512 | -| 0.6338 | 900 | 0.0014 | 0.0517 | -| 0.6690 | 950 | 0.0139 | 0.0515 | -| 0.7042 | 1000 | 0.0009 | 0.0522 | -| 0.7394 | 1050 | 0.0008 | 0.0518 | -| 0.7746 | 1100 | 0.0015 | 0.0518 | -| 0.8099 | 1150 | 0.0031 | 0.0521 | -| 0.8451 | 1200 | 0.0027 | 0.0516 | -| 0.8803 | 1250 | 0.0013 | 0.0517 | -| 0.9155 | 1300 | 0.0015 | 0.0518 | -| 0.9507 | 1350 | 0.0001 | 0.052 | -| 0.9859 | 1400 | 0.001 | 0.0518 | -| 0.0007 | 1 | 0.0007 | - | -| 0.0352 | 50 | 0.0153 | 0.055 | -| 0.0704 | 100 | 0.0095 | 0.056 | -| 0.1056 | 150 | 0.0038 | 0.0692 | -| 0.1408 | 200 | 0.0072 | 0.0738 | -| 0.1761 | 250 | 0.0031 | 0.069 | -| 0.2113 | 300 | 0.0035 | 0.0618 | -| 0.2465 | 350 | 0.0004 | 0.0617 | -| 0.2817 | 400 | 0.02 | 0.0638 | -| 0.3169 | 450 | 0.003 | 0.0649 | -| 0.0007 | 1 | 0.0038 | - | -| 0.0352 | 50 | 0.0164 | 0.0607 | -| 0.0704 | 100 | 0.0084 | 0.0711 | -| 0.1056 | 150 | 0.0031 | 0.0653 | -| 0.1408 | 200 | 0.0034 | 0.0703 | -| 0.0007 | 1 | 0.0125 | - | -| 0.0352 | 50 | 0.0108 | 0.0602 | -| 0.0704 | 100 | 0.0056 | 0.0589 | -| 0.1056 | 150 | 0.0019 | 0.0598 | -| 0.1408 | 200 | 0.0025 | 0.0626 | -| 0.1761 | 250 | 0.0032 | 0.0576 | -| 0.2113 | 300 | 0.0033 | 0.0565 | -| 0.2465 | 350 | 0.0002 | 0.0574 | -| 0.2817 | 400 | 0.018 | 0.0575 | -| 0.3169 | 450 | 0.0022 | 0.0573 | -| 0.3521 | 500 | 0.0016 | 0.0553 | -| 0.3873 | 550 | 0.0165 | 0.0565 | -| 0.4225 | 600 | 0.0016 | 0.0565 | -| 0.4577 | 650 | 0.0002 | 0.0557 | -| 0.4930 | 700 | 0.0033 | 0.0553 | -| 0.5282 | 750 | 0.0039 | 0.0573 | -| 0.5634 | 800 | 0.0034 | 0.0574 | -| 0.5986 | 850 | 0.001 | 0.0578 | -| 0.6338 | 900 | 0.0017 | 0.0579 | -| 0.6690 | 950 | 0.0129 | 0.0593 | -| 0.7042 | 1000 | 0.0005 | 0.0613 | -| 0.7394 | 1050 | 0.0006 | 0.0615 | -| 0.7746 | 1100 | 0.0016 | 0.0626 | -| 0.8099 | 1150 | 0.0033 | 0.0626 | -| 0.8451 | 1200 | 0.0029 | 0.0622 | -| 0.8803 | 1250 | 0.001 | 0.063 | -| 0.9155 | 1300 | 0.0017 | 0.0616 | -| 0.9507 | 1350 | 0.0001 | 0.0625 | -| 0.9859 | 1400 | 0.0011 | 0.0624 | - +| 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