Ouchbara commited on
Commit
c639a91
·
verified ·
1 Parent(s): 7daaa2a

Ouchbara/embiding/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 man with blond-hair, and a brown shirt drinking out of a public
12
+ water fountain.
13
+ sentences:
14
+ - A blond man wearing a brown shirt is reading a book on a bench in the park
15
+ - The friends scowl at each other over a full dinner table.
16
+ - Two adults walk across a street.
17
+ - source_sentence: An older man sits with his orange juice at a small table in a coffee
18
+ shop while employees in bright colored shirts smile in the background.
19
+ sentences:
20
+ - The woman and man are playing baseball together.
21
+ - The friends have just met for the first time in 20 years, and have had a great
22
+ time catching up.
23
+ - An older man drinks his juice as he waits for his daughter to get off work.
24
+ - source_sentence: Two adults, one female in white, with shades and one male, gray
25
+ clothes, walking across a street, away from a eatery with a blurred image of a
26
+ dark colored red shirted person in the foreground.
27
+ sentences:
28
+ - There are no women in the picture.
29
+ - A person eating.
30
+ - The woman is wearing green.
31
+ - source_sentence: A man, woman, and child enjoying themselves on a beach.
32
+ sentences:
33
+ - A family of three is at the beach.
34
+ - The mans briefcase is for work.
35
+ - A person is training his horse for a competition.
36
+ - source_sentence: Children smiling and waving at camera
37
+ sentences:
38
+ - The family is on vacation.
39
+ - Two groups of rival gang members flipped each other off.
40
+ - There are children present
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.1629711561999381
58
+ name: Pearson Cosine
59
+ - type: spearman_cosine
60
+ value: 0.01599191652998732
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
+ 'Children smiling and waving at camera',
115
+ 'There are children present',
116
+ 'The family is on vacation.',
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.9857, 0.9845],
126
+ # [0.9857, 1.0000, 0.9931],
127
+ # [0.9845, 0.9931, 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.163 |
165
+ | **spearman_cosine** | **0.016** |
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: 26.0 tokens</li><li>max: 52 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 11.95 tokens</li><li>max: 29 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.49</li><li>max: 1.0</li></ul> |
193
+ * Samples:
194
+ | sentence1 | sentence2 | score |
195
+ |:----------------------------------------------------------------------------------------------------|:--------------------------------------------------------------|:-----------------|
196
+ | <code>A boy is jumping on skateboard in the middle of a red bridge.</code> | <code>The boy is wearing safety equipment.</code> | <code>0.5</code> |
197
+ | <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> |
198
+ | <code>Two blond women are hugging one another.</code> | <code>The women are sleeping.</code> | <code>0.0</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: 10 tokens</li><li>mean: 24.65 tokens</li><li>max: 52 tokens</li></ul> | <ul><li>min: 6 tokens</li><li>mean: 12.1 tokens</li><li>max: 25 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.55</li><li>max: 1.0</li></ul> |
219
+ * Samples:
220
+ | sentence1 | sentence2 | score |
221
+ |:-------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------|:-----------------|
222
+ | <code>A woman is walking across the street eating a banana, while a man is following with his briefcase.</code> | <code>The woman and man are playing baseball together.</code> | <code>0.0</code> |
223
+ | <code>A couple play in the tide with their young son.</code> | <code>The family is on vacation.</code> | <code>0.5</code> |
224
+ | <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> |
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.9349 | - | - |
350
+ | 0.5 | 5 | 3.0658 | - | - |
351
+ | **1.0** | **10** | **2.926** | **2.8427** | **0.016** |
352
+
353
+ * The bold row denotes the saved checkpoint.
354
+
355
+ ### Training Time
356
+ - **Training**: 22.5 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
+ }