Haitam03 commited on
Commit
f969d40
·
verified ·
1 Parent(s): 38676f2

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