akhooli commited on
Commit
71187fb
·
verified ·
1 Parent(s): 8f59f10

Push model using huggingface_hub.

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 CHANGED
@@ -1,3 +1,278 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: akhooli/sbert_ar_nli_500k_ubc_norm
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: ليه فاجعة؟ بس لإنو بجيب سيرة جبران باسيل؟ عم يدق بالزعيم؟
14
+ - text: ديري بالك و خليكي صامدة و قومي افتحي التلفظيون و تابعي انتصارات جيشنا الباسل
15
+ بسرعة بسرعة
16
+ - text: يا باريس انت حمار ولا بتستحمر
17
+ - text: حطموا أحلام جبران باسيل بالمساهمة بإعادة الإعمار
18
+ - text: وكمان هالمرة أهل الغوطة ضربوا حالهن كيماوي؟
19
+ inference: true
20
+ model-index:
21
+ - name: SetFit with akhooli/sbert_ar_nli_500k_ubc_norm
22
+ results:
23
+ - task:
24
+ type: text-classification
25
+ name: Text Classification
26
+ dataset:
27
+ name: Unknown
28
+ type: unknown
29
+ split: test
30
+ metrics:
31
+ - type: accuracy
32
+ value: 0.8215962441314554
33
+ name: Accuracy
34
+ ---
35
+
36
+ # SetFit with akhooli/sbert_ar_nli_500k_ubc_norm
37
+
38
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [akhooli/sbert_ar_nli_500k_ubc_norm](https://huggingface.co/akhooli/sbert_ar_nli_500k_ubc_norm) 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.
39
+
40
+ The model has been trained using an efficient few-shot learning technique that involves:
41
+
42
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
43
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
44
+
45
+ ## Model Details
46
+
47
+ ### Model Description
48
+ - **Model Type:** SetFit
49
+ - **Sentence Transformer body:** [akhooli/sbert_ar_nli_500k_ubc_norm](https://huggingface.co/akhooli/sbert_ar_nli_500k_ubc_norm)
50
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
51
+ - **Maximum Sequence Length:** 512 tokens
52
+ - **Number of Classes:** 2 classes
53
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
54
+ <!-- - **Language:** Unknown -->
55
+ <!-- - **License:** Unknown -->
56
+
57
+ ### Model Sources
58
+
59
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
60
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
61
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
62
+
63
+ ### Model Labels
64
+ | Label | Examples |
65
+ |:---------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
66
+ | negative | <ul><li>'نشرتكم مقابلة لوزير الخارجية اللبناني جبران باسيل مع سي أن أن تثير الجدل على منصات التواصل ما السبب؟'</li><li>'أود أن أسأل سماحتكم، كيف تحدد نوعية العلاقة أو ما هو تشخيصكم للعلاقة القائمة بينكم وبين الحليف ووزير الخارجية ورئيس...'</li><li>'انت عندك الصيغة الأولية شي'</li></ul> |
67
+ | positive | <ul><li>'بتحط صورة بتقول السوري يضب غراضه ويرحل وبعدين بتقول ما في ضرورة لتغذية الحقد إنتي حمارة ولا عم تستحمري'</li><li>'مش جايي لعندك و على دولة الخلّفك و فيك تفل إذا مش عاجبك'</li><li>'العرب كلهم بدهم حرق وبس'</li></ul> |
68
+
69
+ ## Evaluation
70
+
71
+ ### Metrics
72
+ | Label | Accuracy |
73
+ |:--------|:---------|
74
+ | **all** | 0.8216 |
75
+
76
+ ## Uses
77
+
78
+ ### Direct Use for Inference
79
+
80
+ First install the SetFit library:
81
+
82
+ ```bash
83
+ pip install setfit
84
+ ```
85
+
86
+ Then you can load this model and run inference.
87
+
88
+ ```python
89
+ from setfit import SetFitModel
90
+
91
+ # Download from the 🤗 Hub
92
+ model = SetFitModel.from_pretrained("akhooli/setfit_ar_ubc_hs")
93
+ # Run inference
94
+ preds = model("يا باريس انت حمار ولا بتستحمر")
95
+ ```
96
+
97
+ <!--
98
+ ### Downstream Use
99
+
100
+ *List how someone could finetune this model on their own dataset.*
101
+ -->
102
+
103
+ <!--
104
+ ### Out-of-Scope Use
105
+
106
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
107
+ -->
108
+
109
+ <!--
110
+ ## Bias, Risks and Limitations
111
+
112
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
113
+ -->
114
+
115
+ <!--
116
+ ### Recommendations
117
+
118
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
119
+ -->
120
+
121
+ ## Training Details
122
+
123
+ ### Training Set Metrics
124
+ | Training set | Min | Median | Max |
125
+ |:-------------|:----|:--------|:----|
126
+ | Word count | 1 | 12.1725 | 52 |
127
+
128
+ | Label | Training Sample Count |
129
+ |:---------|:----------------------|
130
+ | negative | 1978 |
131
+ | positive | 2800 |
132
+
133
+ ### Training Hyperparameters
134
+ - batch_size: (32, 32)
135
+ - num_epochs: (1, 1)
136
+ - max_steps: 8000
137
+ - sampling_strategy: undersampling
138
+ - body_learning_rate: (2e-05, 1e-05)
139
+ - head_learning_rate: 0.01
140
+ - loss: CosineSimilarityLoss
141
+ - distance_metric: cosine_distance
142
+ - margin: 0.25
143
+ - end_to_end: False
144
+ - use_amp: False
145
+ - warmup_proportion: 0.1
146
+ - l2_weight: 0.01
147
+ - seed: 42
148
+ - run_name: setfit_hate_25kv8
149
+ - eval_max_steps: -1
150
+ - load_best_model_at_end: False
151
+
152
+ ### Training Results
153
+ | Epoch | Step | Training Loss | Validation Loss |
154
+ |:------:|:----:|:-------------:|:---------------:|
155
+ | 0.0003 | 1 | 0.283 | - |
156
+ | 0.025 | 100 | 0.2635 | - |
157
+ | 0.05 | 200 | 0.218 | - |
158
+ | 0.075 | 300 | 0.1592 | - |
159
+ | 0.1 | 400 | 0.1118 | - |
160
+ | 0.125 | 500 | 0.0777 | - |
161
+ | 0.15 | 600 | 0.0567 | - |
162
+ | 0.175 | 700 | 0.0394 | - |
163
+ | 0.2 | 800 | 0.03 | - |
164
+ | 0.225 | 900 | 0.0212 | - |
165
+ | 0.25 | 1000 | 0.0205 | - |
166
+ | 0.275 | 1100 | 0.0172 | - |
167
+ | 0.3 | 1200 | 0.0142 | - |
168
+ | 0.325 | 1300 | 0.0098 | - |
169
+ | 0.35 | 1400 | 0.0097 | - |
170
+ | 0.375 | 1500 | 0.0064 | - |
171
+ | 0.4 | 1600 | 0.0044 | - |
172
+ | 0.425 | 1700 | 0.005 | - |
173
+ | 0.45 | 1800 | 0.0034 | - |
174
+ | 0.475 | 1900 | 0.0028 | - |
175
+ | 0.5 | 2000 | 0.0034 | - |
176
+ | 0.525 | 2100 | 0.0052 | - |
177
+ | 0.55 | 2200 | 0.0041 | - |
178
+ | 0.575 | 2300 | 0.0028 | - |
179
+ | 0.6 | 2400 | 0.002 | - |
180
+ | 0.625 | 2500 | 0.0015 | - |
181
+ | 0.65 | 2600 | 0.0021 | - |
182
+ | 0.675 | 2700 | 0.0032 | - |
183
+ | 0.7 | 2800 | 0.0028 | - |
184
+ | 0.725 | 2900 | 0.0017 | - |
185
+ | 0.75 | 3000 | 0.0029 | - |
186
+ | 0.775 | 3100 | 0.0018 | - |
187
+ | 0.8 | 3200 | 0.0028 | - |
188
+ | 0.825 | 3300 | 0.0014 | - |
189
+ | 0.85 | 3400 | 0.002 | - |
190
+ | 0.875 | 3500 | 0.001 | - |
191
+ | 0.9 | 3600 | 0.0012 | - |
192
+ | 0.925 | 3700 | 0.0007 | - |
193
+ | 0.95 | 3800 | 0.0013 | - |
194
+ | 0.975 | 3900 | 0.0011 | - |
195
+ | 1.0 | 4000 | 0.0012 | - |
196
+ | 1.025 | 4100 | 0.0013 | - |
197
+ | 1.05 | 4200 | 0.0017 | - |
198
+ | 1.075 | 4300 | 0.0013 | - |
199
+ | 1.1 | 4400 | 0.0013 | - |
200
+ | 1.125 | 4500 | 0.0008 | - |
201
+ | 1.15 | 4600 | 0.0007 | - |
202
+ | 1.175 | 4700 | 0.0008 | - |
203
+ | 1.2 | 4800 | 0.0015 | - |
204
+ | 1.225 | 4900 | 0.0017 | - |
205
+ | 1.25 | 5000 | 0.0012 | - |
206
+ | 1.275 | 5100 | 0.0008 | - |
207
+ | 1.3 | 5200 | 0.001 | - |
208
+ | 1.325 | 5300 | 0.0009 | - |
209
+ | 1.35 | 5400 | 0.0008 | - |
210
+ | 1.375 | 5500 | 0.0004 | - |
211
+ | 1.4 | 5600 | 0.0014 | - |
212
+ | 1.425 | 5700 | 0.001 | - |
213
+ | 1.45 | 5800 | 0.0013 | - |
214
+ | 1.475 | 5900 | 0.0009 | - |
215
+ | 1.5 | 6000 | 0.0 | - |
216
+ | 1.525 | 6100 | 0.0008 | - |
217
+ | 1.55 | 6200 | 0.0003 | - |
218
+ | 1.575 | 6300 | 0.0009 | - |
219
+ | 1.6 | 6400 | 0.0007 | - |
220
+ | 1.625 | 6500 | 0.0002 | - |
221
+ | 1.65 | 6600 | 0.0008 | - |
222
+ | 1.675 | 6700 | 0.0005 | - |
223
+ | 1.7 | 6800 | 0.0005 | - |
224
+ | 1.725 | 6900 | 0.0005 | - |
225
+ | 1.75 | 7000 | 0.0004 | - |
226
+ | 1.775 | 7100 | 0.001 | - |
227
+ | 1.8 | 7200 | 0.0006 | - |
228
+ | 1.825 | 7300 | 0.0003 | - |
229
+ | 1.85 | 7400 | 0.0004 | - |
230
+ | 1.875 | 7500 | 0.0002 | - |
231
+ | 1.9 | 7600 | 0.0002 | - |
232
+ | 1.925 | 7700 | 0.0001 | - |
233
+ | 1.95 | 7800 | 0.0002 | - |
234
+ | 1.975 | 7900 | 0.0002 | - |
235
+ | 2.0 | 8000 | 0.0002 | - |
236
+
237
+ ### Framework Versions
238
+ - Python: 3.10.14
239
+ - SetFit: 1.2.0.dev0
240
+ - Sentence Transformers: 3.2.1
241
+ - Transformers: 4.45.1
242
+ - PyTorch: 2.4.0
243
+ - Datasets: 3.0.1
244
+ - Tokenizers: 0.20.0
245
+
246
+ ## Citation
247
+
248
+ ### BibTeX
249
+ ```bibtex
250
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
251
+ doi = {10.48550/ARXIV.2209.11055},
252
+ url = {https://arxiv.org/abs/2209.11055},
253
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
254
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
255
+ title = {Efficient Few-Shot Learning Without Prompts},
256
+ publisher = {arXiv},
257
+ year = {2022},
258
+ copyright = {Creative Commons Attribution 4.0 International}
259
+ }
260
+ ```
261
+
262
+ <!--
263
+ ## Glossary
264
+
265
+ *Clearly define terms in order to be accessible across audiences.*
266
+ -->
267
+
268
+ <!--
269
+ ## Model Card Authors
270
+
271
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
272
+ -->
273
+
274
+ <!--
275
+ ## Model Card Contact
276
+
277
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
278
+ -->
config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "akhooli/sbert_ar_nli_500k_ubc_norm",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "directionality": "bidi",
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 768,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 3072,
14
+ "layer_norm_eps": 1e-12,
15
+ "max_position_embeddings": 512,
16
+ "model_type": "bert",
17
+ "num_attention_heads": 12,
18
+ "num_hidden_layers": 12,
19
+ "pad_token_id": 0,
20
+ "pooler_fc_size": 768,
21
+ "pooler_num_attention_heads": 12,
22
+ "pooler_num_fc_layers": 3,
23
+ "pooler_size_per_head": 128,
24
+ "pooler_type": "first_token_transform",
25
+ "position_embedding_type": "absolute",
26
+ "torch_dtype": "float32",
27
+ "transformers_version": "4.45.1",
28
+ "type_vocab_size": 2,
29
+ "use_cache": true,
30
+ "vocab_size": 100000
31
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.2.1",
4
+ "transformers": "4.45.1",
5
+ "pytorch": "2.4.0"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": null
10
+ }
config_setfit.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "labels": [
3
+ "negative",
4
+ "positive"
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:e42375eed335329c139303f78478df8964c0af125d04a7eee1d5ee7968090c65
3
+ size 651387752
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab5c7f6844a83c48bbcff806d678d4d999d754df34798630ac86cc0080fba6b7
3
+ size 7007
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
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "mask_token": {
10
+ "content": "[MASK]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "[PAD]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "sep_token": {
24
+ "content": "[SEP]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "unk_token": {
31
+ "content": "[UNK]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ }
37
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "4": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "mask_token": "[MASK]",
49
+ "max_length": 512,
50
+ "model_max_length": 512,
51
+ "never_split": null,
52
+ "pad_to_multiple_of": null,
53
+ "pad_token": "[PAD]",
54
+ "pad_token_type_id": 0,
55
+ "padding_side": "right",
56
+ "sep_token": "[SEP]",
57
+ "stride": 0,
58
+ "strip_accents": null,
59
+ "tokenize_chinese_chars": true,
60
+ "tokenizer_class": "BertTokenizer",
61
+ "truncation_side": "right",
62
+ "truncation_strategy": "longest_first",
63
+ "unk_token": "[UNK]"
64
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff