livinNector commited on
Commit
00a830f
·
verified ·
1 Parent(s): e3e1ee2

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": 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,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - setfit
4
+ - sentence-transformers
5
+ - text-classification
6
+ - generated_from_setfit_trainer
7
+ widget:
8
+ - text: '"ഒരുപാട് ഇഷ്ട്ടപെട്ട പോലെ ഒരുപാട് വെറുത്ത് പോയി, ഡോക്ടറെ കിട്ടാനുള്ള ഭാഗ്യം
9
+ ഇല്ല"'
10
+ - text: ഒരു കരുണയും ഇല്ലാതെ ഒരാളുടെ ഫീലിംഗ് വെച്ച് കളിക്കുക... ആത്മാർഥതക്ക് ഒരു വിലയും
11
+ കൊടുക്കാതെ അയാളെ തൂത്തെറിയുക.... എല്ലാവർക്കും എല്ലാം മനസ്സിൽ ആയി.. ഇനി കൂടുതൽ
12
+ ഒന്നും പറയണ്ട...
13
+ - text: சொத்துக்கே வழி இல்லாம இங்க கஸ்டப்பற்றாங்க இதுங்களுக்கு அறிப்பு பிடிச்சி அலைதுங்க
14
+ தூ தூ மூதேவிங்களா
15
+ - text: അടിപൊളി കൊള്ളാം സൂപ്പർ ഡയലോഗ് ആരാണ് ഈ അമ്മമാരും ചേച്ചിമാരും ചേട്ടന്മാരും ഞങ്ങൾക്കറിയില്ല
16
+ - text: 24×7 എല്ലാം കാണണം കേട്ടോ. അപ്പോൾ അറിയാം. അവിടെ എന്തൊക്കെയാ കാട്ടികൂട്ടിയതെന്ന്.
17
+ എങ്കിലുംഡോക്റ്റരോട് നീ ഇത് ചെയ്യും എന്ന് ഞങ്ങൾ ആരും കരുതിയില്ല.
18
+ metrics:
19
+ - accuracy
20
+ pipeline_tag: text-classification
21
+ library_name: setfit
22
+ inference: true
23
+ base_model: microsoft/Multilingual-MiniLM-L12-H384
24
+ model-index:
25
+ - name: SetFit with microsoft/Multilingual-MiniLM-L12-H384
26
+ results:
27
+ - task:
28
+ type: text-classification
29
+ name: Text Classification
30
+ dataset:
31
+ name: Unknown
32
+ type: unknown
33
+ split: test
34
+ metrics:
35
+ - type: accuracy
36
+ value: 0.6875
37
+ name: Accuracy
38
+ ---
39
+
40
+ # SetFit with microsoft/Multilingual-MiniLM-L12-H384
41
+
42
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [microsoft/Multilingual-MiniLM-L12-H384](https://huggingface.co/microsoft/Multilingual-MiniLM-L12-H384) as the Sentence Transformer embedding model. A [SetFitHead](huggingface.co/docs/setfit/reference/main#setfit.SetFitHead) instance is used for classification.
43
+
44
+ The model has been trained using an efficient few-shot learning technique that involves:
45
+
46
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
47
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
48
+
49
+ ## Model Details
50
+
51
+ ### Model Description
52
+ - **Model Type:** SetFit
53
+ - **Sentence Transformer body:** [microsoft/Multilingual-MiniLM-L12-H384](https://huggingface.co/microsoft/Multilingual-MiniLM-L12-H384)
54
+ - **Classification head:** a [SetFitHead](huggingface.co/docs/setfit/reference/main#setfit.SetFitHead) instance
55
+ - **Maximum Sequence Length:** 512 tokens
56
+ - **Number of Classes:** 2 classes
57
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
58
+ <!-- - **Language:** Unknown -->
59
+ <!-- - **License:** Unknown -->
60
+
61
+ ### Model Sources
62
+
63
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
64
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
65
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
66
+
67
+ ### Model Labels
68
+ | Label | Examples |
69
+ |:------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
70
+ | 0 | <ul><li>'Madam divyaக்கு 1கிலோ colgate paste வாங்கி கொடுங்க videoவில் வாய் நாற்றம் தாங்கல'</li><li>'ഇനി ഇതുപോലുള്ള സാദനം ആയി വന്നാൽ ഞാൻ ഡിസ്ക്രൈബ് ചെയ്യും'</li><li>'ஏன்பா behindwoods தயவு செய்து இப்படி கேவலமான programme ஐ telecast பண்ணாதீங்க ராஜா'</li></ul> |
71
+ | 1 | <ul><li>'கம்பிய பழுக்க வச்சு சூத்துல வைங்க சார்'</li><li>'ഇനി റെഡ് സ്ട്ര���റ്റ്റിലും കൂടി പോയി ഇന്റർവ്യൂ എടുക്ക് ചേച്ചി'</li><li>'നിങ്ങൾ പണ്ടേ വിവരക്കേടാണ്. ബോധം ഇല്ലായ്മ കാണിക്കാതെ സ്ത്രീ. മറ്റുള്ളവരുടെ കിഡ്ണി കളയിപ്പിച്ചിട്ടുവേണോ നിന്റെ കഞ്ഞി കുടിക്കൽ.'</li></ul> |
72
+
73
+ ## Evaluation
74
+
75
+ ### Metrics
76
+ | Label | Accuracy |
77
+ |:--------|:---------|
78
+ | **all** | 0.6875 |
79
+
80
+ ## Uses
81
+
82
+ ### Direct Use for Inference
83
+
84
+ First install the SetFit library:
85
+
86
+ ```bash
87
+ pip install setfit
88
+ ```
89
+
90
+ Then you can load this model and run inference.
91
+
92
+ ```python
93
+ from setfit import SetFitModel
94
+
95
+ # Download from the 🤗 Hub
96
+ model = SetFitModel.from_pretrained("livinNector/m-minilm-l12-h384-dra-tam-mal-aw-setfit-finetune")
97
+ # Run inference
98
+ preds = model("\"ഒരുപാട് ഇഷ്ട്ടപെട്ട പോലെ ഒരുപാട് വെറുത്ത് പോയി, ഡോക്ടറെ കിട്ടാനുള്ള ഭാഗ്യം ഇല്ല\"")
99
+ ```
100
+
101
+ <!--
102
+ ### Downstream Use
103
+
104
+ *List how someone could finetune this model on their own dataset.*
105
+ -->
106
+
107
+ <!--
108
+ ### Out-of-Scope Use
109
+
110
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
111
+ -->
112
+
113
+ <!--
114
+ ## Bias, Risks and Limitations
115
+
116
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
117
+ -->
118
+
119
+ <!--
120
+ ### Recommendations
121
+
122
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
123
+ -->
124
+
125
+ ## Training Details
126
+
127
+ ### Training Set Metrics
128
+ | Training set | Min | Median | Max |
129
+ |:-------------|:----|:--------|:----|
130
+ | Word count | 2 | 15.4375 | 123 |
131
+
132
+ | Label | Training Sample Count |
133
+ |:------|:----------------------|
134
+ | 0 | 132 |
135
+ | 1 | 124 |
136
+
137
+ ### Training Hyperparameters
138
+ - batch_size: (64, 64)
139
+ - num_epochs: (10, 10)
140
+ - max_steps: -1
141
+ - sampling_strategy: oversampling
142
+ - num_iterations: 2
143
+ - body_learning_rate: (2e-05, 1e-05)
144
+ - head_learning_rate: 0.01
145
+ - loss: CosineSimilarityLoss
146
+ - distance_metric: cosine_distance
147
+ - margin: 0.25
148
+ - end_to_end: True
149
+ - use_amp: False
150
+ - warmup_proportion: 0.1
151
+ - l2_weight: 0.01
152
+ - seed: 42
153
+ - eval_max_steps: -1
154
+ - load_best_model_at_end: True
155
+
156
+ ### Training Results
157
+ | Epoch | Step | Training Loss | Validation Loss |
158
+ |:------:|:----:|:-------------:|:---------------:|
159
+ | 0.0625 | 1 | 0.422 | - |
160
+ | 0.625 | 10 | - | 0.4029 |
161
+ | 1.25 | 20 | - | 0.2799 |
162
+ | 1.875 | 30 | - | 0.2464 |
163
+ | 2.5 | 40 | - | 0.2480 |
164
+ | 3.125 | 50 | 0.2964 | 0.2451 |
165
+ | 3.75 | 60 | - | 0.2368 |
166
+ | 4.375 | 70 | - | 0.2444 |
167
+ | 5.0 | 80 | - | 0.2393 |
168
+ | 5.625 | 90 | - | 0.2382 |
169
+ | 6.25 | 100 | 0.1825 | 0.2395 |
170
+ | 6.875 | 110 | - | 0.2405 |
171
+ | 7.5 | 120 | - | 0.2424 |
172
+ | 8.125 | 130 | - | 0.2468 |
173
+ | 8.75 | 140 | - | 0.2432 |
174
+ | 9.375 | 150 | 0.1308 | 0.2451 |
175
+ | 10.0 | 160 | - | 0.2454 |
176
+
177
+ ### Framework Versions
178
+ - Python: 3.10.12
179
+ - SetFit: 1.1.0
180
+ - Sentence Transformers: 3.3.1
181
+ - Transformers: 4.45.2
182
+ - PyTorch: 2.5.1+cu121
183
+ - Datasets: 3.2.0
184
+ - Tokenizers: 0.20.3
185
+
186
+ ## Citation
187
+
188
+ ### BibTeX
189
+ ```bibtex
190
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
191
+ doi = {10.48550/ARXIV.2209.11055},
192
+ url = {https://arxiv.org/abs/2209.11055},
193
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
194
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
195
+ title = {Efficient Few-Shot Learning Without Prompts},
196
+ publisher = {arXiv},
197
+ year = {2022},
198
+ copyright = {Creative Commons Attribution 4.0 International}
199
+ }
200
+ ```
201
+
202
+ <!--
203
+ ## Glossary
204
+
205
+ *Clearly define terms in order to be accessible across audiences.*
206
+ -->
207
+
208
+ <!--
209
+ ## Model Card Authors
210
+
211
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
212
+ -->
213
+
214
+ <!--
215
+ ## Model Card Contact
216
+
217
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
218
+ -->
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "microsoft/Multilingual-MiniLM-L12-H384",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 384,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 1536,
13
+ "layer_norm_eps": 1e-12,
14
+ "max_position_embeddings": 512,
15
+ "model_type": "bert",
16
+ "num_attention_heads": 12,
17
+ "num_hidden_layers": 12,
18
+ "pad_token_id": 0,
19
+ "position_embedding_type": "absolute",
20
+ "tokenizer_class": "XLMRobertaTokenizer",
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.45.2",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 250037
26
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.3.1",
4
+ "transformers": "4.45.2",
5
+ "pytorch": "2.5.1+cu121"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": "cosine"
10
+ }
config_setfit.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "normalize_embeddings": false,
3
+ "labels": null
4
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:91762b865c7f52f646a5b848830536b23a21171744ba51d7672f96cfe4a52f61
3
+ size 470637416
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d4f578eb45134f3f194da8a13b457cf6aee52162127a3c83a0b13a2ba2be91e3
3
+ size 4614
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:3ea2d57e1ab5ebb5789b8e8e6f9593a996e8b624f870e6f55f63abe5359ff32c
3
+ size 17098504
tokenizer_config.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": false,
46
+ "cls_token": "<s>",
47
+ "eos_token": "</s>",
48
+ "mask_token": "<mask>",
49
+ "model_max_length": 1000000000000000019884624838656,
50
+ "pad_token": "<pad>",
51
+ "sep_token": "</s>",
52
+ "sp_model_kwargs": {},
53
+ "tokenizer_class": "XLMRobertaTokenizer",
54
+ "unk_token": "<unk>"
55
+ }