Husain's picture
Add new SentenceTransformer model.
31a3b85 verified
---
base_model: sentence-transformers/all-MiniLM-L6-v2
datasets:
- sentence-transformers/stsb
language:
- en
library_name: sentence-transformers
metrics:
- pearson_cosine
- spearman_cosine
- pearson_manhattan
- spearman_manhattan
- pearson_euclidean
- spearman_euclidean
- pearson_dot
- spearman_dot
- pearson_max
- spearman_max
pipeline_tag: sentence-similarity
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:101
- loss:CoSENTLoss
widget:
- source_sentence: The man is slicing a potato.
sentences:
- A woman is slicing carrot.
- Two women are singing.
- A man is slicing potato.
- source_sentence: A girl is playing a flute.
sentences:
- A woman stirs eggs in a bowl.
- A girl plays a wind instrument.
- A man is turning over tables in anger.
- source_sentence: People are playing baseball.
sentences:
- The cricket player hit the ball.
- A man breaks a stick.
- A woman is pouring a yellow mixture on a frying pan.
- source_sentence: A woman and man are riding in a car.
sentences:
- A woman driving a car is talking to the man seated beside her.
- A woman is placing skewered food onto a cooker.
- The man and woman are walking.
- source_sentence: A cat is on a robot.
sentences:
- A man is eating bread.
- A woman is pouring eyes into a bowl.
- A boy sits on a bed, sings and plays a guitar.
model-index:
- name: SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2
results:
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts dev
type: sts-dev
metrics:
- type: pearson_cosine
value: 0.9186522039312566
name: Pearson Cosine
- type: spearman_cosine
value: 0.9276278198564623
name: Spearman Cosine
- type: pearson_manhattan
value: 0.8991493568260668
name: Pearson Manhattan
- type: spearman_manhattan
value: 0.9320766471557739
name: Spearman Manhattan
- type: pearson_euclidean
value: 0.9014580823459483
name: Pearson Euclidean
- type: spearman_euclidean
value: 0.9289530024562572
name: Spearman Euclidean
- type: pearson_dot
value: 0.8789190604301875
name: Pearson Dot
- type: spearman_dot
value: 0.8957287815613981
name: Spearman Dot
- type: pearson_max
value: 0.9186522039312566
name: Pearson Max
- type: spearman_max
value: 0.9320766471557739
name: Spearman Max
---
# 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, text 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 8b3219a92973c328a8e22fadcfa821b5dc75636a -->
- **Maximum Sequence Length:** 512 tokens
- **Output Dimensionality:** 384 tokens
- **Similarity Function:** Cosine Similarity
<!-- - **Training Dataset:** Unknown -->
- **Language:** en
<!-- - **License:** Unknown -->
### Model Sources
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co./models?library=sentence-transformers)
### Full Model Architecture
```
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)
```
## 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("Husain/ramdam_fingerprint_embedding_model")
# Run inference
sentences = [
'A cat is on a robot.',
'A man is eating bread.',
'A woman is pouring eyes into a bowl.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
```
<!--
### 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.*
-->
## Evaluation
### Metrics
#### Semantic Similarity
* Dataset: `sts-dev`
* Evaluated with [<code>EmbeddingSimilarityEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator)
| Metric | Value |
|:--------------------|:-----------|
| pearson_cosine | 0.9187 |
| **spearman_cosine** | **0.9276** |
| pearson_manhattan | 0.8991 |
| spearman_manhattan | 0.9321 |
| pearson_euclidean | 0.9015 |
| spearman_euclidean | 0.929 |
| pearson_dot | 0.8789 |
| spearman_dot | 0.8957 |
| pearson_max | 0.9187 |
| spearman_max | 0.9321 |
<!--
## 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: 101 training samples
* Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
* Approximate statistics based on the first 101 samples:
| | sentence1 | sentence2 | score |
|:--------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------|
| type | string | string | float |
| details | <ul><li>min: 7 tokens</li><li>mean: 9.44 tokens</li><li>max: 14 tokens</li></ul> | <ul><li>min: 3 tokens</li><li>mean: 9.46 tokens</li><li>max: 15 tokens</li></ul> | <ul><li>min: 0.1</li><li>mean: 0.66</li><li>max: 1.0</li></ul> |
* Samples:
| sentence1 | sentence2 | score |
|:-----------------------------------------------------------|:----------------------------------------------------------------------|:------------------|
| <code>A plane is taking off.</code> | <code>An air plane is taking off.</code> | <code>1.0</code> |
| <code>A man is playing a large flute.</code> | <code>A man is playing a flute.</code> | <code>0.76</code> |
| <code>A man is spreading shreded cheese on a pizza.</code> | <code>A man is spreading shredded cheese on an uncooked pizza.</code> | <code>0.76</code> |
* Loss: [<code>CoSENTLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
```json
{
"scale": 20.0,
"similarity_fct": "pairwise_cos_sim"
}
```
### Evaluation Dataset
#### stsb
* Dataset: [stsb](https://huggingface.co./datasets/sentence-transformers/stsb) at [ab7a5ac](https://huggingface.co./datasets/sentence-transformers/stsb/tree/ab7a5ac0e35aa22088bdcf23e7fd99b220e53308)
* Size: 1,500 evaluation samples
* Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
* Approximate statistics based on the first 1000 samples:
| | sentence1 | sentence2 | score |
|:--------|:---------------------------------------------------------------------------------|:--------------------------------------------------------------------------------|:---------------------------------------------------------------|
| type | string | string | float |
| details | <ul><li>min: 6 tokens</li><li>mean: 9.35 tokens</li><li>max: 13 tokens</li></ul> | <ul><li>min: 7 tokens</li><li>mean: 9.9 tokens</li><li>max: 16 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.39</li><li>max: 1.0</li></ul> |
* Samples:
| sentence1 | sentence2 | score |
|:-----------------------------------------------|:----------------------------------------------------|:------------------|
| <code>A woman is riding on a horse.</code> | <code>A man is turning over tables in anger.</code> | <code>0.0</code> |
| <code>A man is screwing wood to a wall.</code> | <code>A man is giving a woman a massage.</code> | <code>0.04</code> |
| <code>A girl is playing a flute.</code> | <code>A girl plays a wind instrument.</code> | <code>0.64</code> |
* Loss: [<code>CoSENTLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
```json
{
"scale": 20.0,
"similarity_fct": "pairwise_cos_sim"
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: steps
- `learning_rate`: 2e-05
- `num_train_epochs`: 10
- `warmup_ratio`: 0.1
- `save_only_model`: True
- `seed`: 33
- `fp16`: True
- `load_best_model_at_end`: True
#### All Hyperparameters
<details><summary>Click to expand</summary>
- `overwrite_output_dir`: False
- `do_predict`: False
- `eval_strategy`: steps
- `prediction_loss_only`: True
- `per_device_train_batch_size`: 8
- `per_device_eval_batch_size`: 8
- `per_gpu_train_batch_size`: None
- `per_gpu_eval_batch_size`: None
- `gradient_accumulation_steps`: 1
- `eval_accumulation_steps`: None
- `torch_empty_cache_steps`: None
- `learning_rate`: 2e-05
- `weight_decay`: 0.0
- `adam_beta1`: 0.9
- `adam_beta2`: 0.999
- `adam_epsilon`: 1e-08
- `max_grad_norm`: 1.0
- `num_train_epochs`: 10
- `max_steps`: -1
- `lr_scheduler_type`: linear
- `lr_scheduler_kwargs`: {}
- `warmup_ratio`: 0.1
- `warmup_steps`: 0
- `log_level`: passive
- `log_level_replica`: warning
- `log_on_each_node`: True
- `logging_nan_inf_filter`: True
- `save_safetensors`: True
- `save_on_each_node`: False
- `save_only_model`: True
- `restore_callback_states_from_checkpoint`: False
- `no_cuda`: False
- `use_cpu`: False
- `use_mps_device`: False
- `seed`: 33
- `data_seed`: None
- `jit_mode_eval`: False
- `use_ipex`: False
- `bf16`: False
- `fp16`: True
- `fp16_opt_level`: O1
- `half_precision_backend`: auto
- `bf16_full_eval`: False
- `fp16_full_eval`: False
- `tf32`: None
- `local_rank`: 0
- `ddp_backend`: None
- `tpu_num_cores`: None
- `tpu_metrics_debug`: False
- `debug`: []
- `dataloader_drop_last`: False
- `dataloader_num_workers`: 0
- `dataloader_prefetch_factor`: None
- `past_index`: -1
- `disable_tqdm`: False
- `remove_unused_columns`: True
- `label_names`: None
- `load_best_model_at_end`: True
- `ignore_data_skip`: False
- `fsdp`: []
- `fsdp_min_num_params`: 0
- `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
- `fsdp_transformer_layer_cls_to_wrap`: None
- `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
- `deepspeed`: None
- `label_smoothing_factor`: 0.0
- `optim`: adamw_torch
- `optim_args`: None
- `adafactor`: False
- `group_by_length`: False
- `length_column_name`: length
- `ddp_find_unused_parameters`: None
- `ddp_bucket_cap_mb`: None
- `ddp_broadcast_buffers`: False
- `dataloader_pin_memory`: True
- `dataloader_persistent_workers`: False
- `skip_memory_metrics`: True
- `use_legacy_prediction_loop`: False
- `push_to_hub`: False
- `resume_from_checkpoint`: None
- `hub_model_id`: None
- `hub_strategy`: every_save
- `hub_private_repo`: False
- `hub_always_push`: False
- `gradient_checkpointing`: False
- `gradient_checkpointing_kwargs`: None
- `include_inputs_for_metrics`: False
- `eval_do_concat_batches`: True
- `fp16_backend`: auto
- `push_to_hub_model_id`: None
- `push_to_hub_organization`: None
- `mp_parameters`:
- `auto_find_batch_size`: False
- `full_determinism`: False
- `torchdynamo`: None
- `ray_scope`: last
- `ddp_timeout`: 1800
- `torch_compile`: False
- `torch_compile_backend`: None
- `torch_compile_mode`: None
- `dispatch_batches`: None
- `split_batches`: None
- `include_tokens_per_second`: False
- `include_num_input_tokens_seen`: False
- `neftune_noise_alpha`: None
- `optim_target_modules`: None
- `batch_eval_metrics`: False
- `eval_on_start`: False
- `eval_use_gather_object`: False
- `batch_sampler`: batch_sampler
- `multi_dataset_batch_sampler`: proportional
</details>
### Training Logs
| Epoch | Step | loss | sts-dev_spearman_cosine |
|:--------:|:-------:|:----------:|:-----------------------:|
| 0.1538 | 2 | 4.4641 | 0.9366 |
| 0.3077 | 4 | 4.4652 | 0.9366 |
| 0.4615 | 6 | 4.4719 | 0.9366 |
| 0.6154 | 8 | 4.4903 | 0.9366 |
| 0.7692 | 10 | 4.5264 | 0.9373 |
| 0.9231 | 12 | 4.5954 | 0.9339 |
| 1.0769 | 14 | 4.6832 | 0.9328 |
| 1.2308 | 16 | 4.7534 | 0.9289 |
| 1.3846 | 18 | 4.8155 | 0.9281 |
| 1.5385 | 20 | 4.8788 | 0.9269 |
| 1.6923 | 22 | 4.9350 | 0.9272 |
| 1.8462 | 24 | 4.9789 | 0.9239 |
| 2.0 | 26 | 5.0132 | 0.9230 |
| 2.1538 | 28 | 5.0636 | 0.9237 |
| 2.3077 | 30 | 5.1068 | 0.9202 |
| 2.4615 | 32 | 5.1460 | 0.9172 |
| 2.6154 | 34 | 5.1602 | 0.9164 |
| 2.7692 | 36 | 5.1493 | 0.9210 |
| 2.9231 | 38 | 5.1399 | 0.9200 |
| 3.0769 | 40 | 5.1342 | 0.9235 |
| 3.2308 | 42 | 5.1413 | 0.9258 |
| 3.3846 | 44 | 5.1440 | 0.9271 |
| 3.5385 | 46 | 5.1583 | 0.9311 |
| 3.6923 | 48 | 5.1664 | 0.9293 |
| 3.8462 | 50 | 5.1682 | 0.9293 |
| 4.0 | 52 | 5.1617 | 0.9293 |
| 4.1538 | 54 | 5.1543 | 0.9293 |
| 4.3077 | 56 | 5.1480 | 0.9293 |
| 4.4615 | 58 | 5.1428 | 0.9291 |
| 4.6154 | 60 | 5.1292 | 0.9298 |
| 4.7692 | 62 | 5.1271 | 0.9276 |
| 4.9231 | 64 | 5.1133 | 0.9276 |
| 5.0769 | 66 | 5.0928 | 0.9270 |
| 5.2308 | 68 | 5.0874 | 0.9270 |
| 5.3846 | 70 | 5.0755 | 0.9270 |
| 5.5385 | 72 | 5.0665 | 0.9270 |
| 5.6923 | 74 | 5.0676 | 0.9293 |
| 5.8462 | 76 | 5.0747 | 0.9293 |
| 6.0 | 78 | 5.0647 | 0.9295 |
| 6.1538 | 80 | 5.0763 | 0.9273 |
| 6.3077 | 82 | 5.0832 | 0.9272 |
| 6.4615 | 84 | 5.0750 | 0.9289 |
| 6.6154 | 86 | 5.0547 | 0.9289 |
| 6.7692 | 88 | 5.0350 | 0.9308 |
| 6.9231 | 90 | 5.0221 | 0.9308 |
| 7.0769 | 92 | 5.0107 | 0.9308 |
| 7.2308 | 94 | 4.9967 | 0.9297 |
| 7.3846 | 96 | 4.9983 | 0.9297 |
| 7.5385 | 98 | 5.0026 | 0.9277 |
| 7.6923 | 100 | 5.0095 | 0.9277 |
| 7.8462 | 102 | 5.0102 | 0.9277 |
| 8.0 | 104 | 5.0055 | 0.9271 |
| 8.1538 | 106 | 5.0031 | 0.9271 |
| 8.3077 | 108 | 4.9976 | 0.9271 |
| 8.4615 | 110 | 4.9941 | 0.9271 |
| 8.6154 | 112 | 4.9856 | 0.9276 |
| 8.7692 | 114 | 4.9821 | 0.9276 |
| 8.9231 | 116 | 4.9782 | 0.9276 |
| 9.0769 | 118 | 4.9706 | 0.9276 |
| 9.2308 | 120 | 4.9646 | 0.9276 |
| 9.3846 | 122 | 4.9584 | 0.9276 |
| 9.5385 | 124 | 4.9537 | 0.9276 |
| 9.6923 | 126 | 4.9499 | 0.9276 |
| 9.8462 | 128 | 4.9485 | 0.9276 |
| **10.0** | **130** | **4.9463** | **0.9276** |
* The bold row denotes the saved checkpoint.
### Framework Versions
- Python: 3.8.10
- Sentence Transformers: 3.1.0
- Transformers: 4.44.2
- PyTorch: 2.3.1+cu121
- Accelerate: 0.34.2
- Datasets: 3.0.0
- Tokenizers: 0.19.1
## 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",
}
```
#### CoSENTLoss
```bibtex
@online{kexuefm-8847,
title={CoSENT: A more efficient sentence vector scheme than Sentence-BERT},
author={Su Jianlin},
year={2022},
month={Jan},
url={https://kexue.fm/archives/8847},
}
```
<!--
## 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.*
-->