How to use from the
Use from the
sentence-transformers library
from sentence_transformers import SentenceTransformer

model = SentenceTransformer("Mossie96/all-mpnet-base-v2_distilled_3_layers_1-5-10")

sentences = [
    "At an outdoor event in an Asian-themed area, a crowd congregates as one person in a yellow Chinese dragon costume confronts the camera.",
    "Boy dressed in blue holds a toy.",
    "the animal is running",
    "Two young asian men are squatting."
]
embeddings = model.encode(sentences)

similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]

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 = [
    'A black dog is drinking next to a brown and white dog that is looking at an orange ball in the lake, whilst a horse and rider passes behind.',
    'There are two people running around a track in lane three and the one wearing a blue shirt with a green thing over the eyes is just barely ahead of the guy wearing an orange shirt and sunglasses.',
    'the guy is dead',
]
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 sts-test
pearson_cosine 0.8659 0.8309
spearman_cosine 0.8685 0.8339

Knowledge Distillation

Metric Value
negative_mse -0.0158

Training Details

Training Dataset

Unnamed Dataset

  • Size: 9,014,210 training samples
  • Columns: sentence and label
  • Approximate statistics based on the first 1000 samples:
    sentence label
    type string list
    details
    • min: 4 tokens
    • mean: 12.24 tokens
    • max: 52 tokens
    • size: 768 elements
  • Samples:
    sentence label
    A person on a horse jumps over a broken down airplane. [-0.030610017478466034, 0.11742044985294342, 0.031586047261953354, 0.01859636977314949, 0.016319412738084793, ...]
    Children smiling and waving at camera [-0.006198188289999962, -0.036625951528549194, -0.005352460313588381, -0.006725294981151819, 0.05185901001095772, ...]
    A boy is jumping on skateboard in the middle of a red bridge. [-0.01783316768705845, -0.05204763263463974, -0.003716366598382592, 0.0009472182719036937, 0.05223219841718674, ...]
  • Loss: MSELoss

Evaluation Dataset

Unnamed Dataset

  • Size: 10,000 evaluation samples
  • Columns: sentence and label
  • Approximate statistics based on the first 1000 samples:
    sentence label
    type string list
    details
    • min: 5 tokens
    • mean: 13.23 tokens
    • max: 57 tokens
    • size: 768 elements
  • Samples:
    sentence label
    Two women are embracing while holding to go packages. [0.010130808688700199, 0.009573593735694885, -0.00034817546838894486, -0.0040625291876494884, 0.02026110142469406, ...]
    Two young children in blue jerseys, one with the number 9 and one with the number 2 are standing on wooden steps in a bathroom and washing their hands in a sink. [-0.033891696482896805, -0.04130887985229492, -0.006042165216058493, -0.02770376019179821, -0.0017171527724713087, ...]
    A man selling donuts to a customer during a world exhibition event held in the city of Angeles [0.0013940087519586086, -0.044612932950258255, -0.023834265768527985, 0.11863800883293152, -0.03907289728522301, ...]
  • Loss: MSELoss

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 64
  • per_device_eval_batch_size: 64
  • learning_rate: 0.0001
  • num_train_epochs: 1
  • warmup_ratio: 0.1
  • fp16: True
  • load_best_model_at_end: True

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 64
  • per_device_eval_batch_size: 64
  • 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: 0.0001
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1.0
  • num_train_epochs: 1
  • 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: 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: 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}
  • tp_size: 0
  • 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
  • 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: proportional

Training Logs

Click to expand
Epoch Step Training Loss Validation Loss sts-dev_spearman_cosine negative_mse sts-test_spearman_cosine
-1 -1 - - 0.6786 -0.2176 -
0.0071 1000 0.0016 - - - -
0.0142 2000 0.001 - - - -
0.0213 3000 0.0008 - - - -
0.0284 4000 0.0007 - - - -
0.0355 5000 0.0006 0.0006 0.8511 -0.0561 -
0.0426 6000 0.0006 - - - -
0.0497 7000 0.0005 - - - -
0.0568 8000 0.0005 - - - -
0.0639 9000 0.0005 - - - -
0.0710 10000 0.0004 0.0004 0.8624 -0.0361 -
0.0781 11000 0.0004 - - - -
0.0852 12000 0.0004 - - - -
0.0923 13000 0.0004 - - - -
0.0994 14000 0.0004 - - - -
0.1065 15000 0.0003 0.0003 0.8649 -0.0288 -
0.1136 16000 0.0003 - - - -
0.1207 17000 0.0003 - - - -
0.1278 18000 0.0003 - - - -
0.1349 19000 0.0003 - - - -
0.1420 20000 0.0003 0.0003 0.8663 -0.0252 -
0.1491 21000 0.0003 - - - -
0.1562 22000 0.0003 - - - -
0.1633 23000 0.0003 - - - -
0.1704 24000 0.0003 - - - -
0.1775 25000 0.0003 0.0002 0.8641 -0.0232 -
0.1846 26000 0.0003 - - - -
0.1917 27000 0.0003 - - - -
0.1988 28000 0.0003 - - - -
0.2059 29000 0.0003 - - - -
0.2130 30000 0.0003 0.0002 0.8641 -0.0219 -
0.2201 31000 0.0003 - - - -
0.2272 32000 0.0003 - - - -
0.2343 33000 0.0003 - - - -
0.2414 34000 0.0003 - - - -
0.2485 35000 0.0003 0.0002 0.8649 -0.0209 -
0.2556 36000 0.0003 - - - -
0.2627 37000 0.0003 - - - -
0.2698 38000 0.0003 - - - -
0.2769 39000 0.0003 - - - -
0.2840 40000 0.0003 0.0002 0.8648 -0.0202 -
0.2911 41000 0.0003 - - - -
0.2982 42000 0.0002 - - - -
0.3053 43000 0.0002 - - - -
0.3124 44000 0.0002 - - - -
0.3195 45000 0.0002 0.0002 0.8663 -0.0196 -
0.3266 46000 0.0002 - - - -
0.3337 47000 0.0002 - - - -
0.3408 48000 0.0002 - - - -
0.3479 49000 0.0002 - - - -
0.3550 50000 0.0002 0.0002 0.8665 -0.0192 -
0.3621 51000 0.0002 - - - -
0.3692 52000 0.0002 - - - -
0.3763 53000 0.0002 - - - -
0.3834 54000 0.0002 - - - -
0.3905 55000 0.0002 0.0002 0.8650 -0.0187 -
0.3976 56000 0.0002 - - - -
0.4047 57000 0.0002 - - - -
0.4118 58000 0.0002 - - - -
0.4189 59000 0.0002 - - - -
0.4260 60000 0.0002 0.0002 0.8636 -0.0184 -
0.4331 61000 0.0002 - - - -
0.4402 62000 0.0002 - - - -
0.4473 63000 0.0002 - - - -
0.4544 64000 0.0002 - - - -
0.4615 65000 0.0002 0.0002 0.8673 -0.0180 -
0.4686 66000 0.0002 - - - -
0.4757 67000 0.0002 - - - -
0.4828 68000 0.0002 - - - -
0.4899 69000 0.0002 - - - -
0.4970 70000 0.0002 0.0002 0.8692 -0.0178 -
0.5041 71000 0.0002 - - - -
0.5112 72000 0.0002 - - - -
0.5183 73000 0.0002 - - - -
0.5254 74000 0.0002 - - - -
0.5325 75000 0.0002 0.0002 0.8675 -0.0175 -
0.5396 76000 0.0002 - - - -
0.5467 77000 0.0002 - - - -
0.5538 78000 0.0002 - - - -
0.5609 79000 0.0002 - - - -
0.5680 80000 0.0002 0.0002 0.8657 -0.0173 -
0.5751 81000 0.0002 - - - -
0.5822 82000 0.0002 - - - -
0.5893 83000 0.0002 - - - -
0.5964 84000 0.0002 - - - -
0.6035 85000 0.0002 0.0002 0.8670 -0.0171 -
0.6106 86000 0.0002 - - - -
0.6177 87000 0.0002 - - - -
0.6248 88000 0.0002 - - - -
0.6319 89000 0.0002 - - - -
0.6390 90000 0.0002 0.0002 0.8665 -0.0169 -
0.6461 91000 0.0002 - - - -
0.6532 92000 0.0002 - - - -
0.6603 93000 0.0002 - - - -
0.6674 94000 0.0002 - - - -
0.6745 95000 0.0002 0.0002 0.8672 -0.0167 -
0.6816 96000 0.0002 - - - -
0.6887 97000 0.0002 - - - -
0.6958 98000 0.0002 - - - -
0.7029 99000 0.0002 - - - -
0.7100 100000 0.0002 0.0002 0.8657 -0.0165 -
0.7171 101000 0.0002 - - - -
0.7242 102000 0.0002 - - - -
0.7313 103000 0.0002 - - - -
0.7384 104000 0.0002 - - - -
0.7455 105000 0.0002 0.0002 0.8676 -0.0165 -
0.7526 106000 0.0002 - - - -
0.7597 107000 0.0002 - - - -
0.7668 108000 0.0002 - - - -
0.7739 109000 0.0002 - - - -
0.7810 110000 0.0002 0.0002 0.8672 -0.0164 -
0.7881 111000 0.0002 - - - -
0.7952 112000 0.0002 - - - -
0.8023 113000 0.0002 - - - -
0.8094 114000 0.0002 - - - -
0.8165 115000 0.0002 0.0002 0.8698 -0.0162 -
0.8236 116000 0.0002 - - - -
0.8307 117000 0.0002 - - - -
0.8378 118000 0.0002 - - - -
0.8449 119000 0.0002 - - - -
0.8520 120000 0.0002 0.0002 0.8685 -0.0161 -
0.8591 121000 0.0002 - - - -
0.8662 122000 0.0002 - - - -
0.8733 123000 0.0002 - - - -
0.8804 124000 0.0002 - - - -
0.8875 125000 0.0002 0.0002 0.8676 -0.0160 -
0.8946 126000 0.0002 - - - -
0.9017 127000 0.0002 - - - -
0.9088 128000 0.0002 - - - -
0.9159 129000 0.0002 - - - -
0.9230 130000 0.0002 0.0002 0.8682 -0.0159 -
0.9301 131000 0.0002 - - - -
0.9372 132000 0.0002 - - - -
0.9443 133000 0.0002 - - - -
0.9514 134000 0.0002 - - - -
0.9585 135000 0.0002 0.0002 0.8678 -0.0158 -
0.9656 136000 0.0002 - - - -
0.9727 137000 0.0002 - - - -
0.9798 138000 0.0002 - - - -
0.9869 139000 0.0002 - - - -
0.9940 140000 0.0002 0.0002 0.8685 -0.0158 -
-1 -1 - - - - 0.8339
  • The bold row denotes the saved checkpoint.

Framework Versions

  • Python: 3.11.11
  • Sentence Transformers: 4.1.0
  • Transformers: 4.51.3
  • PyTorch: 2.7.1+cu118
  • Accelerate: 1.7.0
  • Datasets: 3.3.2
  • Tokenizers: 0.21.1

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",
}

MSELoss

@inproceedings{reimers-2020-multilingual-sentence-bert,
    title = "Making Monolingual Sentence Embeddings Multilingual using Knowledge Distillation",
    author = "Reimers, Nils and Gurevych, Iryna",
    booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing",
    month = "11",
    year = "2020",
    publisher = "Association for Computational Linguistics",
    url = "https://arxiv.org/abs/2004.09813",
}
Downloads last month
2
Safetensors
Model size
45.7M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Mossie96/all-mpnet-base-v2_distilled_3_layers_1-5-10

Finetuned
(378)
this model

Papers for Mossie96/all-mpnet-base-v2_distilled_3_layers_1-5-10

Evaluation results