1HeroX1 commited on
Commit
3ca66c0
·
verified ·
1 Parent(s): 2dd6c1a

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