Riyadh03 commited on
Commit
433a190
·
verified ·
1 Parent(s): 33f5709

aitouiazzaneali49/hack_ai_embbedding_model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "embedding_dimension": 1024,
3
+ "pooling_mode": "mean",
4
+ "include_prompt": true
5
+ }
README.md ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - sentence-transformers
4
+ - sentence-similarity
5
+ - feature-extraction
6
+ - generated_from_trainer
7
+ - dataset_size:80
8
+ - loss:CoSENTLoss
9
+ base_model: abdeljalilELmajjodi/model
10
+ widget:
11
+ - source_sentence: A couple play in the tide with their young son.
12
+ sentences:
13
+ - The family is outside.
14
+ - A man in a restaurant is waiting for his meal to arrive.
15
+ - Two adults walking across a road
16
+ - source_sentence: A couple playing with a little boy on the beach.
17
+ sentences:
18
+ - They are working for John's Pizza.
19
+ - The woman is wearing green.
20
+ - A couple are playing frisbee with a young child at the beach.
21
+ - source_sentence: A man, woman, and child enjoying themselves on a beach.
22
+ sentences:
23
+ - A family of three is at the mall shopping.
24
+ - A person is training his horse for a competition.
25
+ - The diners are at a restaurant.
26
+ - source_sentence: Two women who just had lunch hugging and saying goodbye.
27
+ sentences:
28
+ - The friends have just met for the first time in 20 years, and have had a great
29
+ time catching up.
30
+ - A blond man drinking water from a fountain.
31
+ - The woman and man are outdoors.
32
+ - source_sentence: Two adults, one female in white, with shades and one male, gray
33
+ clothes, walking across a street, away from a eatery with a blurred image of a
34
+ dark colored red shirted person in the foreground.
35
+ sentences:
36
+ - The man with the sign is caucasian.
37
+ - A woman in white.
38
+ - The adults are both male and female.
39
+ pipeline_tag: sentence-similarity
40
+ library_name: sentence-transformers
41
+ metrics:
42
+ - pearson_cosine
43
+ - spearman_cosine
44
+ model-index:
45
+ - name: SentenceTransformer based on abdeljalilELmajjodi/model
46
+ results:
47
+ - task:
48
+ type: semantic-similarity
49
+ name: Semantic Similarity
50
+ dataset:
51
+ name: pair score evaluator dev
52
+ type: pair-score-evaluator-dev
53
+ metrics:
54
+ - type: pearson_cosine
55
+ value: -0.06308677482270299
56
+ name: Pearson Cosine
57
+ - type: spearman_cosine
58
+ value: -0.1064194728626353
59
+ name: Spearman Cosine
60
+ ---
61
+
62
+ # SentenceTransformer based on abdeljalilELmajjodi/model
63
+
64
+ This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [abdeljalilELmajjodi/model](https://huggingface.co/abdeljalilELmajjodi/model) on the all-nli dataset. It maps sentences & paragraphs to a 1024-dimensional dense vector space and can be used for retrieval.
65
+
66
+ ## Model Details
67
+
68
+ ### Model Description
69
+ - **Model Type:** Sentence Transformer
70
+ - **Base model:** [abdeljalilELmajjodi/model](https://huggingface.co/abdeljalilELmajjodi/model) <!-- at revision 284169e2c18b482372374a251b8dc1e1756416de -->
71
+ - **Maximum Sequence Length:** 512 tokens
72
+ - **Output Dimensionality:** 1024 dimensions
73
+ - **Similarity Function:** Cosine Similarity
74
+ - **Supported Modality:** Text
75
+ - **Training Dataset:**
76
+ - all-nli
77
+ <!-- - **Language:** Unknown -->
78
+ <!-- - **License:** Unknown -->
79
+
80
+ ### Model Sources
81
+
82
+ - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
83
+ - **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)
84
+ - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
85
+
86
+ ### Full Model Architecture
87
+
88
+ ```
89
+ SentenceTransformer(
90
+ (0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'XLMRobertaModel'})
91
+ (1): Pooling({'embedding_dimension': 1024, 'pooling_mode': 'mean', 'include_prompt': True})
92
+ )
93
+ ```
94
+
95
+ ## Usage
96
+
97
+ ### Direct Usage (Sentence Transformers)
98
+
99
+ First install the Sentence Transformers library:
100
+
101
+ ```bash
102
+ pip install -U sentence-transformers
103
+ ```
104
+ Then you can load this model and run inference.
105
+ ```python
106
+ from sentence_transformers import SentenceTransformer
107
+
108
+ # Download from the 🤗 Hub
109
+ model = SentenceTransformer("sentence_transformers_model_id")
110
+ # Run inference
111
+ sentences = [
112
+ '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.',
113
+ 'The adults are both male and female.',
114
+ 'The man with the sign is caucasian.',
115
+ ]
116
+ embeddings = model.encode(sentences)
117
+ print(embeddings.shape)
118
+ # [3, 1024]
119
+
120
+ # Get the similarity scores for the embeddings
121
+ similarities = model.similarity(embeddings, embeddings)
122
+ print(similarities)
123
+ # tensor([[1.0000, 0.9915, 0.9927],
124
+ # [0.9915, 1.0000, 0.9914],
125
+ # [0.9927, 0.9914, 1.0000]])
126
+ ```
127
+ <!--
128
+ ### Direct Usage (Transformers)
129
+
130
+ <details><summary>Click to see the direct usage in Transformers</summary>
131
+
132
+ </details>
133
+ -->
134
+
135
+ <!--
136
+ ### Downstream Usage (Sentence Transformers)
137
+
138
+ You can finetune this model on your own dataset.
139
+
140
+ <details><summary>Click to expand</summary>
141
+
142
+ </details>
143
+ -->
144
+
145
+ <!--
146
+ ### Out-of-Scope Use
147
+
148
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
149
+ -->
150
+
151
+ ## Evaluation
152
+
153
+ ### Metrics
154
+
155
+ #### Semantic Similarity
156
+
157
+ * Dataset: `pair-score-evaluator-dev`
158
+ * Evaluated with [<code>EmbeddingSimilarityEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.sentence_transformer.evaluation.EmbeddingSimilarityEvaluator)
159
+
160
+ | Metric | Value |
161
+ |:--------------------|:------------|
162
+ | pearson_cosine | -0.0631 |
163
+ | **spearman_cosine** | **-0.1064** |
164
+
165
+ <!--
166
+ ## Bias, Risks and Limitations
167
+
168
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
169
+ -->
170
+
171
+ <!--
172
+ ### Recommendations
173
+
174
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
175
+ -->
176
+
177
+ ## Training Details
178
+
179
+ ### Training Dataset
180
+
181
+ #### all-nli
182
+
183
+ * Dataset: all-nli
184
+ * Size: 80 training samples
185
+ * Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
186
+ * Approximate statistics based on the first 80 samples:
187
+ | | sentence1 | sentence2 | score |
188
+ |:--------|:-----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------|
189
+ | type | string | string | float |
190
+ | details | <ul><li>min: 10 tokens</li><li>mean: 25.66 tokens</li><li>max: 52 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 11.88 tokens</li><li>max: 29 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.47</li><li>max: 1.0</li></ul> |
191
+ * Samples:
192
+ | sentence1 | sentence2 | score |
193
+ |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------|:-----------------|
194
+ | <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>Some people board a train.</code> | <code>0.0</code> |
195
+ | <code>A woman is walking across the street eating a banana, while a man is following with his briefcase.</code> | <code>A person eating.</code> | <code>1.0</code> |
196
+ | <code>A woman is walking across the street eating a banana, while a man is following with his briefcase.</code> | <code>The mans briefcase is for work.</code> | <code>0.5</code> |
197
+ * Loss: [<code>CoSENTLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
198
+ ```json
199
+ {
200
+ "scale": 20.0,
201
+ "similarity_fct": "pairwise_cos_sim"
202
+ }
203
+ ```
204
+
205
+ ### Evaluation Dataset
206
+
207
+ #### all-nli
208
+
209
+ * Dataset: all-nli
210
+ * Size: 20 evaluation samples
211
+ * Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
212
+ * Approximate statistics based on the first 20 samples:
213
+ | | sentence1 | sentence2 | score |
214
+ |:--------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------|
215
+ | type | string | string | float |
216
+ | details | <ul><li>min: 13 tokens</li><li>mean: 26.0 tokens</li><li>max: 52 tokens</li></ul> | <ul><li>min: 7 tokens</li><li>mean: 12.4 tokens</li><li>max: 25 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.65</li><li>max: 1.0</li></ul> |
217
+ * Samples:
218
+ | sentence1 | sentence2 | score |
219
+ |:-------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------|:-----------------|
220
+ | <code>Woman in white in foreground and a man slightly behind walking with a sign for John's Pizza and Gyro in the background.</code> | <code>They are working for John's Pizza.</code> | <code>0.5</code> |
221
+ | <code>Two women who just had lunch hugging and saying goodbye.</code> | <code>The friends have just met for the first time in 20 years, and have had a great time catching up.</code> | <code>0.5</code> |
222
+ | <code>A person on a horse jumps over a broken down airplane.</code> | <code>A person is training his horse for a competition.</code> | <code>0.5</code> |
223
+ * Loss: [<code>CoSENTLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
224
+ ```json
225
+ {
226
+ "scale": 20.0,
227
+ "similarity_fct": "pairwise_cos_sim"
228
+ }
229
+ ```
230
+
231
+ ### Training Hyperparameters
232
+ #### Non-Default Hyperparameters
233
+
234
+ - `num_train_epochs`: 1
235
+ - `warmup_steps`: 0.05
236
+ - `bf16`: True
237
+ - `fp16_full_eval`: True
238
+ - `load_best_model_at_end`: True
239
+ - `push_to_hub`: True
240
+ - `gradient_checkpointing`: True
241
+
242
+ #### All Hyperparameters
243
+ <details><summary>Click to expand</summary>
244
+
245
+ - `do_predict`: False
246
+ - `prediction_loss_only`: True
247
+ - `per_device_train_batch_size`: 8
248
+ - `per_device_eval_batch_size`: 8
249
+ - `gradient_accumulation_steps`: 1
250
+ - `eval_accumulation_steps`: None
251
+ - `torch_empty_cache_steps`: None
252
+ - `learning_rate`: 5e-05
253
+ - `weight_decay`: 0.0
254
+ - `adam_beta1`: 0.9
255
+ - `adam_beta2`: 0.999
256
+ - `adam_epsilon`: 1e-08
257
+ - `max_grad_norm`: 1.0
258
+ - `num_train_epochs`: 1
259
+ - `max_steps`: -1
260
+ - `lr_scheduler_type`: linear
261
+ - `lr_scheduler_kwargs`: None
262
+ - `warmup_ratio`: None
263
+ - `warmup_steps`: 0.05
264
+ - `log_level`: passive
265
+ - `log_level_replica`: warning
266
+ - `log_on_each_node`: True
267
+ - `logging_nan_inf_filter`: True
268
+ - `enable_jit_checkpoint`: False
269
+ - `save_on_each_node`: False
270
+ - `save_only_model`: False
271
+ - `restore_callback_states_from_checkpoint`: False
272
+ - `use_cpu`: False
273
+ - `seed`: 42
274
+ - `data_seed`: None
275
+ - `bf16`: True
276
+ - `fp16`: False
277
+ - `bf16_full_eval`: False
278
+ - `fp16_full_eval`: True
279
+ - `tf32`: None
280
+ - `local_rank`: -1
281
+ - `ddp_backend`: None
282
+ - `debug`: []
283
+ - `dataloader_drop_last`: False
284
+ - `dataloader_num_workers`: 0
285
+ - `dataloader_prefetch_factor`: None
286
+ - `disable_tqdm`: False
287
+ - `remove_unused_columns`: True
288
+ - `label_names`: None
289
+ - `load_best_model_at_end`: True
290
+ - `ignore_data_skip`: False
291
+ - `fsdp`: []
292
+ - `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
293
+ - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
294
+ - `parallelism_config`: None
295
+ - `deepspeed`: None
296
+ - `label_smoothing_factor`: 0.0
297
+ - `optim`: adamw_torch_fused
298
+ - `optim_args`: None
299
+ - `group_by_length`: False
300
+ - `length_column_name`: length
301
+ - `project`: huggingface
302
+ - `trackio_space_id`: trackio
303
+ - `ddp_find_unused_parameters`: None
304
+ - `ddp_bucket_cap_mb`: None
305
+ - `ddp_broadcast_buffers`: False
306
+ - `dataloader_pin_memory`: True
307
+ - `dataloader_persistent_workers`: False
308
+ - `skip_memory_metrics`: True
309
+ - `push_to_hub`: True
310
+ - `resume_from_checkpoint`: None
311
+ - `hub_model_id`: None
312
+ - `hub_strategy`: every_save
313
+ - `hub_private_repo`: None
314
+ - `hub_always_push`: False
315
+ - `hub_revision`: None
316
+ - `gradient_checkpointing`: True
317
+ - `gradient_checkpointing_kwargs`: None
318
+ - `include_for_metrics`: []
319
+ - `eval_do_concat_batches`: True
320
+ - `auto_find_batch_size`: False
321
+ - `full_determinism`: False
322
+ - `ddp_timeout`: 1800
323
+ - `torch_compile`: False
324
+ - `torch_compile_backend`: None
325
+ - `torch_compile_mode`: None
326
+ - `include_num_input_tokens_seen`: no
327
+ - `neftune_noise_alpha`: None
328
+ - `optim_target_modules`: None
329
+ - `batch_eval_metrics`: False
330
+ - `eval_on_start`: False
331
+ - `use_liger_kernel`: False
332
+ - `liger_kernel_config`: None
333
+ - `eval_use_gather_object`: False
334
+ - `average_tokens_across_devices`: True
335
+ - `use_cache`: False
336
+ - `prompts`: None
337
+ - `batch_sampler`: batch_sampler
338
+ - `multi_dataset_batch_sampler`: proportional
339
+ - `router_mapping`: {}
340
+ - `learning_rate_mapping`: {}
341
+
342
+ </details>
343
+
344
+ ### Training Logs
345
+ | Epoch | Step | Training Loss | Validation Loss | pair-score-evaluator-dev_spearman_cosine |
346
+ |:-------:|:------:|:-------------:|:---------------:|:----------------------------------------:|
347
+ | 0.1 | 1 | 2.7818 | - | - |
348
+ | 0.5 | 5 | 2.8166 | - | - |
349
+ | **1.0** | **10** | **3.1101** | **2.7679** | **-0.1064** |
350
+
351
+ * The bold row denotes the saved checkpoint.
352
+
353
+ ### Training Time
354
+ - **Training**: 8.5 minutes
355
+
356
+ ### Framework Versions
357
+ - Python: 3.12.13
358
+ - Sentence Transformers: 5.4.1
359
+ - Transformers: 5.0.0
360
+ - PyTorch: 2.10.0+cu128
361
+ - Accelerate: 1.13.0
362
+ - Datasets: 4.8.5
363
+ - Tokenizers: 0.22.2
364
+
365
+ ## Citation
366
+
367
+ ### BibTeX
368
+
369
+ #### Sentence Transformers
370
+ ```bibtex
371
+ @inproceedings{reimers-2019-sentence-bert,
372
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
373
+ author = "Reimers, Nils and Gurevych, Iryna",
374
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
375
+ month = "11",
376
+ year = "2019",
377
+ publisher = "Association for Computational Linguistics",
378
+ url = "https://arxiv.org/abs/1908.10084",
379
+ }
380
+ ```
381
+
382
+ #### CoSENTLoss
383
+ ```bibtex
384
+ @article{10531646,
385
+ author={Huang, Xiang and Peng, Hao and Zou, Dongcheng and Liu, Zhiwei and Li, Jianxin and Liu, Kay and Wu, Jia and Su, Jianlin and Yu, Philip S.},
386
+ journal={IEEE/ACM Transactions on Audio, Speech, and Language Processing},
387
+ title={CoSENT: Consistent Sentence Embedding via Similarity Ranking},
388
+ year={2024},
389
+ doi={10.1109/TASLP.2024.3402087}
390
+ }
391
+ ```
392
+
393
+ <!--
394
+ ## Glossary
395
+
396
+ *Clearly define terms in order to be accessible across audiences.*
397
+ -->
398
+
399
+ <!--
400
+ ## Model Card Authors
401
+
402
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
403
+ -->
404
+
405
+ <!--
406
+ ## Model Card Contact
407
+
408
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
409
+ -->
config_sentence_transformers.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "pytorch": "2.10.0+cu128",
4
+ "sentence_transformers": "5.4.1",
5
+ "transformers": "5.0.0"
6
+ },
7
+ "default_prompt_name": null,
8
+ "model_type": "SentenceTransformer",
9
+ "prompts": {
10
+ "document": "",
11
+ "query": ""
12
+ },
13
+ "similarity_fn_name": "cosine"
14
+ }
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.base.modules.transformer.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.sentence_transformer.modules.pooling.Pooling"
13
+ }
14
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "transformer_task": "feature-extraction",
3
+ "modality_config": {
4
+ "text": {
5
+ "method": "forward",
6
+ "method_output_name": "last_hidden_state"
7
+ }
8
+ },
9
+ "module_output_name": "token_embeddings"
10
+ }