abderrahmanech commited on
Commit
bcf5659
·
verified ·
1 Parent(s): 833b2fb

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