Ismailea04 commited on
Commit
8f490c4
·
verified ·
1 Parent(s): 825b324

EigenBrains/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,412 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - sentence-transformers
4
+ - sentence-similarity
5
+ - feature-extraction
6
+ - generated_from_trainer
7
+ - dataset_size:240
8
+ - loss:CoSENTLoss
9
+ base_model: abdeljalilELmajjodi/model
10
+ widget:
11
+ - source_sentence: A woman is walking across the street eating a banana, while a man
12
+ is following with his briefcase.
13
+ sentences:
14
+ - The bicyclists are dead.
15
+ - A man has facial hair.
16
+ - the woman is outside
17
+ - source_sentence: A big brown dog swims towards the camera.
18
+ sentences:
19
+ - People with bikes.
20
+ - Two men play catch on a hill.
21
+ - A dog swims towards the camera.
22
+ - source_sentence: A man with a beard, wearing a red shirt with gray sleeves and work
23
+ gloves, pulling on a rope.
24
+ sentences:
25
+ - A female is next to a man.
26
+ - A family of three is at the mall shopping.
27
+ - The man was clean shaven.
28
+ - source_sentence: A blond man is drinking from a public fountain.
29
+ sentences:
30
+ - People on bicycles speed through an intersection.
31
+ - Men and women outside on a street corner.
32
+ - The man is drinking water.
33
+ - source_sentence: Bicyclists waiting at an intersection.
34
+ sentences:
35
+ - The man is sitting down while he has a sign for John's Pizza and Gyro in his arms.
36
+ - The bicyclists are at home.
37
+ - Five bikers are riding on the road.
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.12068451525682179
55
+ name: Pearson Cosine
56
+ - type: spearman_cosine
57
+ value: -0.0998270817072691
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
+ 'Bicyclists waiting at an intersection.',
112
+ 'The bicyclists are at home.',
113
+ 'Five bikers are riding on the road.',
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.9860, 0.9703],
123
+ # [0.9860, 1.0000, 0.9793],
124
+ # [0.9703, 0.9793, 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.1207 |
162
+ | **spearman_cosine** | **-0.0998** |
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: 240 training samples
184
+ * Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
185
+ * Approximate statistics based on the first 240 samples:
186
+ | | sentence1 | sentence2 | score |
187
+ |:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------|
188
+ | type | string | string | float |
189
+ | details | <ul><li>min: 8 tokens</li><li>mean: 20.42 tokens</li><li>max: 58 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 12.19 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> |
190
+ * Samples:
191
+ | sentence1 | sentence2 | score |
192
+ |:----------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------|:-----------------|
193
+ | <code>High fashion ladies wait outside a tram beside a crowd of people in the city.</code> | <code>Women are waiting by a tram.</code> | <code>1.0</code> |
194
+ | <code>Two women who just had lunch hugging and saying goodbye.</code> | <code>The friends have just met for the first time in 20 years, and have had a great time catching up.</code> | <code>0.5</code> |
195
+ | <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> |
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: 60 evaluation samples
210
+ * Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
211
+ * Approximate statistics based on the first 60 samples:
212
+ | | sentence1 | sentence2 | score |
213
+ |:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------|
214
+ | type | string | string | float |
215
+ | details | <ul><li>min: 9 tokens</li><li>mean: 20.95 tokens</li><li>max: 52 tokens</li></ul> | <ul><li>min: 6 tokens</li><li>mean: 11.42 tokens</li><li>max: 24 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.47</li><li>max: 1.0</li></ul> |
216
+ * Samples:
217
+ | sentence1 | sentence2 | score |
218
+ |:------------------------------------------------------------------------------------|:-------------------------------------------------------|:-----------------|
219
+ | <code>A yellow uniformed skier is performing a trick across a railed object.</code> | <code>A skier is competing in a competition.</code> | <code>0.5</code> |
220
+ | <code>A yellow uniformed skier is performing a trick across a railed object.</code> | <code>A snowboarder is riding a ski lift.</code> | <code>0.0</code> |
221
+ | <code>A boat worker securing line.</code> | <code>The boat worker is swimming in the ocean.</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.0333 | 1 | 2.7398 | - | - |
347
+ | 0.1667 | 5 | 3.0677 | - | - |
348
+ | **0.3333** | **10** | **2.8502** | **2.7886** | **-0.0199** |
349
+ | 0.5 | 15 | 3.0319 | - | - |
350
+ | 0.6667 | 20 | 3.0896 | 3.0382 | -0.1429 |
351
+ | 0.8333 | 25 | 2.8197 | - | - |
352
+ | 1.0 | 30 | 3.0208 | 2.9154 | -0.0998 |
353
+
354
+ * The bold row denotes the saved checkpoint.
355
+
356
+ ### Training Time
357
+ - **Training**: 12.0 minutes
358
+
359
+ ### Framework Versions
360
+ - Python: 3.12.13
361
+ - Sentence Transformers: 5.4.1
362
+ - Transformers: 5.0.0
363
+ - PyTorch: 2.10.0+cu128
364
+ - Accelerate: 1.13.0
365
+ - Datasets: 4.8.5
366
+ - Tokenizers: 0.22.2
367
+
368
+ ## Citation
369
+
370
+ ### BibTeX
371
+
372
+ #### Sentence Transformers
373
+ ```bibtex
374
+ @inproceedings{reimers-2019-sentence-bert,
375
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
376
+ author = "Reimers, Nils and Gurevych, Iryna",
377
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
378
+ month = "11",
379
+ year = "2019",
380
+ publisher = "Association for Computational Linguistics",
381
+ url = "https://arxiv.org/abs/1908.10084",
382
+ }
383
+ ```
384
+
385
+ #### CoSENTLoss
386
+ ```bibtex
387
+ @article{10531646,
388
+ 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.},
389
+ journal={IEEE/ACM Transactions on Audio, Speech, and Language Processing},
390
+ title={CoSENT: Consistent Sentence Embedding via Similarity Ranking},
391
+ year={2024},
392
+ doi={10.1109/TASLP.2024.3402087}
393
+ }
394
+ ```
395
+
396
+ <!--
397
+ ## Glossary
398
+
399
+ *Clearly define terms in order to be accessible across audiences.*
400
+ -->
401
+
402
+ <!--
403
+ ## Model Card Authors
404
+
405
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
406
+ -->
407
+
408
+ <!--
409
+ ## Model Card Contact
410
+
411
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
412
+ -->
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
+ }
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:01709c3a6fe68049a75924db540a50e570c76c83d3bbebfc8212518bf0c319c7
3
  size 2239607120
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da05267472aea7ac55d82bdc3a2fa091d3ac8c2007dbe61774ba472a8bf46209
3
  size 2239607120
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
+ }