software-15 / README.md
csjo24003's picture
Upload folder using huggingface_hub
a865019 verified
---
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:5749
- loss:CosineSimilarityLoss
base_model: sentence-transformers/all-mpnet-base-v2
widget:
- source_sentence: Young woman in riding gear on top of horse.
sentences:
- Italy’s centre-left splinters in presidential vote
- The woman is riding on the brown horse.
- Mali's Interim President Sworn Into Office
- source_sentence: Sony reports record annual loss
sentences:
- A woman is playing a flute.
- A man and a woman kiss.
- Sony forecasts record annual loss of $6.4bn
- source_sentence: A clear plastic chair in front of a bookcase.
sentences:
- Allen defends self against Farrow's abuse claims
- Ehud Olmert sentenced to six years in Israel
- a clear plastic chair in front of book shelves.
- source_sentence: KLCI Futures traded mixed at mid-day
sentences:
- KL shares mixed at mid-day
- NATO helicopter makes hard landing in E. Afghanistan
- Sewol ferry crew faces trial
- source_sentence: We in Britain think differently to Americans.
sentences:
- south korea has had a bullet train system since the 1980s.
- Originally Posted by zaf We in Britain think differently to Americans.
- Car bombings kill 13 civilians in Iraqi capital
pipeline_tag: sentence-similarity
library_name: sentence-transformers
metrics:
- pearson_cosine
- spearman_cosine
model-index:
- name: SentenceTransformer based on sentence-transformers/all-mpnet-base-v2
results:
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: Unknown
type: unknown
metrics:
- type: pearson_cosine
value: 0.9075334661878893
name: Pearson Cosine
- type: spearman_cosine
value: 0.9060484206473507
name: Spearman Cosine
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts dev
type: sts-dev
metrics:
- type: pearson_cosine
value: 0.9075334589342524
name: Pearson Cosine
- type: spearman_cosine
value: 0.9060484206473507
name: Spearman Cosine
---
# SentenceTransformer based on sentence-transformers/all-mpnet-base-v2
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2). It maps sentences & paragraphs to a 768-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-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2) <!-- at revision 9a3225965996d404b775526de6dbfe85d3368642 -->
- **Maximum Sequence Length:** 384 tokens
- **Output Dimensionality:** 768 dimensions
- **Similarity Function:** Cosine Similarity
<!-- - **Training Dataset:** Unknown -->
<!-- - **Language:** Unknown -->
<!-- - **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': 384, 'do_lower_case': False}) with Transformer model: MPNetModel
(1): Pooling({'word_embedding_dimension': 768, '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})
(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 = [
'We in Britain think differently to Americans.',
'Originally Posted by zaf We in Britain think differently to Americans.',
'south korea has had a bullet train system since the 1980s.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# 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
* Datasets: `` and `sts-dev`
* Evaluated with [<code>EmbeddingSimilarityEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator)
| Metric | | sts-dev |
|:--------------------|:----------|:----------|
| pearson_cosine | 0.9075 | 0.9075 |
| **spearman_cosine** | **0.906** | **0.906** |
<!--
## 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: 5,749 training samples
* Columns: <code>sentence_0</code>, <code>sentence_1</code>, and <code>label</code>
* Approximate statistics based on the first 1000 samples:
| | sentence_0 | sentence_1 | label |
|:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------|
| type | string | string | float |
| details | <ul><li>min: 6 tokens</li><li>mean: 14.16 tokens</li><li>max: 45 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 14.18 tokens</li><li>max: 49 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.54</li><li>max: 1.0</li></ul> |
* Samples:
| sentence_0 | sentence_1 | label |
|:----------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------|:--------------------------------|
| <code>US Senate to vote on fiscal cliff deal as deadline nears</code> | <code>Fiscal cliff: House delays vote on fiscal cliff deal - live</code> | <code>0.5599999904632569</code> |
| <code>This is America, my friends, and it should not happen here," he said to loud applause.</code> | <code>"This is America, my friends, and it should not happen here."</code> | <code>0.65</code> |
| <code>Books To Help Kids Talk About Boston Marathon News</code> | <code>Report of two explosions at finish line of Boston Marathon</code> | <code>0.1600000023841858</code> |
* Loss: [<code>CosineSimilarityLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosinesimilarityloss) with these parameters:
```json
{
"loss_fct": "torch.nn.modules.loss.MSELoss"
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: steps
- `per_device_train_batch_size`: 32
- `per_device_eval_batch_size`: 32
- `num_train_epochs`: 10
- `multi_dataset_batch_sampler`: round_robin
#### 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`: 32
- `per_device_eval_batch_size`: 32
- `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`: 5e-05
- `weight_decay`: 0.0
- `adam_beta1`: 0.9
- `adam_beta2`: 0.999
- `adam_epsilon`: 1e-08
- `max_grad_norm`: 1
- `num_train_epochs`: 10
- `max_steps`: -1
- `lr_scheduler_type`: linear
- `lr_scheduler_kwargs`: {}
- `warmup_ratio`: 0.0
- `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`: False
- `restore_callback_states_from_checkpoint`: False
- `no_cuda`: False
- `use_cpu`: False
- `use_mps_device`: False
- `seed`: 42
- `data_seed`: None
- `jit_mode_eval`: False
- `use_ipex`: False
- `bf16`: False
- `fp16`: False
- `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`: False
- `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`: None
- `hub_always_push`: False
- `gradient_checkpointing`: False
- `gradient_checkpointing_kwargs`: None
- `include_inputs_for_metrics`: False
- `include_for_metrics`: []
- `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
- `use_liger_kernel`: False
- `eval_use_gather_object`: False
- `average_tokens_across_devices`: False
- `prompts`: None
- `batch_sampler`: batch_sampler
- `multi_dataset_batch_sampler`: round_robin
</details>
### Training Logs
<details><summary>Click to expand</summary>
| Epoch | Step | Training Loss | spearman_cosine | sts-dev_spearman_cosine |
|:------:|:----:|:-------------:|:---------------:|:-----------------------:|
| 0 | 0 | - | 0.8811 | - |
| 0.1 | 18 | - | - | 0.8816 |
| 0.2 | 36 | - | - | 0.8834 |
| 0.3 | 54 | - | - | 0.8847 |
| 0.4 | 72 | - | - | 0.8894 |
| 0.5 | 90 | - | - | 0.8933 |
| 0.6 | 108 | - | - | 0.8966 |
| 0.7 | 126 | - | - | 0.9005 |
| 0.8 | 144 | - | - | 0.9020 |
| 0.9 | 162 | - | - | 0.9010 |
| 1.0 | 180 | - | - | 0.9001 |
| 1.1 | 198 | - | - | 0.9022 |
| 1.2 | 216 | - | - | 0.9018 |
| 1.3 | 234 | - | - | 0.9015 |
| 1.4 | 252 | - | - | 0.9029 |
| 1.5 | 270 | - | - | 0.9044 |
| 1.6 | 288 | - | - | 0.9049 |
| 1.7 | 306 | - | - | 0.9051 |
| 1.8 | 324 | - | - | 0.9033 |
| 1.9 | 342 | - | - | 0.9039 |
| 2.0 | 360 | - | - | 0.9050 |
| 2.1 | 378 | - | - | 0.9042 |
| 2.2 | 396 | - | - | 0.9041 |
| 2.3 | 414 | - | - | 0.9040 |
| 2.4 | 432 | - | - | 0.9048 |
| 2.5 | 450 | - | - | 0.9045 |
| 2.6 | 468 | - | - | 0.9046 |
| 2.7 | 486 | - | - | 0.9047 |
| 2.7778 | 500 | 0.0153 | - | - |
| 2.8 | 504 | - | - | 0.9057 |
| 2.9 | 522 | - | - | 0.9065 |
| 3.0 | 540 | - | - | 0.9074 |
| 3.1 | 558 | - | - | 0.9073 |
| 3.2 | 576 | - | - | 0.9065 |
| 3.3 | 594 | - | - | 0.9046 |
| 3.4 | 612 | - | - | 0.9057 |
| 3.5 | 630 | - | - | 0.9069 |
| 3.6 | 648 | - | - | 0.9062 |
| 3.7 | 666 | - | - | 0.9061 |
| 3.8 | 684 | - | - | 0.9050 |
| 3.9 | 702 | - | - | 0.9050 |
| 4.0 | 720 | - | - | 0.9048 |
| 4.1 | 738 | - | - | 0.9052 |
| 4.2 | 756 | - | - | 0.9055 |
| 4.3 | 774 | - | - | 0.9060 |
| 4.4 | 792 | - | - | 0.9059 |
| 4.5 | 810 | - | - | 0.9064 |
| 4.6 | 828 | - | - | 0.9063 |
| 4.7 | 846 | - | - | 0.9063 |
| 4.8 | 864 | - | - | 0.9067 |
| 4.9 | 882 | - | - | 0.9059 |
| 5.0 | 900 | - | - | 0.9052 |
| 5.1 | 918 | - | - | 0.9061 |
| 5.2 | 936 | - | - | 0.9057 |
| 5.3 | 954 | - | - | 0.9053 |
| 5.4 | 972 | - | - | 0.9060 |
| 5.5 | 990 | - | - | 0.9050 |
| 5.5556 | 1000 | 0.0051 | - | - |
| 5.6 | 1008 | - | - | 0.9053 |
| 5.7 | 1026 | - | - | 0.9052 |
| 5.8 | 1044 | - | - | 0.9056 |
| 5.9 | 1062 | - | - | 0.9062 |
| 6.0 | 1080 | - | - | 0.9056 |
| 6.1 | 1098 | - | - | 0.9054 |
| 6.2 | 1116 | - | - | 0.9058 |
| 6.3 | 1134 | - | - | 0.9058 |
| 6.4 | 1152 | - | - | 0.9056 |
| 6.5 | 1170 | - | - | 0.9057 |
| 6.6 | 1188 | - | - | 0.9055 |
| 6.7 | 1206 | - | - | 0.9055 |
| 6.8 | 1224 | - | - | 0.9053 |
| 6.9 | 1242 | - | - | 0.9053 |
| 7.0 | 1260 | - | - | 0.9053 |
| 7.1 | 1278 | - | - | 0.9057 |
| 7.2 | 1296 | - | - | 0.9055 |
| 7.3 | 1314 | - | - | 0.9053 |
| 7.4 | 1332 | - | - | 0.9056 |
| 7.5 | 1350 | - | - | 0.9059 |
| 7.6 | 1368 | - | - | 0.9060 |
| 7.7 | 1386 | - | - | 0.9057 |
| 7.8 | 1404 | - | - | 0.9058 |
| 7.9 | 1422 | - | - | 0.9057 |
| 8.0 | 1440 | - | - | 0.9058 |
| 8.1 | 1458 | - | - | 0.9059 |
| 8.2 | 1476 | - | - | 0.9060 |
| 8.3 | 1494 | - | - | 0.9056 |
| 8.3333 | 1500 | 0.0031 | - | - |
| 8.4 | 1512 | - | - | 0.9057 |
| 8.5 | 1530 | - | - | 0.9060 |
| 8.6 | 1548 | - | - | 0.9058 |
| 8.7 | 1566 | - | - | 0.9060 |
| 8.8 | 1584 | - | - | 0.9062 |
| 8.9 | 1602 | - | - | 0.9061 |
| 9.0 | 1620 | - | - | 0.9061 |
| 9.1 | 1638 | - | - | 0.9061 |
| 9.2 | 1656 | - | - | 0.9059 |
| 9.3 | 1674 | - | - | 0.9060 |
| 9.4 | 1692 | - | - | 0.9061 |
| 9.5 | 1710 | - | - | 0.9061 |
| 9.6 | 1728 | - | - | 0.9061 |
| 9.7 | 1746 | - | - | 0.9060 |
| 9.8 | 1764 | - | - | 0.9061 |
| 9.9 | 1782 | - | - | 0.9061 |
| 10.0 | 1800 | - | 0.9060 | 0.9060 |
</details>
### Framework Versions
- Python: 3.10.12
- Sentence Transformers: 3.3.1
- Transformers: 4.47.1
- PyTorch: 2.5.1+cu121
- Accelerate: 1.2.1
- Datasets: 3.2.0
- Tokenizers: 0.21.0
## 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",
}
```
<!--
## 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.*
-->