File size: 17,626 Bytes
17bb5ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
---

tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- dense
- generated_from_trainer
- dataset_size:4555
- loss:MultipleNegativesRankingLoss
base_model: sentence-transformers/all-MiniLM-L6-v2
widget:
- source_sentence: Shahid Kapoor was in a film.
  sentences:
  - In addition to acting in films , Kapoor has sung several of her film songs .
  - Two years later , he played a drug abusing singer in the crime drama Udta Punjab
    , which won him the Filmfare Critics Award for Best Actor .
  - Matthew Paige Damon -LRB- -LSB- ˈdeɪmən -RSB- born October 8 , 1970 -RRB- is an
    American actor , film producer , and screenwriter .
- source_sentence: Robert Redford is a performer.
  sentences:
  - Grey 's Anatomy is an American medical drama television series that premiered

    on American Broadcasting Company -LRB- ABC -RRB- as a mid-season replacement on

    March 27 , 2005 .

  - Charles Robert Redford Jr. -LRB- born August 18 , 1936 -RRB- is an American actor

    , director , producer , businessman , environmentalist , and philanthropist .

  - 'Redford ''s career began in 1960 as a guest star on numerous TV shows , including
    : The Untouchables , Perry Mason , Alfred Hitchcock Presents , and The Twilight
    Zone , among others .'
- source_sentence: Boeing 777 planes have two engines.
  sentences:
  - It is the world 's largest twinjet and has a typical seating capacity of 314 to

    396 passengers , with a range of 5240 to .

  - Bush married Laura Welch in 1977 and ran unsuccessfully for the House of Representatives

    shortly thereafter .

  - The Boeing 777 is a family of long-range wide-body twin-engine jet airliners developed

    and manufactured by Boeing Commercial Airplanes .

- source_sentence: The Academy Honorary Award was put in place for a prize formerly

    named the Special Award.

  sentences:

  - The Academy Honorary Award -- instituted in 1948 for the 21st Academy Awards -LRB-

    previously called the Special Award , which was first presented in early 1929

    -RRB- -- is given annually by the Board of Governors of the Academy of Motion

    Picture Arts and Sciences -LRB- AMPAS -RRB- to celebrate motion picture achievements

    that are not covered by existing Academy Awards , although prior winners of competitive

    Academy Awards are not excluded from receiving the Honorary Award .

  - In 2011 , Hathaway voiced Jewel in the animated film Rio and hosted the 83rd Academy

    Awards with James Franco , which was nominated for a Primetime Emmy Award for

    Outstanding Special Class Program .

  - The song was performed during the Super Bowl XXXVIII halftime show in 2004 .

- source_sentence: Instagram started supporting videos in 2015.

  sentences:

  - 'In 2015 , she reprised her role as Lindsay in Wet Hot American Summer for the
    Netflix miniseries Wet Hot American Summer : First Day of Camp .'
  - Instagram is a mobile , desktop , and internet-based photo-sharing application
    and service that allows users to share pictures and videos either publicly or
    privately .
  - Support for videos was originally launched in June 2013 , and had a 15-second
    maximum duration and limited quality , with Instagram later adding support for
    widescreen and longer videos .
pipeline_tag: sentence-similarity
library_name: sentence-transformers
---


# SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2

This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2). It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, classification, clustering, and more.

## Model Details

### Model Description
- **Model Type:** Sentence Transformer
- **Base model:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) <!-- at revision 1110a243fdf4706b3f48f1d95db1a4f5529b4d41 -->
- **Maximum Sequence Length:** 256 tokens
- **Output Dimensionality:** 384 dimensions
- **Similarity Function:** Cosine Similarity
- **Supported Modality:** Text
<!-- - **Training Dataset:** Unknown -->
<!-- - **Language:** Unknown -->
<!-- - **License:** Unknown -->

### Model Sources

- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
- **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)

### Full Model Architecture

```

SentenceTransformer(

  (0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})

  (1): Pooling({'embedding_dimension': 384, 'pooling_mode': 'mean', 'include_prompt': True})

  (2): Normalize({})

)

```

## Usage

### Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

```bash

pip install -U sentence-transformers

```
Then you can load this model and run inference.
```python

from sentence_transformers import SentenceTransformer



# Download from the 🤗 Hub

model = SentenceTransformer("sentence_transformers_model_id")

# Run inference

sentences = [

    'Instagram started supporting videos in 2015.',

    'Support for videos was originally launched in June 2013 , and had a 15-second maximum duration and limited quality , with Instagram later adding support for widescreen and longer videos .',

    'Instagram is a mobile , desktop , and internet-based photo-sharing application and service that allows users to share pictures and videos either publicly or privately .',

]

embeddings = model.encode(sentences)

print(embeddings.shape)

# [3, 384]



# Get the similarity scores for the embeddings

similarities = model.similarity(embeddings, embeddings)

print(similarities)

# tensor([[1.0000, 0.8020, 0.5034],

#         [0.8020, 1.0000, 0.5358],

#         [0.5034, 0.5358, 1.0000]])

```
<!--
### Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details>
-->

<!--
### Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details>
-->

<!--
### Out-of-Scope Use

*List how the model may foreseeably be misused and address what users ought not to do with the model.*
-->

<!--
## Bias, Risks and Limitations

*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
-->

<!--
### Recommendations

*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
-->

## Training Details

### Training Dataset

#### Unnamed Dataset

* Size: 4,555 training samples
* Columns: <code>sentence_0</code>, <code>sentence_1</code>, and <code>sentence_2</code>

* Approximate statistics based on the first 100 samples:

  |          | sentence_0                                                                        | sentence_1                                                                          | sentence_2                                                                         |
  |:---------|:----------------------------------------------------------------------------------|:------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|
  | type     | string                                                                            | string                                                                              | string                                                                             |
  | modality | text                                                                              | text                                                                                | text                                                                               |
  | details  | <ul><li>min: 6 tokens</li><li>mean: 11.45 tokens</li><li>max: 21 tokens</li></ul> | <ul><li>min: 13 tokens</li><li>mean: 37.74 tokens</li><li>max: 131 tokens</li></ul> | <ul><li>min: 9 tokens</li><li>mean: 35.88 tokens</li><li>max: 103 tokens</li></ul> |
* Samples:
  | sentence_0                                                           | sentence_1                                                                                                                                                                                                                                                    | sentence_2                                                                                                                                                                    |

  |:---------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

  | <code>Grace Jones performed in 1984 film Conan the Destroyer.</code> | <code>In 1984 she made her first mainstream appearance as Zula in the fantasy-action film Conan the Destroyer alongside Arnold Schwarzenegger and Sarah Douglas , and subsequently appeared in the 1985 James Bond movie A View to a Kill as May Day .</code> | <code>In 2008 , he played Henry `` Mutt Williams '' Jones III in Indiana Jones and the Kingdom of the Crystal Skull , the fourth film in the Indiana Jones franchise .</code> |

  | <code>Pornhub is a website for pornography.</code>                   | <code>Pornhub is a pornographic video sharing website and the largest pornography site on the Internet .</code>                                                                                                                                               | <code>There are contanious -LSB- sic -RSB- sexual scenes , abusive words , audio pornography and a bit sensitive touch about one particular section of society '' .</code>    |

  | <code>The Beatles were an English soccer team.</code>                | <code>In 2008 , the group topped Billboard magazine 's list of the all-time most successful `` Hot 100 '' artists ; , they hold the record for most number-one hits on the Hot 100 chart with twenty .</code>                                                 | <code>The Beatles were an English rock band formed in Liverpool in 1960 .</code>                                                                                              |

* Loss: [<code>MultipleNegativesRankingLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters:

  ```json

  {

      "scale": 20.0,

      "similarity_fct": "cos_sim",

      "gather_across_devices": false,

      "directions": [

          "query_to_doc"

      ],

      "partition_mode": "joint",
      "hardness_mode": null,

      "hardness_strength": 0.0

  }

  ```


### Training Hyperparameters
#### Non-Default Hyperparameters

- `per_device_train_batch_size`: 32
- `per_device_eval_batch_size`: 32
- `multi_dataset_batch_sampler`: round_robin



#### All Hyperparameters

<details><summary>Click to expand</summary>



- `per_device_train_batch_size`: 32

- `num_train_epochs`: 3

- `max_steps`: -1
- `learning_rate`: 5e-05
- `lr_scheduler_type`: linear
- `lr_scheduler_kwargs`: None
- `warmup_steps`: 0
- `optim`: adamw_torch_fused
- `optim_args`: None
- `weight_decay`: 0.0
- `adam_beta1`: 0.9
- `adam_beta2`: 0.999
- `adam_epsilon`: 1e-08
- `optim_target_modules`: None
- `gradient_accumulation_steps`: 1
- `average_tokens_across_devices`: True
- `max_grad_norm`: 1
- `label_smoothing_factor`: 0.0
- `bf16`: False
- `fp16`: False
- `bf16_full_eval`: False
- `fp16_full_eval`: False
- `tf32`: None
- `gradient_checkpointing`: False
- `gradient_checkpointing_kwargs`: None
- `torch_compile`: False
- `torch_compile_backend`: None
- `torch_compile_mode`: None
- `use_liger_kernel`: False
- `liger_kernel_config`: None
- `use_cache`: False
- `neftune_noise_alpha`: None
- `torch_empty_cache_steps`: None
- `auto_find_batch_size`: False
- `log_on_each_node`: True
- `logging_nan_inf_filter`: True
- `include_num_input_tokens_seen`: no
- `log_level`: passive
- `log_level_replica`: warning
- `disable_tqdm`: False
- `project`: huggingface
- `trackio_space_id`: None
- `trackio_bucket_id`: None
- `trackio_static_space_id`: None
- `per_device_eval_batch_size`: 32
- `prediction_loss_only`: True
- `eval_on_start`: False
- `eval_do_concat_batches`: True
- `eval_use_gather_object`: False
- `eval_accumulation_steps`: None
- `include_for_metrics`: []
- `batch_eval_metrics`: False
- `save_only_model`: False
- `save_on_each_node`: False
- `enable_jit_checkpoint`: False
- `push_to_hub`: False
- `hub_private_repo`: None
- `hub_model_id`: None
- `hub_strategy`: every_save

- `hub_always_push`: False

- `hub_revision`: None
- `load_best_model_at_end`: False
- `ignore_data_skip`: False
- `restore_callback_states_from_checkpoint`: False
- `full_determinism`: False
- `seed`: 42
- `data_seed`: None
- `use_cpu`: False
- `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
- `parallelism_config`: None
- `dataloader_drop_last`: False
- `dataloader_num_workers`: 0
- `dataloader_pin_memory`: True
- `dataloader_persistent_workers`: False
- `dataloader_prefetch_factor`: None
- `remove_unused_columns`: True
- `label_names`: None
- `train_sampling_strategy`: random
- `length_column_name`: length
- `ddp_find_unused_parameters`: None
- `ddp_bucket_cap_mb`: None
- `ddp_broadcast_buffers`: False
- `ddp_static_graph`: None
- `ddp_backend`: None
- `ddp_timeout`: 1800
- `fsdp`: None
- `fsdp_config`: None
- `deepspeed`: None
- `debug`: []
- `skip_memory_metrics`: True
- `do_predict`: False
- `resume_from_checkpoint`: None
- `warmup_ratio`: None
- `local_rank`: -1
- `prompts`: None
- `batch_sampler`: batch_sampler

- `multi_dataset_batch_sampler`: round_robin

- `router_mapping`: {}
- `learning_rate_mapping`: {}

</details>

### Training Time
- **Training**: 59.1 minutes

### Framework Versions
- Python: 3.13.7
- Sentence Transformers: 5.7.0
- Transformers: 5.14.1
- PyTorch: 2.13.0+cpu
- Accelerate: 1.14.0
- Datasets: 5.0.1
- Tokenizers: 0.22.2

## Additional Resources

- [Training and Finetuning Embedding Models with Sentence Transformers](https://huggingface.co/blog/train-sentence-transformers): the end-to-end guide for training or finetuning Sentence Transformer models.
- [Introduction to Matryoshka Embedding Models](https://huggingface.co/blog/matryoshka): variable-size embeddings that can be truncated with minimal quality loss.
- [Binary and Scalar Embedding Quantization for Significantly Faster & Cheaper Retrieval](https://huggingface.co/blog/embedding-quantization): post-training compression of embedding vectors.
- [Multimodal Embedding & Reranker Models with Sentence Transformers](https://huggingface.co/blog/multimodal-sentence-transformers): use text, image, audio, and video models through the same API.
- [Training and Finetuning Multimodal Embedding & Reranker Models with Sentence Transformers](https://huggingface.co/blog/train-multimodal-sentence-transformers): train multimodal embedding models, with a Visual Document Retrieval walkthrough.

## Citation

### BibTeX

#### Sentence Transformers
```bibtex

@inproceedings{reimers-2019-sentence-bert,

    title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",

    author = "Reimers, Nils and Gurevych, Iryna",

    booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",

    month = "11",

    year = "2019",

    publisher = "Association for Computational Linguistics",

    url = "https://arxiv.org/abs/1908.10084",

}

```

#### MultipleNegativesRankingLoss
```bibtex

@misc{oord2019representationlearningcontrastivepredictive,

      title={Representation Learning with Contrastive Predictive Coding},

      author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},

      year={2019},

      eprint={1807.03748},

      archivePrefix={arXiv},

      primaryClass={cs.LG},

      url={https://arxiv.org/abs/1807.03748},

}

```

<!--
## Glossary

*Clearly define terms in order to be accessible across audiences.*
-->

<!--
## Model Card Authors

*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
-->

<!--
## Model Card Contact

*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
-->