JihaneJra commited on
Commit
b507aab
·
verified ·
1 Parent(s): c024c4e

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