SamiKazrboubi commited on
Commit
9dd2867
·
verified ·
1 Parent(s): f289740

SamiKazrboubi/hack_ai_embbedding_model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 1024,
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,430 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - sentence-transformers
6
+ - sentence-similarity
7
+ - feature-extraction
8
+ - generated_from_trainer
9
+ - dataset_size:80
10
+ - loss:CoSENTLoss
11
+ base_model: abdeljalilELmajjodi/model
12
+ widget:
13
+ - source_sentence: A man, woman, and child enjoying themselves on a beach.
14
+ sentences:
15
+ - A family of three is at the mall shopping.
16
+ - An actress and her favorite assistant talk a walk in the city.
17
+ - The woman is nake.
18
+ - source_sentence: A woman in a green jacket and hood over her head looking towards
19
+ a valley.
20
+ sentences:
21
+ - Nobody has food.
22
+ - The people are sitting at desks in school.
23
+ - The woman is wearing green.
24
+ - source_sentence: Woman in white in foreground and a man slightly behind walking
25
+ with a sign for John's Pizza and Gyro in the background.
26
+ sentences:
27
+ - The woman is wearing black.
28
+ - A man is drinking juice.
29
+ - A blond man wearing a brown shirt is reading a book on a bench in the park
30
+ - source_sentence: Two adults, one female in white, with shades and one male, gray
31
+ clothes, walking across a street, away from a eatery with a blurred image of a
32
+ dark colored red shirted person in the foreground.
33
+ sentences:
34
+ - Two adults walking across a road near the convicted prisoner dressed in red
35
+ - The family is sitting down for dinner.
36
+ - A person that is hungry.
37
+ - source_sentence: A woman wearing all white and eating, walks next to a man holding
38
+ a briefcase.
39
+ sentences:
40
+ - Near a couple of restaurants, two people walk across the street.
41
+ - A woman eats ice cream walking down the sidewalk, and there is another woman in
42
+ front of her with a purse.
43
+ - A married couple is walking next to each other.
44
+ datasets:
45
+ - sentence-transformers/all-nli
46
+ pipeline_tag: sentence-similarity
47
+ library_name: sentence-transformers
48
+ metrics:
49
+ - pearson_cosine
50
+ - spearman_cosine
51
+ model-index:
52
+ - name: SentenceTransformer based on abdeljalilELmajjodi/model
53
+ results:
54
+ - task:
55
+ type: semantic-similarity
56
+ name: Semantic Similarity
57
+ dataset:
58
+ name: pair score evaluator dev
59
+ type: pair-score-evaluator-dev
60
+ metrics:
61
+ - type: pearson_cosine
62
+ value: 0.5632238441216909
63
+ name: Pearson Cosine
64
+ - type: spearman_cosine
65
+ value: 0.5948422242500994
66
+ name: Spearman Cosine
67
+ ---
68
+
69
+ # SentenceTransformer based on abdeljalilELmajjodi/model
70
+
71
+ This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [abdeljalilELmajjodi/model](https://huggingface.co/abdeljalilELmajjodi/model) on the [all-nli](https://huggingface.co/datasets/sentence-transformers/all-nli) dataset. It maps sentences & paragraphs to a 1024-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
72
+
73
+ ## Model Details
74
+
75
+ ### Model Description
76
+ - **Model Type:** Sentence Transformer
77
+ - **Base model:** [abdeljalilELmajjodi/model](https://huggingface.co/abdeljalilELmajjodi/model) <!-- at revision 284169e2c18b482372374a251b8dc1e1756416de -->
78
+ - **Maximum Sequence Length:** 512 tokens
79
+ - **Output Dimensionality:** 1024 dimensions
80
+ - **Similarity Function:** Cosine Similarity
81
+ - **Training Dataset:**
82
+ - [all-nli](https://huggingface.co/datasets/sentence-transformers/all-nli)
83
+ - **Language:** en
84
+ <!-- - **License:** Unknown -->
85
+
86
+ ### Model Sources
87
+
88
+ - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
89
+ - **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
90
+ - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
91
+
92
+ ### Full Model Architecture
93
+
94
+ ```
95
+ SentenceTransformer(
96
+ (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: XLMRobertaModel
97
+ (1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
98
+ )
99
+ ```
100
+
101
+ ## Usage
102
+
103
+ ### Direct Usage (Sentence Transformers)
104
+
105
+ First install the Sentence Transformers library:
106
+
107
+ ```bash
108
+ pip install -U sentence-transformers
109
+ ```
110
+
111
+ Then you can load this model and run inference.
112
+ ```python
113
+ from sentence_transformers import SentenceTransformer
114
+
115
+ # Download from the 🤗 Hub
116
+ model = SentenceTransformer("sentence_transformers_model_id")
117
+ # Run inference
118
+ sentences = [
119
+ 'A woman wearing all white and eating, walks next to a man holding a briefcase.',
120
+ 'A married couple is walking next to each other.',
121
+ 'Near a couple of restaurants, two people walk across the street.',
122
+ ]
123
+ embeddings = model.encode(sentences)
124
+ print(embeddings.shape)
125
+ # [3, 1024]
126
+
127
+ # Get the similarity scores for the embeddings
128
+ similarities = model.similarity(embeddings, embeddings)
129
+ print(similarities.shape)
130
+ # [3, 3]
131
+ ```
132
+
133
+ <!--
134
+ ### Direct Usage (Transformers)
135
+
136
+ <details><summary>Click to see the direct usage in Transformers</summary>
137
+
138
+ </details>
139
+ -->
140
+
141
+ <!--
142
+ ### Downstream Usage (Sentence Transformers)
143
+
144
+ You can finetune this model on your own dataset.
145
+
146
+ <details><summary>Click to expand</summary>
147
+
148
+ </details>
149
+ -->
150
+
151
+ <!--
152
+ ### Out-of-Scope Use
153
+
154
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
155
+ -->
156
+
157
+ ## Evaluation
158
+
159
+ ### Metrics
160
+
161
+ #### Semantic Similarity
162
+
163
+ * Dataset: `pair-score-evaluator-dev`
164
+ * Evaluated with [<code>EmbeddingSimilarityEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator)
165
+
166
+ | Metric | Value |
167
+ |:--------------------|:-----------|
168
+ | pearson_cosine | 0.5632 |
169
+ | **spearman_cosine** | **0.5948** |
170
+
171
+ <!--
172
+ ## Bias, Risks and Limitations
173
+
174
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
175
+ -->
176
+
177
+ <!--
178
+ ### Recommendations
179
+
180
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
181
+ -->
182
+
183
+ ## Training Details
184
+
185
+ ### Training Dataset
186
+
187
+ #### all-nli
188
+
189
+ * Dataset: [all-nli](https://huggingface.co/datasets/sentence-transformers/all-nli) at [d482672](https://huggingface.co/datasets/sentence-transformers/all-nli/tree/d482672c8e74ce18da116f430137434ba2e52fab)
190
+ * Size: 80 training samples
191
+ * Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
192
+ * Approximate statistics based on the first 80 samples:
193
+ | | sentence1 | sentence2 | score |
194
+ |:--------|:-----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------|
195
+ | type | string | string | float |
196
+ | details | <ul><li>min: 10 tokens</li><li>mean: 26.15 tokens</li><li>max: 52 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 11.68 tokens</li><li>max: 29 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.54</li><li>max: 1.0</li></ul> |
197
+ * Samples:
198
+ | sentence1 | sentence2 | score |
199
+ |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------|:-----------------|
200
+ | <code>Two women, holding food carryout containers, hug.</code> | <code>Two women hug each other.</code> | <code>1.0</code> |
201
+ | <code>Two adults, one female in white, with shades and one male, gray clothes, walking across a street, away from a eatery with a blurred image of a dark colored red shirted person in the foreground.</code> | <code>Two people walk home after a tasty steak dinner.</code> | <code>0.5</code> |
202
+ | <code>An older man is drinking orange juice at a restaurant.</code> | <code>Two women are at a restaurant drinking wine.</code> | <code>0.0</code> |
203
+ * Loss: [<code>CoSENTLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
204
+ ```json
205
+ {
206
+ "scale": 20.0,
207
+ "similarity_fct": "pairwise_cos_sim"
208
+ }
209
+ ```
210
+
211
+ ### Evaluation Dataset
212
+
213
+ #### all-nli
214
+
215
+ * Dataset: [all-nli](https://huggingface.co/datasets/sentence-transformers/all-nli) at [d482672](https://huggingface.co/datasets/sentence-transformers/all-nli/tree/d482672c8e74ce18da116f430137434ba2e52fab)
216
+ * Size: 20 evaluation samples
217
+ * Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
218
+ * Approximate statistics based on the first 20 samples:
219
+ | | sentence1 | sentence2 | score |
220
+ |:--------|:-----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------|
221
+ | type | string | string | float |
222
+ | details | <ul><li>min: 10 tokens</li><li>mean: 24.05 tokens</li><li>max: 52 tokens</li></ul> | <ul><li>min: 7 tokens</li><li>mean: 13.2 tokens</li><li>max: 29 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.35</li><li>max: 1.0</li></ul> |
223
+ * Samples:
224
+ | sentence1 | sentence2 | score |
225
+ |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------|:-----------------|
226
+ | <code>A man with blond-hair, and a brown shirt drinking out of a public water fountain.</code> | <code>A blond man wearing a brown shirt is reading a book on a bench in the park</code> | <code>0.0</code> |
227
+ | <code>Two adults, one female in white, with shades and one male, gray clothes, walking across a street, away from a eatery with a blurred image of a dark colored red shirted person in the foreground.</code> | <code>Two adults walking across a road near the convicted prisoner dressed in red</code> | <code>0.5</code> |
228
+ | <code>A woman in a green jacket and hood over her head looking towards a valley.</code> | <code>The woman is nake.</code> | <code>0.0</code> |
229
+ * Loss: [<code>CoSENTLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
230
+ ```json
231
+ {
232
+ "scale": 20.0,
233
+ "similarity_fct": "pairwise_cos_sim"
234
+ }
235
+ ```
236
+
237
+ ### Training Hyperparameters
238
+ #### Non-Default Hyperparameters
239
+
240
+ - `eval_strategy`: steps
241
+ - `num_train_epochs`: 1
242
+ - `warmup_ratio`: 0.05
243
+ - `bf16`: True
244
+ - `fp16_full_eval`: True
245
+ - `load_best_model_at_end`: True
246
+ - `push_to_hub`: True
247
+ - `gradient_checkpointing`: True
248
+
249
+ #### All Hyperparameters
250
+ <details><summary>Click to expand</summary>
251
+
252
+ - `overwrite_output_dir`: False
253
+ - `do_predict`: False
254
+ - `eval_strategy`: steps
255
+ - `prediction_loss_only`: True
256
+ - `per_device_train_batch_size`: 8
257
+ - `per_device_eval_batch_size`: 8
258
+ - `per_gpu_train_batch_size`: None
259
+ - `per_gpu_eval_batch_size`: None
260
+ - `gradient_accumulation_steps`: 1
261
+ - `eval_accumulation_steps`: None
262
+ - `torch_empty_cache_steps`: None
263
+ - `learning_rate`: 5e-05
264
+ - `weight_decay`: 0.0
265
+ - `adam_beta1`: 0.9
266
+ - `adam_beta2`: 0.999
267
+ - `adam_epsilon`: 1e-08
268
+ - `max_grad_norm`: 1.0
269
+ - `num_train_epochs`: 1
270
+ - `max_steps`: -1
271
+ - `lr_scheduler_type`: linear
272
+ - `lr_scheduler_kwargs`: {}
273
+ - `warmup_ratio`: 0.05
274
+ - `warmup_steps`: 0
275
+ - `log_level`: passive
276
+ - `log_level_replica`: warning
277
+ - `log_on_each_node`: True
278
+ - `logging_nan_inf_filter`: True
279
+ - `save_safetensors`: True
280
+ - `save_on_each_node`: False
281
+ - `save_only_model`: False
282
+ - `restore_callback_states_from_checkpoint`: False
283
+ - `no_cuda`: False
284
+ - `use_cpu`: False
285
+ - `use_mps_device`: False
286
+ - `seed`: 42
287
+ - `data_seed`: None
288
+ - `jit_mode_eval`: False
289
+ - `use_ipex`: False
290
+ - `bf16`: True
291
+ - `fp16`: False
292
+ - `fp16_opt_level`: O1
293
+ - `half_precision_backend`: auto
294
+ - `bf16_full_eval`: False
295
+ - `fp16_full_eval`: True
296
+ - `tf32`: None
297
+ - `local_rank`: 0
298
+ - `ddp_backend`: None
299
+ - `tpu_num_cores`: None
300
+ - `tpu_metrics_debug`: False
301
+ - `debug`: []
302
+ - `dataloader_drop_last`: False
303
+ - `dataloader_num_workers`: 0
304
+ - `dataloader_prefetch_factor`: None
305
+ - `past_index`: -1
306
+ - `disable_tqdm`: False
307
+ - `remove_unused_columns`: True
308
+ - `label_names`: None
309
+ - `load_best_model_at_end`: True
310
+ - `ignore_data_skip`: False
311
+ - `fsdp`: []
312
+ - `fsdp_min_num_params`: 0
313
+ - `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
314
+ - `fsdp_transformer_layer_cls_to_wrap`: None
315
+ - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
316
+ - `deepspeed`: None
317
+ - `label_smoothing_factor`: 0.0
318
+ - `optim`: adamw_torch
319
+ - `optim_args`: None
320
+ - `adafactor`: False
321
+ - `group_by_length`: False
322
+ - `length_column_name`: length
323
+ - `ddp_find_unused_parameters`: None
324
+ - `ddp_bucket_cap_mb`: None
325
+ - `ddp_broadcast_buffers`: False
326
+ - `dataloader_pin_memory`: True
327
+ - `dataloader_persistent_workers`: False
328
+ - `skip_memory_metrics`: True
329
+ - `use_legacy_prediction_loop`: False
330
+ - `push_to_hub`: True
331
+ - `resume_from_checkpoint`: None
332
+ - `hub_model_id`: None
333
+ - `hub_strategy`: every_save
334
+ - `hub_private_repo`: None
335
+ - `hub_always_push`: False
336
+ - `gradient_checkpointing`: True
337
+ - `gradient_checkpointing_kwargs`: None
338
+ - `include_inputs_for_metrics`: False
339
+ - `include_for_metrics`: []
340
+ - `eval_do_concat_batches`: True
341
+ - `fp16_backend`: auto
342
+ - `push_to_hub_model_id`: None
343
+ - `push_to_hub_organization`: None
344
+ - `mp_parameters`:
345
+ - `auto_find_batch_size`: False
346
+ - `full_determinism`: False
347
+ - `torchdynamo`: None
348
+ - `ray_scope`: last
349
+ - `ddp_timeout`: 1800
350
+ - `torch_compile`: False
351
+ - `torch_compile_backend`: None
352
+ - `torch_compile_mode`: None
353
+ - `include_tokens_per_second`: False
354
+ - `include_num_input_tokens_seen`: False
355
+ - `neftune_noise_alpha`: None
356
+ - `optim_target_modules`: None
357
+ - `batch_eval_metrics`: False
358
+ - `eval_on_start`: False
359
+ - `use_liger_kernel`: False
360
+ - `eval_use_gather_object`: False
361
+ - `average_tokens_across_devices`: False
362
+ - `prompts`: None
363
+ - `batch_sampler`: batch_sampler
364
+ - `multi_dataset_batch_sampler`: proportional
365
+
366
+ </details>
367
+
368
+ ### Training Logs
369
+ | Epoch | Step | Training Loss | Validation Loss | pair-score-evaluator-dev_spearman_cosine |
370
+ |:-------:|:------:|:-------------:|:---------------:|:----------------------------------------:|
371
+ | 0.1 | 1 | 2.962 | - | - |
372
+ | 0.5 | 5 | 3.1673 | - | - |
373
+ | **1.0** | **10** | **2.813** | **2.6618** | **0.5948** |
374
+
375
+ * The bold row denotes the saved checkpoint.
376
+
377
+ ### Framework Versions
378
+ - Python: 3.11.12
379
+ - Sentence Transformers: 4.1.0
380
+ - Transformers: 4.52.3
381
+ - PyTorch: 2.7.0+cu118
382
+ - Accelerate: 1.6.0
383
+ - Datasets: 3.6.0
384
+ - Tokenizers: 0.21.1
385
+
386
+ ## Citation
387
+
388
+ ### BibTeX
389
+
390
+ #### Sentence Transformers
391
+ ```bibtex
392
+ @inproceedings{reimers-2019-sentence-bert,
393
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
394
+ author = "Reimers, Nils and Gurevych, Iryna",
395
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
396
+ month = "11",
397
+ year = "2019",
398
+ publisher = "Association for Computational Linguistics",
399
+ url = "https://arxiv.org/abs/1908.10084",
400
+ }
401
+ ```
402
+
403
+ #### CoSENTLoss
404
+ ```bibtex
405
+ @online{kexuefm-8847,
406
+ title={CoSENT: A more efficient sentence vector scheme than Sentence-BERT},
407
+ author={Su Jianlin},
408
+ year={2022},
409
+ month={Jan},
410
+ url={https://kexue.fm/archives/8847},
411
+ }
412
+ ```
413
+
414
+ <!--
415
+ ## Glossary
416
+
417
+ *Clearly define terms in order to be accessible across audiences.*
418
+ -->
419
+
420
+ <!--
421
+ ## Model Card Authors
422
+
423
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
424
+ -->
425
+
426
+ <!--
427
+ ## Model Card Contact
428
+
429
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
430
+ -->
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "4.1.0",
4
+ "transformers": "4.52.3",
5
+ "pytorch": "2.7.0+cu118"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": "cosine"
10
+ }
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
+ }