pEpOo commited on
Commit
52a1560
1 Parent(s): 4ae7336

Add SetFit model

Browse files
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,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: setfit
3
+ tags:
4
+ - setfit
5
+ - sentence-transformers
6
+ - text-classification
7
+ - generated_from_setfit_trainer
8
+ base_model: kinit/slovakbert-sentiment-twitter
9
+ metrics:
10
+ - accuracy
11
+ widget:
12
+ - text: Pan Vilasek bol velmi mily, snaizl sa spestrit vyucbu zaujimavymi aktivitami.
13
+ a zaroven sa snazil nam vstiepit nieco z nemciny. skripta z ktorych sa ucime by
14
+ vsak mohli byt kusok zlozitejsie, slovna zasoba je vecsinou trivialna...
15
+ - text: Predmet na ktorom sa skvelo naucite zaklady html a css a celkovo webdizajnu,
16
+ dobre prednasky a cvicenia kde si to precvicite
17
+ - text: Super zostavena prednaska, veci pre mna zaujimave, lebo viem ze sa celkom
18
+ pouzivaju, vyborne vysvetlovane, tempo na mna tak akurat - vela sa stihlo (clovek
19
+ sa nenudil) ale na druhej strane sa aj dalo stihat ak si to clovek aspon raz za
20
+ cas pozrel. Co som pocul tak niektori si stazovali na narocnost vykladu, ale myslim
21
+ ze to je skor tym, ze ked sa na to niekto ani raz nepozrie nemoze cakat ze vsetko
22
+ hned na prve pocutie pochopi. este raz - super
23
+ - text: potešili by ma praktické ukážky namiesto viacnásobných odvodení podobných
24
+ vecí
25
+ - text: Veľmi zaujímavé, zrozumiteľne podané a niekedy aj vtipné:)
26
+ pipeline_tag: text-classification
27
+ inference: true
28
+ model-index:
29
+ - name: SetFit with kinit/slovakbert-sentiment-twitter
30
+ results:
31
+ - task:
32
+ type: text-classification
33
+ name: Text Classification
34
+ dataset:
35
+ name: Unknown
36
+ type: unknown
37
+ split: test
38
+ metrics:
39
+ - type: accuracy
40
+ value: 0.6830314585319351
41
+ name: Accuracy
42
+ ---
43
+
44
+ # SetFit with kinit/slovakbert-sentiment-twitter
45
+
46
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [kinit/slovakbert-sentiment-twitter](https://huggingface.co/kinit/slovakbert-sentiment-twitter) 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.
47
+
48
+ The model has been trained using an efficient few-shot learning technique that involves:
49
+
50
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
51
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
52
+
53
+ ## Model Details
54
+
55
+ ### Model Description
56
+ - **Model Type:** SetFit
57
+ - **Sentence Transformer body:** [kinit/slovakbert-sentiment-twitter](https://huggingface.co/kinit/slovakbert-sentiment-twitter)
58
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
59
+ - **Maximum Sequence Length:** 514 tokens
60
+ - **Number of Classes:** 3 classes
61
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
62
+ <!-- - **Language:** Unknown -->
63
+ <!-- - **License:** Unknown -->
64
+
65
+ ### Model Sources
66
+
67
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
68
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
69
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
70
+
71
+ ### Model Labels
72
+ | Label | Examples |
73
+ |:------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
74
+ | 0 | <ul><li>'Predmet bol fajn, zaujimavy, akurat bolo malo prilezitosti ziskat body za prezentacie.'</li><li>'Great.'</li><li>'Zaujímavý, konceptuálne náročný predmet. Objavuje sa tu všeličo z iných predmetov. Najskôr sa preberie záver a zvyšok semestra sa študenti k tomu dopracovávajú. Predmet nie je rozdelený na prednášky a cvičenia. Na hodinách však musia študenti veľa pracovať, často treba niečo odvodiť overiť alebo vypočitať príklad a tiež sa diskutuje. Tento spôsob učenia považujem za účinný - z prednášok som odchádzal s tým, že som sa niečo nové naučil a rozumiem tomu. K dispozícii sú skriptá, ktoré pomôžu vyjasniť prípadné nezrovnalosti a pri učení sa na skúšku.'</li></ul> |
75
+ | -1 | <ul><li>'Bolo by dobré, keby sa zadávali témy prác pred letnými prázdninami. Tento semester bol dosť náročný, takže sme nemali čas pracovať na bakalárkach.'</li><li>'Na začiatku semestra vynechať trochu s počtu hodín venovaným OS Linuxu a práci s jeho konzolou.'</li><li>'Zaujimavy predmet,dobre prednasany, kvalitne skripta, no chybaju mu cvicenia.'</li></ul> |
76
+ | 1 | <ul><li>'Predmet bol narocny, ale bez dobrovolnych cviceni z algebry by bol podla mna kazdy student este viac zmateny, nepochopil by uplne prebranu temu.'</li><li>'Pravidla na praktickych cviceniach sa stale menili. Najprv boli cvicenia povinne, zrazu boli dobrovolne, niekolkokrat sa menil system odovzdavania uloh, nakoniec ani ten povinny projekt nebol uz povinny, ked som ho zacal kodit. Prakticke cvicenia su strata casu, urcene pre ludi co "kodia" stylom opisem to z tabule. Clovek co vie programovat (co by 4taci mali vediet vsetci) to zvladne v pohode aj bez nich.'</li><li>'Prvy problem nastal takmer okamzite, ked sa na zaciatku menili pravidla. Po dovysvetlovani podmienok sa ustalili a (az na praktocke cvicenia) nemenili. Nastastie ak sa najde nieco, comu nepochopite na prednaske, na cviceniach vam to ochotne vysvetlia. Hlavnym problemom tohto predmetu je extremna casova narocnost vzhladom na pocet kreditov. Z pociatku boli pivinne 2*2h cvicenia tyzdenne + prednaska, pricom cvicenia museli byt so 100% ucastou. Tiez nepotesi ze okrem midtermu a final testu, ide student este na jednu pisomnu a ustnu cast....'</li></ul> |
77
+
78
+ ## Evaluation
79
+
80
+ ### Metrics
81
+ | Label | Accuracy |
82
+ |:--------|:---------|
83
+ | **all** | 0.6830 |
84
+
85
+ ## Uses
86
+
87
+ ### Direct Use for Inference
88
+
89
+ First install the SetFit library:
90
+
91
+ ```bash
92
+ pip install setfit
93
+ ```
94
+
95
+ Then you can load this model and run inference.
96
+
97
+ ```python
98
+ from setfit import SetFitModel
99
+
100
+ # Download from the 🤗 Hub
101
+ model = SetFitModel.from_pretrained("pEpOo/setfit-model-24-3")
102
+ # Run inference
103
+ preds = model("Veľmi zaujímavé, zrozumiteľne podané a niekedy aj vtipné:)")
104
+ ```
105
+
106
+ <!--
107
+ ### Downstream Use
108
+
109
+ *List how someone could finetune this model on their own dataset.*
110
+ -->
111
+
112
+ <!--
113
+ ### Out-of-Scope Use
114
+
115
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
116
+ -->
117
+
118
+ <!--
119
+ ## Bias, Risks and Limitations
120
+
121
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
122
+ -->
123
+
124
+ <!--
125
+ ### Recommendations
126
+
127
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
128
+ -->
129
+
130
+ ## Training Details
131
+
132
+ ### Training Set Metrics
133
+ | Training set | Min | Median | Max |
134
+ |:-------------|:----|:--------|:----|
135
+ | Word count | 1 | 41.9167 | 128 |
136
+
137
+ | Label | Training Sample Count |
138
+ |:------|:----------------------|
139
+ | -1 | 8 |
140
+ | 0 | 8 |
141
+ | 1 | 0 |
142
+
143
+ ### Training Hyperparameters
144
+ - batch_size: (16, 16)
145
+ - num_epochs: (10, 10)
146
+ - max_steps: -1
147
+ - sampling_strategy: oversampling
148
+ - num_iterations: 10
149
+ - body_learning_rate: (2e-05, 2e-05)
150
+ - head_learning_rate: 2e-05
151
+ - loss: CosineSimilarityLoss
152
+ - distance_metric: cosine_distance
153
+ - margin: 0.25
154
+ - end_to_end: False
155
+ - use_amp: False
156
+ - warmup_proportion: 0.1
157
+ - seed: 42
158
+ - eval_max_steps: -1
159
+ - load_best_model_at_end: False
160
+
161
+ ### Training Results
162
+ | Epoch | Step | Training Loss | Validation Loss |
163
+ |:------:|:----:|:-------------:|:---------------:|
164
+ | 0.0333 | 1 | 0.3101 | - |
165
+ | 1.6667 | 50 | 0.0032 | - |
166
+ | 3.3333 | 100 | 0.0012 | - |
167
+ | 5.0 | 150 | 0.0004 | - |
168
+ | 6.6667 | 200 | 0.0002 | - |
169
+ | 8.3333 | 250 | 0.0003 | - |
170
+ | 10.0 | 300 | 0.0002 | - |
171
+
172
+ ### Framework Versions
173
+ - Python: 3.11.0
174
+ - SetFit: 1.0.3
175
+ - Sentence Transformers: 2.5.1
176
+ - Transformers: 4.38.2
177
+ - PyTorch: 2.2.1+cu121
178
+ - Datasets: 2.18.0
179
+ - Tokenizers: 0.15.2
180
+
181
+ ## Citation
182
+
183
+ ### BibTeX
184
+ ```bibtex
185
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
186
+ doi = {10.48550/ARXIV.2209.11055},
187
+ url = {https://arxiv.org/abs/2209.11055},
188
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
189
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
190
+ title = {Efficient Few-Shot Learning Without Prompts},
191
+ publisher = {arXiv},
192
+ year = {2022},
193
+ copyright = {Creative Commons Attribution 4.0 International}
194
+ }
195
+ ```
196
+
197
+ <!--
198
+ ## Glossary
199
+
200
+ *Clearly define terms in order to be accessible across audiences.*
201
+ -->
202
+
203
+ <!--
204
+ ## Model Card Authors
205
+
206
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
207
+ -->
208
+
209
+ <!--
210
+ ## Model Card Contact
211
+
212
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
213
+ -->
config.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "models/sentiment/50264_checkpoint_58_125000/",
3
+ "architectures": [
4
+ "RobertaForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": null,
9
+ "eos_token_id": 2,
10
+ "gradient_checkpointing": false,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout_prob": 0.1,
13
+ "hidden_size": 768,
14
+ "id2label": {
15
+ "0": "-1",
16
+ "1": "0",
17
+ "2": "1"
18
+ },
19
+ "initializer_range": 0.02,
20
+ "intermediate_size": 3072,
21
+ "label2id": {
22
+ "-1": 0,
23
+ "0": 1,
24
+ "1": 2
25
+ },
26
+ "layer_norm_eps": 1e-05,
27
+ "max_position_embeddings": 514,
28
+ "model_type": "roberta",
29
+ "num_attention_heads": 12,
30
+ "num_hidden_layers": 12,
31
+ "pad_token_id": 1,
32
+ "position_embedding_type": "absolute",
33
+ "torch_dtype": "float32",
34
+ "transformers_version": "4.12.2",
35
+ "type_vocab_size": 1,
36
+ "use_cache": true,
37
+ "vocab_size": 50264
38
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.5.1",
4
+ "transformers": "4.38.2",
5
+ "pytorch": "2.2.1+cu121"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null
9
+ }
config_setfit.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "labels": [
3
+ -1,
4
+ 0,
5
+ 1
6
+ ],
7
+ "normalize_embeddings": false
8
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b2af41dca4d11742eefe9566b3ee04186af258894597c4676c802d44059e95c4
3
+ size 498601832
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:127226f48c163b116f733772ec2c3f21cdcdf466705290af539b0dff9060f5f8
3
+ size 19269
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": 514,
3
+ "do_lower_case": false
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "<s>",
11
+ "lstrip": false,
12
+ "normalized": true,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": true,
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": true,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "sep_token": {
38
+ "content": "</s>",
39
+ "lstrip": false,
40
+ "normalized": true,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ },
44
+ "unk_token": {
45
+ "content": "<unk>",
46
+ "lstrip": false,
47
+ "normalized": true,
48
+ "rstrip": false,
49
+ "single_word": false
50
+ }
51
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<s>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<pad>",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": true,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": true,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "50263": {
37
+ "content": "<mask>",
38
+ "lstrip": true,
39
+ "normalized": true,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ }
44
+ },
45
+ "bos_token": "<s>",
46
+ "clean_up_tokenization_spaces": true,
47
+ "cls_token": "<s>",
48
+ "eos_token": "</s>",
49
+ "errors": "replace",
50
+ "mask_token": "<mask>",
51
+ "model_max_length": 1000000000000000019884624838656,
52
+ "pad_token": "<pad>",
53
+ "sep_token": "</s>",
54
+ "tokenizer_class": "RobertaTokenizer",
55
+ "trim_offsets": true,
56
+ "unk_token": "<unk>"
57
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff