cnmoro commited on
Commit
22bcaca
·
verified ·
1 Parent(s): f1948c4

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": 384,
3
+ "pooling_mode_cls_token": true,
4
+ "pooling_mode_mean_tokens": false,
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,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - setfit
4
+ - sentence-transformers
5
+ - text-classification
6
+ - generated_from_setfit_trainer
7
+ widget:
8
+ - text: Solicite um relatório financeiro trimestral via ERP conectado.
9
+ - text: If you save $200 monthly, how much money will you have saved after 18 months?
10
+ - text: Get the stock price history of Tesla for the last month.
11
+ - text: Given a historical archive of economic indicators, build a forecasting model
12
+ that predicts recessions, incorporating leading, lagging, and coincident indicators
13
+ with explainable outputs.
14
+ - text: Narrate the experience of a character born without the ability to dream.
15
+ metrics:
16
+ - accuracy
17
+ pipeline_tag: text-classification
18
+ library_name: setfit
19
+ inference: true
20
+ base_model: ibm-granite/granite-embedding-107m-multilingual
21
+ model-index:
22
+ - name: SetFit with ibm-granite/granite-embedding-107m-multilingual
23
+ results:
24
+ - task:
25
+ type: text-classification
26
+ name: Text Classification
27
+ dataset:
28
+ name: Unknown
29
+ type: unknown
30
+ split: test
31
+ metrics:
32
+ - type: accuracy
33
+ value: 0.9966555183946488
34
+ name: Accuracy
35
+ ---
36
+
37
+ # SetFit with ibm-granite/granite-embedding-107m-multilingual
38
+
39
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [ibm-granite/granite-embedding-107m-multilingual](https://huggingface.co/ibm-granite/granite-embedding-107m-multilingual) 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.
40
+
41
+ The model has been trained using an efficient few-shot learning technique that involves:
42
+
43
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
44
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
45
+
46
+ ## Model Details
47
+
48
+ ### Model Description
49
+ - **Model Type:** SetFit
50
+ - **Sentence Transformer body:** [ibm-granite/granite-embedding-107m-multilingual](https://huggingface.co/ibm-granite/granite-embedding-107m-multilingual)
51
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
52
+ - **Maximum Sequence Length:** 512 tokens
53
+ - **Number of Classes:** 8 classes
54
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
55
+ <!-- - **Language:** Unknown -->
56
+ <!-- - **License:** Unknown -->
57
+
58
+ ### Model Sources
59
+
60
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
61
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
62
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
63
+
64
+ ### Model Labels
65
+ | Label | Examples |
66
+ |:------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
67
+ | summarization | <ul><li>'Resuma um texto acadêmico sobre psicologia do comportamento.'</li><li>'Summarize the timeline and outcomes of a historical event based on multiple eyewitness accounts.'</li><li>'Extract and summarize the key lessons learned from multiple post-project reviews.'</li></ul> |
68
+ | general_knowledge | <ul><li>'Qual é a importância da agricultura para a economia brasileira?'</li><li>'Quais são os principais países membros da Organização dos Países Exportadores de Petróleo (OPEP)?'</li><li>'What is the mechanism by which vaccines provide immunity?'</li></ul> |
69
+ | roleplay | <ul><li>'Personifique um chef pâtissier criando uma sobremesa para um júri exigente.'</li><li>'You are a software tester devising scenarios to uncover bugs in a complex system.'</li><li>'Simule uma reunião de conselho editorial decidindo o rumo de uma grande publicação.'</li></ul> |
70
+ | creativity | <ul><li>'Write a thriller in which the protagonist communicates only through artwork.'</li><li>'Imagine um poema narrativo sobre a relação entre o sertão e a poesia de uma geração esquecida.'</li><li>'Write a story from the perspective of a shadow that gains independence.'</li></ul> |
71
+ | complex_reasoning | <ul><li>'Analise as implicações do uso de drones autônomos para entregas em áreas urbanas densas.'</li><li>'Proponha um sistema para avaliação automatizada e justa de currículos em processos seletivos corporativos.'</li><li>'Proponha um modelo para prever o crescimento urbano sustentável considerando variáveis ambientais e sociais.'</li></ul> |
72
+ | coding | <ul><li>'Implemente uma função para decompor números inteiros em fatores primos eficientemente para valores grandes.'</li><li>'Create an integration that consumes streaming data from an external message broker and processes events in real-time with backpressure management.'</li><li>'Escreva um algoritmo para encontrar os pontos de articulação (cut vertices) em um grafo não direcionado.'</li></ul> |
73
+ | basic_reasoning | <ul><li>'Se um carro consome 12 litros de gasolina para 100 km, quantos litros usará para 150 km?'</li><li>'If a ladder leans against a wall forming a 60-degree angle and the ladder length is 10 feet, how high does it reach on the wall?'</li><li>'Quantos centímetros tem 1 metro?'</li></ul> |
74
+ | tool | <ul><li>'Fetch comprehensive user reviews and ratings for a mobile app across platforms.'</li><li>'Analyze sentiment of a tweet and classify it as positive, neutral, or negative.'</li><li>'Retrieve country-wise COVID-19 vaccination rates from an authoritative source.'</li></ul> |
75
+
76
+ ## Evaluation
77
+
78
+ ### Metrics
79
+ | Label | Accuracy |
80
+ |:--------|:---------|
81
+ | **all** | 0.9967 |
82
+
83
+ ## Uses
84
+
85
+ ### Direct Use for Inference
86
+
87
+ First install the SetFit library:
88
+
89
+ ```bash
90
+ pip install setfit
91
+ ```
92
+
93
+ Then you can load this model and run inference.
94
+
95
+ ```python
96
+ from setfit import SetFitModel
97
+
98
+ # Download from the 🤗 Hub
99
+ model = SetFitModel.from_pretrained("cnmoro/prompt-router")
100
+ # Run inference
101
+ preds = model("Get the stock price history of Tesla for the last month.")
102
+ ```
103
+
104
+ <!--
105
+ ### Downstream Use
106
+
107
+ *List how someone could finetune this model on their own dataset.*
108
+ -->
109
+
110
+ <!--
111
+ ### Out-of-Scope Use
112
+
113
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
114
+ -->
115
+
116
+ <!--
117
+ ## Bias, Risks and Limitations
118
+
119
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
120
+ -->
121
+
122
+ <!--
123
+ ### Recommendations
124
+
125
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
126
+ -->
127
+
128
+ ## Training Details
129
+
130
+ ### Training Set Metrics
131
+ | Training set | Min | Median | Max |
132
+ |:-------------|:----|:--------|:----|
133
+ | Word count | 5 | 13.6792 | 38 |
134
+
135
+ | Label | Training Sample Count |
136
+ |:------------------|:----------------------|
137
+ | summarization | 160 |
138
+ | tool | 144 |
139
+ | general_knowledge | 154 |
140
+ | roleplay | 145 |
141
+ | complex_reasoning | 130 |
142
+ | creativity | 164 |
143
+ | coding | 152 |
144
+ | basic_reasoning | 148 |
145
+
146
+ ### Training Hyperparameters
147
+ - batch_size: (8, 8)
148
+ - num_epochs: (1, 16)
149
+ - max_steps: 2400
150
+ - sampling_strategy: oversampling
151
+ - body_learning_rate: (2e-05, 1e-05)
152
+ - head_learning_rate: 0.01
153
+ - loss: CosineSimilarityLoss
154
+ - distance_metric: cosine_distance
155
+ - margin: 0.25
156
+ - end_to_end: False
157
+ - use_amp: False
158
+ - warmup_proportion: 0.1
159
+ - l2_weight: 0.01
160
+ - seed: 42
161
+ - evaluation_strategy: steps
162
+ - eval_max_steps: -1
163
+ - load_best_model_at_end: True
164
+
165
+ ### Training Results
166
+ | Epoch | Step | Training Loss | Validation Loss |
167
+ |:------:|:----:|:-------------:|:---------------:|
168
+ | 0.0004 | 1 | 0.1954 | - |
169
+ | 0.0208 | 50 | 0.2125 | - |
170
+ | 0.0417 | 100 | 0.2131 | - |
171
+ | 0.0625 | 150 | 0.2072 | - |
172
+ | 0.0833 | 200 | 0.2029 | 0.1902 |
173
+ | 0.1042 | 250 | 0.1925 | - |
174
+ | 0.125 | 300 | 0.1764 | - |
175
+ | 0.1458 | 350 | 0.1512 | - |
176
+ | 0.1667 | 400 | 0.1229 | 0.1072 |
177
+ | 0.1875 | 450 | 0.1015 | - |
178
+ | 0.2083 | 500 | 0.0862 | - |
179
+ | 0.2292 | 550 | 0.065 | - |
180
+ | 0.25 | 600 | 0.0505 | 0.0504 |
181
+ | 0.2708 | 650 | 0.0532 | - |
182
+ | 0.2917 | 700 | 0.0427 | - |
183
+ | 0.3125 | 750 | 0.0378 | - |
184
+ | 0.3333 | 800 | 0.0357 | 0.0322 |
185
+ | 0.3542 | 850 | 0.0286 | - |
186
+ | 0.375 | 900 | 0.0381 | - |
187
+ | 0.3958 | 950 | 0.0333 | - |
188
+ | 0.4167 | 1000 | 0.0307 | 0.0235 |
189
+ | 0.4375 | 1050 | 0.0245 | - |
190
+ | 0.4583 | 1100 | 0.0245 | - |
191
+ | 0.4792 | 1150 | 0.0217 | - |
192
+ | 0.5 | 1200 | 0.0193 | 0.0168 |
193
+ | 0.5208 | 1250 | 0.0167 | - |
194
+ | 0.5417 | 1300 | 0.0158 | - |
195
+ | 0.5625 | 1350 | 0.02 | - |
196
+ | 0.5833 | 1400 | 0.0167 | 0.0120 |
197
+ | 0.6042 | 1450 | 0.0176 | - |
198
+ | 0.625 | 1500 | 0.0159 | - |
199
+ | 0.6458 | 1550 | 0.0141 | - |
200
+ | 0.6667 | 1600 | 0.0131 | 0.0094 |
201
+ | 0.6875 | 1650 | 0.0097 | - |
202
+ | 0.7083 | 1700 | 0.0109 | - |
203
+ | 0.7292 | 1750 | 0.0126 | - |
204
+ | 0.75 | 1800 | 0.0115 | 0.0079 |
205
+ | 0.7708 | 1850 | 0.0122 | - |
206
+ | 0.7917 | 1900 | 0.0104 | - |
207
+ | 0.8125 | 1950 | 0.0111 | - |
208
+ | 0.8333 | 2000 | 0.011 | 0.0071 |
209
+ | 0.8542 | 2050 | 0.0095 | - |
210
+ | 0.875 | 2100 | 0.009 | - |
211
+ | 0.8958 | 2150 | 0.0107 | - |
212
+ | 0.9167 | 2200 | 0.0099 | 0.0067 |
213
+ | 0.9375 | 2250 | 0.0084 | - |
214
+ | 0.9583 | 2300 | 0.0086 | - |
215
+ | 0.9792 | 2350 | 0.0089 | - |
216
+ | 1.0 | 2400 | 0.0098 | 0.0066 |
217
+
218
+ ### Framework Versions
219
+ - Python: 3.11.11
220
+ - SetFit: 1.2.0.dev0
221
+ - Sentence Transformers: 4.0.2
222
+ - Transformers: 4.51.3
223
+ - PyTorch: 2.6.0+cu124
224
+ - Datasets: 3.5.0
225
+ - Tokenizers: 0.21.1
226
+
227
+ ## Citation
228
+
229
+ ### BibTeX
230
+ ```bibtex
231
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
232
+ doi = {10.48550/ARXIV.2209.11055},
233
+ url = {https://arxiv.org/abs/2209.11055},
234
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
235
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
236
+ title = {Efficient Few-Shot Learning Without Prompts},
237
+ publisher = {arXiv},
238
+ year = {2022},
239
+ copyright = {Creative Commons Attribution 4.0 International}
240
+ }
241
+ ```
242
+
243
+ <!--
244
+ ## Glossary
245
+
246
+ *Clearly define terms in order to be accessible across audiences.*
247
+ -->
248
+
249
+ <!--
250
+ ## Model Card Authors
251
+
252
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
253
+ -->
254
+
255
+ <!--
256
+ ## Model Card Contact
257
+
258
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
259
+ -->
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "XLMRobertaModel"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "classifier_dropout": null,
8
+ "eos_token_id": 2,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 384,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 1536,
14
+ "layer_norm_eps": 1e-12,
15
+ "max_position_embeddings": 514,
16
+ "model_type": "xlm-roberta",
17
+ "num_attention_heads": 12,
18
+ "num_hidden_layers": 6,
19
+ "pad_token_id": 1,
20
+ "position_embedding_type": "absolute",
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.51.3",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 250002
26
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "4.0.2",
4
+ "transformers": "4.51.3",
5
+ "pytorch": "2.6.0+cu124"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": "cosine"
10
+ }
config_setfit.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "normalize_embeddings": false,
3
+ "labels": [
4
+ "summarization",
5
+ "tool",
6
+ "general_knowledge",
7
+ "roleplay",
8
+ "complex_reasoning",
9
+ "creativity",
10
+ "coding",
11
+ "basic_reasoning"
12
+ ]
13
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:281a011d611debd6600bae6fee3b7e3087e1bb491a62cbb3401dcb39ac51fdc2
3
+ size 427988744
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b9f216693a908380e6acdd99416fb9d40e83a484a36ccd262021cd06bd50ada
3
+ size 26023
modules.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ {
15
+ "idx": 2,
16
+ "name": "2",
17
+ "path": "2_Normalize",
18
+ "type": "sentence_transformers.models.Normalize"
19
+ }
20
+ ]
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,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "<s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "mask_token": {
24
+ "content": "<mask>",
25
+ "lstrip": true,
26
+ "normalized": true,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "pad_token": {
31
+ "content": "<pad>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "sep_token": {
38
+ "content": "</s>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ },
44
+ "unk_token": {
45
+ "content": "<unk>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false
50
+ }
51
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a8d0b7573869188be52cca17a27a84f3cfbc0a5536c28ee1eca82903e8c68c6
3
+ size 17083051
tokenizer_config.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": true,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "<s>",
45
+ "clean_up_tokenization_spaces": false,
46
+ "cls_token": "<s>",
47
+ "eos_token": "</s>",
48
+ "extra_special_tokens": {},
49
+ "mask_token": "<mask>",
50
+ "model_max_length": 512,
51
+ "pad_token": "<pad>",
52
+ "sep_token": "</s>",
53
+ "sp_model_kwargs": {},
54
+ "tokenizer_class": "XLMRobertaTokenizer",
55
+ "unk_token": "<unk>"
56
+ }