akhooli commited on
Commit
70a89be
·
verified ·
1 Parent(s): 54dff2f

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 ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - setfit
4
+ - sentence-transformers
5
+ - text-classification
6
+ - generated_from_setfit_trainer
7
+ widget:
8
+ - text: يا حاقد ع الاسلام السياسي
9
+ - text: 'بلد مخيف، صار القتل بحجه الشرف متل قتل بعوضة، واللي بيخوف اكتر من اللي واقف
10
+ مكتف ايديه ومش مساعد. وين كنآ، ووين وصلنآ، لمتى حنضل عايشين وساكتين!
11
+
12
+ '
13
+ - text: "من خلال المتابعة ..يتضح أن أكثر اللاعبين الذين يتم تسويقهم هم لاعبي امريكا\
14
+ \ الجنوبية وأقلهم الافارقة. \nمن خلال الواقع ..أكثر اللاعبين تهاونا ولعب على\
15
+ \ الواقف في آخر ٦ شهور من عقودهم هم لاعبي امريكا الجنوبية ."
16
+ - text: ' علم الحزب يا فهمانه ما حطوا لانه عم يحكي وطنيا ومشان ماحدا متلك يعترض. اذا
17
+ حطوا بتعترضي واذا ما حطوا كمان بتعترضي.'
18
+ - text: "شيوعي \nعلماني \nمسيحي\nانصار سنه \nصوفي \nيمثلك التجمع \nلا يمثلك التجمع\
19
+ \ \nاهلا بكم جميعا فنحن نريد بناء وطن ❤"
20
+ metrics:
21
+ - accuracy
22
+ pipeline_tag: text-classification
23
+ library_name: setfit
24
+ inference: true
25
+ base_model: akhooli/sbert-nli-500k-triplets-MB
26
+ model-index:
27
+ - name: SetFit with akhooli/sbert-nli-500k-triplets-MB
28
+ results:
29
+ - task:
30
+ type: text-classification
31
+ name: Text Classification
32
+ dataset:
33
+ name: Unknown
34
+ type: unknown
35
+ split: test
36
+ metrics:
37
+ - type: accuracy
38
+ value: 0.7956709956709956
39
+ name: Accuracy
40
+ ---
41
+
42
+ # SetFit with akhooli/sbert-nli-500k-triplets-MB
43
+
44
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [akhooli/sbert-nli-500k-triplets-MB](https://huggingface.co/akhooli/sbert-nli-500k-triplets-MB) 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.
45
+
46
+ The model has been trained using an efficient few-shot learning technique that involves:
47
+
48
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
49
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
50
+
51
+ ## Model Details
52
+
53
+ ### Model Description
54
+ - **Model Type:** SetFit
55
+ - **Sentence Transformer body:** [akhooli/sbert-nli-500k-triplets-MB](https://huggingface.co/akhooli/sbert-nli-500k-triplets-MB)
56
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
57
+ - **Maximum Sequence Length:** 8192 tokens
58
+ - **Number of Classes:** 2 classes
59
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
60
+ <!-- - **Language:** Unknown -->
61
+ <!-- - **License:** Unknown -->
62
+
63
+ ### Model Sources
64
+
65
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
66
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
67
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
68
+
69
+ ### Model Labels
70
+ | Label | Examples |
71
+ |:---------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
72
+ | positive | <ul><li>' سبحان الله الفلسطينيين شعب خاين في كل مكان \nلاحول ولا قوة إلا بالله'</li><li>'يا بيك عّم تخبرنا عن شي ما فينا تعملو نحن ماًعندنا نواب ولا وزراء بمثلونا بالدولة الا اذا زهقان وعبالك ليك'</li><li>'جوز كذابين منافقين…'</li></ul> |
73
+ | negative | <ul><li>'ربي لا تجعلني أسيء الظن بأحد ولا تجعل في قلبي شيئا على أحد ، اللهم أسألك قلباً نقياً صافيا'</li><li>'هشام حداد عامل فيها جون ستيوارت'</li><li>' بحياة اختك من وين بتجيبي اخبارك؟؟ من صغري وانا عبالي كون… LINK'</li></ul> |
74
+
75
+ ## Evaluation
76
+
77
+ ### Metrics
78
+ | Label | Accuracy |
79
+ |:--------|:---------|
80
+ | **all** | 0.7957 |
81
+
82
+ ## Uses
83
+
84
+ ### Direct Use for Inference
85
+
86
+ First install the SetFit library:
87
+
88
+ ```bash
89
+ pip install setfit
90
+ ```
91
+
92
+ Then you can load this model and run inference.
93
+
94
+ ```python
95
+ from setfit import SetFitModel
96
+
97
+ # Download from the 🤗 Hub
98
+ model = SetFitModel.from_pretrained("akhooli/setfit_ar_hs_mb")
99
+ # Run inference
100
+ preds = model("يا حاقد ع الاسلام السياسي")
101
+ ```
102
+
103
+ <!--
104
+ ### Downstream Use
105
+
106
+ *List how someone could finetune this model on their own dataset.*
107
+ -->
108
+
109
+ <!--
110
+ ### Out-of-Scope Use
111
+
112
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
113
+ -->
114
+
115
+ <!--
116
+ ## Bias, Risks and Limitations
117
+
118
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
119
+ -->
120
+
121
+ <!--
122
+ ### Recommendations
123
+
124
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
125
+ -->
126
+
127
+ ## Training Details
128
+
129
+ ### Training Set Metrics
130
+ | Training set | Min | Median | Max |
131
+ |:-------------|:----|:--------|:----|
132
+ | Word count | 1 | 18.8388 | 185 |
133
+
134
+ | Label | Training Sample Count |
135
+ |:---------|:----------------------|
136
+ | negative | 5200 |
137
+ | positive | 4943 |
138
+
139
+ ### Training Hyperparameters
140
+ - batch_size: (16, 16)
141
+ - num_epochs: (1, 1)
142
+ - max_steps: 6000
143
+ - sampling_strategy: undersampling
144
+ - body_learning_rate: (2e-05, 1e-05)
145
+ - head_learning_rate: 0.01
146
+ - loss: CosineSimilarityLoss
147
+ - distance_metric: cosine_distance
148
+ - margin: 0.25
149
+ - end_to_end: False
150
+ - use_amp: False
151
+ - warmup_proportion: 0.1
152
+ - l2_weight: 0.01
153
+ - seed: 42
154
+ - run_name: setfit_hate_52k_mb_6k
155
+ - eval_max_steps: -1
156
+ - load_best_model_at_end: False
157
+
158
+ ### Training Results
159
+ | Epoch | Step | Training Loss | Validation Loss |
160
+ |:------:|:----:|:-------------:|:---------------:|
161
+ | 0.0003 | 1 | 0.3373 | - |
162
+ | 0.0333 | 100 | 0.2955 | - |
163
+ | 0.0667 | 200 | 0.2535 | - |
164
+ | 0.1 | 300 | 0.2373 | - |
165
+ | 0.1333 | 400 | 0.2228 | - |
166
+ | 0.1667 | 500 | 0.1956 | - |
167
+ | 0.2 | 600 | 0.1768 | - |
168
+ | 0.2333 | 700 | 0.1489 | - |
169
+ | 0.2667 | 800 | 0.122 | - |
170
+ | 0.3 | 900 | 0.1045 | - |
171
+ | 0.3333 | 1000 | 0.086 | - |
172
+ | 0.3667 | 1100 | 0.0681 | - |
173
+ | 0.4 | 1200 | 0.067 | - |
174
+ | 0.4333 | 1300 | 0.0477 | - |
175
+ | 0.4667 | 1400 | 0.043 | - |
176
+ | 0.5 | 1500 | 0.0316 | - |
177
+ | 0.5333 | 1600 | 0.0251 | - |
178
+ | 0.5667 | 1700 | 0.0236 | - |
179
+ | 0.6 | 1800 | 0.0163 | - |
180
+ | 0.6333 | 1900 | 0.0148 | - |
181
+ | 0.6667 | 2000 | 0.0105 | - |
182
+ | 0.7 | 2100 | 0.018 | - |
183
+ | 0.7333 | 2200 | 0.013 | - |
184
+ | 0.7667 | 2300 | 0.0103 | - |
185
+ | 0.8 | 2400 | 0.0107 | - |
186
+ | 0.8333 | 2500 | 0.0115 | - |
187
+ | 0.8667 | 2600 | 0.0069 | - |
188
+ | 0.9 | 2700 | 0.0062 | - |
189
+ | 0.9333 | 2800 | 0.0074 | - |
190
+ | 0.9667 | 2900 | 0.0063 | - |
191
+ | 1.0 | 3000 | 0.0068 | - |
192
+ | 1.0333 | 3100 | 0.0048 | - |
193
+ | 1.0667 | 3200 | 0.0055 | - |
194
+ | 1.1 | 3300 | 0.0047 | - |
195
+ | 1.1333 | 3400 | 0.0043 | - |
196
+ | 1.1667 | 3500 | 0.0029 | - |
197
+ | 1.2 | 3600 | 0.0036 | - |
198
+ | 1.2333 | 3700 | 0.0034 | - |
199
+ | 1.2667 | 3800 | 0.0024 | - |
200
+ | 1.3 | 3900 | 0.0033 | - |
201
+ | 1.3333 | 4000 | 0.0042 | - |
202
+ | 1.3667 | 4100 | 0.0039 | - |
203
+ | 1.4 | 4200 | 0.0019 | - |
204
+ | 1.4333 | 4300 | 0.0022 | - |
205
+ | 1.4667 | 4400 | 0.0031 | - |
206
+ | 1.5 | 4500 | 0.0019 | - |
207
+ | 1.5333 | 4600 | 0.0036 | - |
208
+ | 1.5667 | 4700 | 0.0017 | - |
209
+ | 1.6 | 4800 | 0.0007 | - |
210
+ | 1.6333 | 4900 | 0.0006 | - |
211
+ | 1.6667 | 5000 | 0.0019 | - |
212
+ | 1.7 | 5100 | 0.0022 | - |
213
+ | 1.7333 | 5200 | 0.0013 | - |
214
+ | 1.7667 | 5300 | 0.0025 | - |
215
+ | 1.8 | 5400 | 0.0024 | - |
216
+ | 1.8333 | 5500 | 0.0013 | - |
217
+ | 1.8667 | 5600 | 0.0022 | - |
218
+ | 1.9 | 5700 | 0.0022 | - |
219
+ | 1.9333 | 5800 | 0.0019 | - |
220
+ | 1.9667 | 5900 | 0.0019 | - |
221
+ | 2.0 | 6000 | 0.0031 | - |
222
+
223
+ ### Framework Versions
224
+ - Python: 3.10.12
225
+ - SetFit: 1.2.0.dev0
226
+ - Sentence Transformers: 3.3.1
227
+ - Transformers: 4.48.0
228
+ - PyTorch: 2.5.1+cu121
229
+ - Datasets: 3.2.0
230
+ - Tokenizers: 0.21.0
231
+
232
+ ## Citation
233
+
234
+ ### BibTeX
235
+ ```bibtex
236
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
237
+ doi = {10.48550/ARXIV.2209.11055},
238
+ url = {https://arxiv.org/abs/2209.11055},
239
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
240
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
241
+ title = {Efficient Few-Shot Learning Without Prompts},
242
+ publisher = {arXiv},
243
+ year = {2022},
244
+ copyright = {Creative Commons Attribution 4.0 International}
245
+ }
246
+ ```
247
+
248
+ <!--
249
+ ## Glossary
250
+
251
+ *Clearly define terms in order to be accessible across audiences.*
252
+ -->
253
+
254
+ <!--
255
+ ## Model Card Authors
256
+
257
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
258
+ -->
259
+
260
+ <!--
261
+ ## Model Card Contact
262
+
263
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
264
+ -->
config.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "akhooli/sbert-nli-500k-triplets-MB",
3
+ "architectures": [
4
+ "ModernBertModel"
5
+ ],
6
+ "attention_bias": false,
7
+ "attention_dropout": 0.0,
8
+ "bos_token_id": null,
9
+ "classifier_activation": "gelu",
10
+ "classifier_bias": false,
11
+ "classifier_dropout": 0.0,
12
+ "classifier_pooling": "cls",
13
+ "cls_token_id": 3,
14
+ "decoder_bias": true,
15
+ "deterministic_flash_attn": false,
16
+ "embedding_dropout": 0.0,
17
+ "eos_token_id": null,
18
+ "global_attn_every_n_layers": 3,
19
+ "global_rope_theta": 10000,
20
+ "hidden_activation": "gelu",
21
+ "hidden_size": 768,
22
+ "initializer_cutoff_factor": 2.0,
23
+ "initializer_range": 0.02,
24
+ "intermediate_size": 1152,
25
+ "local_attention": 128,
26
+ "local_rope_theta": 10000.0,
27
+ "max_position_embeddings": 8192,
28
+ "mlp_bias": false,
29
+ "mlp_dropout": 0.0,
30
+ "model_type": "modernbert",
31
+ "norm_bias": false,
32
+ "norm_eps": 1e-05,
33
+ "num_attention_heads": 12,
34
+ "num_hidden_layers": 22,
35
+ "pad_token_id": 5,
36
+ "reference_compile": false,
37
+ "repad_logits_with_grad": false,
38
+ "sep_token_id": 4,
39
+ "sparse_pred_ignore_index": -100,
40
+ "sparse_prediction": false,
41
+ "torch_dtype": "float32",
42
+ "transformers_version": "4.48.0",
43
+ "vocab_size": 50368
44
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.3.1",
4
+ "transformers": "4.48.0",
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,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "normalize_embeddings": false,
3
+ "labels": [
4
+ "negative",
5
+ "positive"
6
+ ]
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a49f044884065e97a9920098f57661e9ce05fc920b786a72a4621027e0db657
3
+ size 596070136
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:22830105d926f2083c2fee65015823750aad45a87a798fd7614df32fbd215652
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": 8192,
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": true,
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,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<|padding|>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<|endoftext|>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[UNK]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[CLS]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "4": {
36
+ "content": "[SEP]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ },
43
+ "5": {
44
+ "content": "[PAD]",
45
+ "lstrip": false,
46
+ "normalized": false,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": true
50
+ },
51
+ "6": {
52
+ "content": "[MASK]",
53
+ "lstrip": true,
54
+ "normalized": false,
55
+ "rstrip": false,
56
+ "single_word": false,
57
+ "special": true
58
+ }
59
+ },
60
+ "clean_up_tokenization_spaces": true,
61
+ "cls_token": "[CLS]",
62
+ "extra_special_tokens": {},
63
+ "mask_token": "[MASK]",
64
+ "max_length": 8192,
65
+ "model_input_names": [
66
+ "input_ids",
67
+ "attention_mask"
68
+ ],
69
+ "model_max_length": 8192,
70
+ "pad_to_multiple_of": null,
71
+ "pad_token": "[PAD]",
72
+ "pad_token_type_id": 0,
73
+ "padding_side": "right",
74
+ "sep_token": "[SEP]",
75
+ "stride": 0,
76
+ "tokenizer_class": "PreTrainedTokenizerFast",
77
+ "truncation_side": "right",
78
+ "truncation_strategy": "longest_first",
79
+ "unk_token": "[UNK]"
80
+ }