saraestevez commited on
Commit
944e24d
1 Parent(s): 32b0edc

Add SetFit model

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 768,
3
+ "pooling_mode_cls_token": false,
4
+ "pooling_mode_mean_tokens": true,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false,
7
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": false,
9
+ "include_prompt": true
10
+ }
README.md ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: FacebookAI/xlm-roberta-base
3
+ library_name: setfit
4
+ metrics:
5
+ - accuracy
6
+ pipeline_tag: text-classification
7
+ tags:
8
+ - setfit
9
+ - sentence-transformers
10
+ - text-classification
11
+ - generated_from_setfit_trainer
12
+ widget:
13
+ - text: Banco Sabadell confirma el día de pago de pensiones para jubilados en agosto.
14
+ - text: Banco Santander supera resistencias y avanza hacia máximos anuales, lo que
15
+ tiene implicaciones para los inversores.
16
+ - text: Abre una cuenta online gratuita en BBVA, domicilia tu nómina durante 12 meses
17
+ y recibe 250€ usando el código 90030031951793.
18
+ - text: MyInvestor tiene una grave falta de oferta en acciones individuales y sus
19
+ comisiones son peores que las de ING en ese mismo ámbito.
20
+ - text: Los recicladores están durmiendo en la vereda del BBVA y el fin de semana
21
+ dentro del cajero, mientras la seguridad parece ausente.
22
+ inference: true
23
+ model-index:
24
+ - name: SetFit with FacebookAI/xlm-roberta-base
25
+ results:
26
+ - task:
27
+ type: text-classification
28
+ name: Text Classification
29
+ dataset:
30
+ name: Unknown
31
+ type: unknown
32
+ split: test
33
+ metrics:
34
+ - type: accuracy
35
+ value: 0.7138461538461538
36
+ name: Accuracy
37
+ ---
38
+
39
+ # SetFit with FacebookAI/xlm-roberta-base
40
+
41
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [FacebookAI/xlm-roberta-base](https://huggingface.co/FacebookAI/xlm-roberta-base) 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.
42
+
43
+ The model has been trained using an efficient few-shot learning technique that involves:
44
+
45
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
46
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
47
+
48
+ ## Model Details
49
+
50
+ ### Model Description
51
+ - **Model Type:** SetFit
52
+ - **Sentence Transformer body:** [FacebookAI/xlm-roberta-base](https://huggingface.co/FacebookAI/xlm-roberta-base)
53
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
54
+ - **Maximum Sequence Length:** 512 tokens
55
+ - **Number of Classes:** 2 classes
56
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
57
+ <!-- - **Language:** Unknown -->
58
+ <!-- - **License:** Unknown -->
59
+
60
+ ### Model Sources
61
+
62
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
63
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
64
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
65
+
66
+ ### Model Labels
67
+ | Label | Examples |
68
+ |:---------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
69
+ | discard | <ul><li>'Las negociaciones para el Banco de España avanzan rápidamente y el Congreso convocará el jueves la comisión de economía para anunciar los nombres pactados, con Conthe como la candidata más firme a gobernadora.'</li><li>'Depósitos y seguros son aspectos fundamentales para atraer clientes y potenciar el negocio de Caixabank en la segunda mitad del año.'</li><li>'El Banco Santander ofrece 400€ al cambiar tu nómina a su cuenta en línea, eliminando las comisiones bancarias.'</li></ul> |
70
+ | relevant | <ul><li>'Nuevo caso de phishing relacionado con Evobanco registrado el 13 de julio de 2024.'</li><li>'El Banco Sabadell ofrece depósitos a plazo fijo con un interés del 2,5% TAE a 1 año y 3% TAE a 6 meses, lo cual es una buena opción.'</li><li>'Estoy en Abanca porque no me cobran comisiones, de lo contrario ya los habría dejado.'</li></ul> |
71
+
72
+ ## Evaluation
73
+
74
+ ### Metrics
75
+ | Label | Accuracy |
76
+ |:--------|:---------|
77
+ | **all** | 0.7138 |
78
+
79
+ ## Uses
80
+
81
+ ### Direct Use for Inference
82
+
83
+ First install the SetFit library:
84
+
85
+ ```bash
86
+ pip install setfit
87
+ ```
88
+
89
+ Then you can load this model and run inference.
90
+
91
+ ```python
92
+ from setfit import SetFitModel
93
+
94
+ # Download from the 🤗 Hub
95
+ model = SetFitModel.from_pretrained("saraestevez/setfit-xlm-bank-tweets-processed-80")
96
+ # Run inference
97
+ preds = model("Banco Sabadell confirma el día de pago de pensiones para jubilados en agosto.")
98
+ ```
99
+
100
+ <!--
101
+ ### Downstream Use
102
+
103
+ *List how someone could finetune this model on their own dataset.*
104
+ -->
105
+
106
+ <!--
107
+ ### Out-of-Scope Use
108
+
109
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
110
+ -->
111
+
112
+ <!--
113
+ ## Bias, Risks and Limitations
114
+
115
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
116
+ -->
117
+
118
+ <!--
119
+ ### Recommendations
120
+
121
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
122
+ -->
123
+
124
+ ## Training Details
125
+
126
+ ### Training Set Metrics
127
+ | Training set | Min | Median | Max |
128
+ |:-------------|:----|:--------|:----|
129
+ | Word count | 1 | 21.0437 | 36 |
130
+
131
+ | Label | Training Sample Count |
132
+ |:---------|:----------------------|
133
+ | discard | 80 |
134
+ | relevant | 80 |
135
+
136
+ ### Training Hyperparameters
137
+ - batch_size: (16, 16)
138
+ - num_epochs: (1, 1)
139
+ - max_steps: -1
140
+ - sampling_strategy: oversampling
141
+ - num_iterations: 20
142
+ - body_learning_rate: (2e-05, 2e-05)
143
+ - head_learning_rate: 2e-05
144
+ - loss: CosineSimilarityLoss
145
+ - distance_metric: cosine_distance
146
+ - margin: 0.25
147
+ - end_to_end: False
148
+ - use_amp: False
149
+ - warmup_proportion: 0.1
150
+ - seed: 42
151
+ - eval_max_steps: -1
152
+ - load_best_model_at_end: False
153
+
154
+ ### Training Results
155
+ | Epoch | Step | Training Loss | Validation Loss |
156
+ |:------:|:----:|:-------------:|:---------------:|
157
+ | 0.0025 | 1 | 0.4924 | - |
158
+ | 0.125 | 50 | 0.2519 | - |
159
+ | 0.25 | 100 | 0.186 | - |
160
+ | 0.375 | 150 | 0.188 | - |
161
+ | 0.5 | 200 | 0.0504 | - |
162
+ | 0.625 | 250 | 0.0412 | - |
163
+ | 0.75 | 300 | 0.0147 | - |
164
+ | 0.875 | 350 | 0.0517 | - |
165
+ | 1.0 | 400 | 0.0162 | - |
166
+
167
+ ### Framework Versions
168
+ - Python: 3.11.0rc1
169
+ - SetFit: 1.0.3
170
+ - Sentence Transformers: 2.7.0
171
+ - Transformers: 4.39.0
172
+ - PyTorch: 2.3.1+cu121
173
+ - Datasets: 2.19.1
174
+ - Tokenizers: 0.15.2
175
+
176
+ ## Citation
177
+
178
+ ### BibTeX
179
+ ```bibtex
180
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
181
+ doi = {10.48550/ARXIV.2209.11055},
182
+ url = {https://arxiv.org/abs/2209.11055},
183
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
184
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
185
+ title = {Efficient Few-Shot Learning Without Prompts},
186
+ publisher = {arXiv},
187
+ year = {2022},
188
+ copyright = {Creative Commons Attribution 4.0 International}
189
+ }
190
+ ```
191
+
192
+ <!--
193
+ ## Glossary
194
+
195
+ *Clearly define terms in order to be accessible across audiences.*
196
+ -->
197
+
198
+ <!--
199
+ ## Model Card Authors
200
+
201
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
202
+ -->
203
+
204
+ <!--
205
+ ## Model Card Contact
206
+
207
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
208
+ -->
config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "FacebookAI/xlm-roberta-base",
3
+ "architectures": [
4
+ "XLMRobertaModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": null,
9
+ "eos_token_id": 2,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 768,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 3072,
15
+ "layer_norm_eps": 1e-05,
16
+ "max_position_embeddings": 514,
17
+ "model_type": "xlm-roberta",
18
+ "num_attention_heads": 12,
19
+ "num_hidden_layers": 12,
20
+ "output_past": true,
21
+ "pad_token_id": 1,
22
+ "position_embedding_type": "absolute",
23
+ "torch_dtype": "float32",
24
+ "transformers_version": "4.39.0",
25
+ "type_vocab_size": 1,
26
+ "use_cache": true,
27
+ "vocab_size": 250002
28
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.7.0",
4
+ "transformers": "4.39.0",
5
+ "pytorch": "2.3.1+cu121"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null
9
+ }
config_setfit.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "labels": [
3
+ "discard",
4
+ "relevant"
5
+ ],
6
+ "normalize_embeddings": false
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7672b04b5dee9d8e3e67eb39847d23e314bf991a59902b4ef67299db15000251
3
+ size 1112197096
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b568d3044fe69cdcb2c5a600302c70fc3b4d9d5c4d17f9b2fe0d7128e9653f33
3
+ size 7039
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.models.Pooling"
13
+ }
14
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 512,
3
+ "do_lower_case": false
4
+ }
sentencepiece.bpe.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
3
+ size 5069051
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "cls_token": "<s>",
4
+ "eos_token": "</s>",
5
+ "mask_token": {
6
+ "content": "<mask>",
7
+ "lstrip": true,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "pad_token": "<pad>",
13
+ "sep_token": "</s>",
14
+ "unk_token": "<unk>"
15
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1cc44ad7faaeec47241864835473fd5403f2da94673f3f764a77ebcb0a803ec
3
+ size 17083009
tokenizer_config.json ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<s>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<pad>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "</s>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "<unk>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "250001": {
36
+ "content": "<mask>",
37
+ "lstrip": true,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "<s>",
45
+ "clean_up_tokenization_spaces": true,
46
+ "cls_token": "<s>",
47
+ "eos_token": "</s>",
48
+ "mask_token": "<mask>",
49
+ "model_max_length": 512,
50
+ "pad_token": "<pad>",
51
+ "sep_token": "</s>",
52
+ "tokenizer_class": "XLMRobertaTokenizer",
53
+ "unk_token": "<unk>"
54
+ }