SentenceTransformer based on sentence-transformers/all-mpnet-base-v2

This is a sentence-transformers model finetuned from 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
  • Maximum Sequence Length: 384 tokens
  • Output Dimensionality: 768 dimensions
  • Similarity Function: Cosine Similarity

Model Sources

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:

pip install -U sentence-transformers

Then you can load this model and run inference.

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]

Evaluation

Metrics

Semantic Similarity

Metric sts-dev
pearson_cosine 0.9075 0.9075
spearman_cosine 0.906 0.906

Training Details

Training Dataset

Unnamed Dataset

  • Size: 5,749 training samples
  • Columns: sentence_0, sentence_1, and label
  • Approximate statistics based on the first 1000 samples:
    sentence_0 sentence_1 label
    type string string float
    details
    • min: 6 tokens
    • mean: 14.16 tokens
    • max: 45 tokens
    • min: 5 tokens
    • mean: 14.18 tokens
    • max: 49 tokens
    • min: 0.0
    • mean: 0.54
    • max: 1.0
  • Samples:
    sentence_0 sentence_1 label
    US Senate to vote on fiscal cliff deal as deadline nears Fiscal cliff: House delays vote on fiscal cliff deal - live 0.5599999904632569
    This is America, my friends, and it should not happen here," he said to loud applause. "This is America, my friends, and it should not happen here." 0.65
    Books To Help Kids Talk About Boston Marathon News Report of two explosions at finish line of Boston Marathon 0.1600000023841858
  • Loss: CosineSimilarityLoss with these parameters:
    {
        "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

Click to expand
  • 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

Training Logs

Click to expand
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

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

@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",
}
Downloads last month
4
Safetensors
Model size
109M params
Tensor type
F32
·
Inference Providers NEW
This model is not currently available via any of the supported third-party Inference Providers, and the model is not deployed on the HF Inference API.

Model tree for csjo24003/software-15

Finetuned
(212)
this model

Evaluation results