---
language:
- en
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:557850
- loss:MatryoshkaLoss
- loss:MultipleNegativesRankingLoss
base_model: microsoft/mpnet-base
widget:
- source_sentence: A man is jumping unto his filthy bed.
sentences:
- A young male is looking at a newspaper while 2 females walks past him.
- The bed is dirty.
- The man is on the moon.
- source_sentence: A carefully balanced male stands on one foot near a clean ocean
beach area.
sentences:
- A man is ouside near the beach.
- Three policemen patrol the streets on bikes
- A man is sitting on his couch.
- source_sentence: The man is wearing a blue shirt.
sentences:
- Near the trashcan the man stood and smoked
- A man in a blue shirt leans on a wall beside a road with a blue van and red car
with water in the background.
- A man in a black shirt is playing a guitar.
- source_sentence: The girls are outdoors.
sentences:
- Two girls riding on an amusement part ride.
- a guy laughs while doing laundry
- Three girls are standing together in a room, one is listening, one is writing
on a wall and the third is talking to them.
- source_sentence: A construction worker peeking out of a manhole while his coworker
sits on the sidewalk smiling.
sentences:
- A worker is looking out of a manhole.
- A man is giving a presentation.
- The workers are both inside the manhole.
datasets:
- sentence-transformers/all-nli
pipeline_tag: sentence-similarity
library_name: sentence-transformers
metrics:
- pearson_cosine
- spearman_cosine
co2_eq_emissions:
emissions: 205.739032893975
energy_consumed: 0.5292975927419334
source: codecarbon
training_type: fine-tuning
on_cloud: false
cpu_model: 13th Gen Intel(R) Core(TM) i7-13700K
ram_total_size: 31.777088165283203
hours_used: 2.452
hardware_used: 1 x NVIDIA GeForce RTX 3090
model-index:
- name: SentenceTransformer based on microsoft/mpnet-base
results:
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts dev 768
type: sts-dev-768
metrics:
- type: pearson_cosine
value: 0.8427806843466507
name: Pearson Cosine
- type: spearman_cosine
value: 0.8508672705970183
name: Spearman Cosine
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts dev 512
type: sts-dev-512
metrics:
- type: pearson_cosine
value: 0.8402650019702758
name: Pearson Cosine
- type: spearman_cosine
value: 0.8492501196021981
name: Spearman Cosine
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts dev 256
type: sts-dev-256
metrics:
- type: pearson_cosine
value: 0.8346871892249894
name: Pearson Cosine
- type: spearman_cosine
value: 0.8462852114011874
name: Spearman Cosine
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts dev 128
type: sts-dev-128
metrics:
- type: pearson_cosine
value: 0.8258126981506843
name: Pearson Cosine
- type: spearman_cosine
value: 0.8396442287070809
name: Spearman Cosine
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts dev 64
type: sts-dev-64
metrics:
- type: pearson_cosine
value: 0.8133510090549183
name: Pearson Cosine
- type: spearman_cosine
value: 0.8314093123007742
name: Spearman Cosine
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts test 768
type: sts-test-768
metrics:
- type: pearson_cosine
value: 0.8189065344720828
name: Pearson Cosine
- type: spearman_cosine
value: 0.8358553875433253
name: Spearman Cosine
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts test 512
type: sts-test-512
metrics:
- type: pearson_cosine
value: 0.8185683063331012
name: Pearson Cosine
- type: spearman_cosine
value: 0.8361687236813662
name: Spearman Cosine
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts test 256
type: sts-test-256
metrics:
- type: pearson_cosine
value: 0.8129602938883278
name: Pearson Cosine
- type: spearman_cosine
value: 0.8332021961323041
name: Spearman Cosine
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts test 128
type: sts-test-128
metrics:
- type: pearson_cosine
value: 0.8030325360463209
name: Pearson Cosine
- type: spearman_cosine
value: 0.826154869627039
name: Spearman Cosine
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts test 64
type: sts-test-64
metrics:
- type: pearson_cosine
value: 0.7903762214352186
name: Pearson Cosine
- type: spearman_cosine
value: 0.8193971659006509
name: Spearman Cosine
---
# SentenceTransformer based on microsoft/mpnet-base
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [microsoft/mpnet-base](https://huggingface.co/microsoft/mpnet-base) on the [all-nli](https://huggingface.co/datasets/sentence-transformers/all-nli) dataset. 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:** [microsoft/mpnet-base](https://huggingface.co/microsoft/mpnet-base)
- **Maximum Sequence Length:** 512 tokens
- **Output Dimensionality:** 768 dimensions
- **Similarity Function:** Cosine Similarity
- **Training Dataset:**
- [all-nli](https://huggingface.co/datasets/sentence-transformers/all-nli)
- **Language:** en
### 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: 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})
)
```
## 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("tomaarsen/mpnet-base-nli-matryoshka-reproduced")
# Run inference
sentences = [
'A construction worker peeking out of a manhole while his coworker sits on the sidewalk smiling.',
'A worker is looking out of a manhole.',
'The workers are both inside the manhole.',
]
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
* Datasets: `sts-dev-768` and `sts-test-768`
* Evaluated with [EmbeddingSimilarityEvaluator
](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator) with these parameters:
```json
{
"truncate_dim": 768
}
```
| Metric | sts-dev-768 | sts-test-768 |
|:--------------------|:------------|:-------------|
| pearson_cosine | 0.8428 | 0.8189 |
| **spearman_cosine** | **0.8509** | **0.8359** |
#### Semantic Similarity
* Datasets: `sts-dev-512` and `sts-test-512`
* Evaluated with [EmbeddingSimilarityEvaluator
](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator) with these parameters:
```json
{
"truncate_dim": 512
}
```
| Metric | sts-dev-512 | sts-test-512 |
|:--------------------|:------------|:-------------|
| pearson_cosine | 0.8403 | 0.8186 |
| **spearman_cosine** | **0.8493** | **0.8362** |
#### Semantic Similarity
* Datasets: `sts-dev-256` and `sts-test-256`
* Evaluated with [EmbeddingSimilarityEvaluator
](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator) with these parameters:
```json
{
"truncate_dim": 256
}
```
| Metric | sts-dev-256 | sts-test-256 |
|:--------------------|:------------|:-------------|
| pearson_cosine | 0.8347 | 0.813 |
| **spearman_cosine** | **0.8463** | **0.8332** |
#### Semantic Similarity
* Datasets: `sts-dev-128` and `sts-test-128`
* Evaluated with [EmbeddingSimilarityEvaluator
](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator) with these parameters:
```json
{
"truncate_dim": 128
}
```
| Metric | sts-dev-128 | sts-test-128 |
|:--------------------|:------------|:-------------|
| pearson_cosine | 0.8258 | 0.803 |
| **spearman_cosine** | **0.8396** | **0.8262** |
#### Semantic Similarity
* Datasets: `sts-dev-64` and `sts-test-64`
* Evaluated with [EmbeddingSimilarityEvaluator
](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator) with these parameters:
```json
{
"truncate_dim": 64
}
```
| Metric | sts-dev-64 | sts-test-64 |
|:--------------------|:-----------|:------------|
| pearson_cosine | 0.8134 | 0.7904 |
| **spearman_cosine** | **0.8314** | **0.8194** |
## Training Details
### Training Dataset
#### all-nli
* Dataset: [all-nli](https://huggingface.co/datasets/sentence-transformers/all-nli) at [d482672](https://huggingface.co/datasets/sentence-transformers/all-nli/tree/d482672c8e74ce18da116f430137434ba2e52fab)
* Size: 557,850 training samples
* Columns: anchor
, positive
, and negative
* Approximate statistics based on the first 1000 samples:
| | anchor | positive | negative |
|:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|
| type | string | string | string |
| details |
A person on a horse jumps over a broken down airplane.
| A person is outdoors, on a horse.
| A person is at a diner, ordering an omelette.
|
| Children smiling and waving at camera
| There are children present
| The kids are frowning
|
| A boy is jumping on skateboard in the middle of a red bridge.
| The boy does a skateboarding trick.
| The boy skates down the sidewalk.
|
* Loss: [MatryoshkaLoss
](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#matryoshkaloss) with these parameters:
```json
{
"loss": "MultipleNegativesRankingLoss",
"matryoshka_dims": [
768,
512,
256,
128,
64
],
"matryoshka_weights": [
1,
1,
1,
1,
1
],
"n_dims_per_step": -1
}
```
### Evaluation Dataset
#### all-nli
* Dataset: [all-nli](https://huggingface.co/datasets/sentence-transformers/all-nli) at [d482672](https://huggingface.co/datasets/sentence-transformers/all-nli/tree/d482672c8e74ce18da116f430137434ba2e52fab)
* Size: 6,584 evaluation samples
* Columns: anchor
, positive
, and negative
* Approximate statistics based on the first 1000 samples:
| | anchor | positive | negative |
|:--------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|
| type | string | string | string |
| details | Two women are embracing while holding to go packages.
| Two woman are holding packages.
| The men are fighting outside a deli.
|
| 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.
| Two kids in numbered jerseys wash their hands.
| Two kids in jackets walk to school.
|
| A man selling donuts to a customer during a world exhibition event held in the city of Angeles
| A man selling donuts to a customer.
| A woman drinks her coffee in a small cafe.
|
* Loss: [MatryoshkaLoss
](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#matryoshkaloss) with these parameters:
```json
{
"loss": "MultipleNegativesRankingLoss",
"matryoshka_dims": [
768,
512,
256,
128,
64
],
"matryoshka_weights": [
1,
1,
1,
1,
1
],
"n_dims_per_step": -1
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: steps
- `per_device_train_batch_size`: 16
- `per_device_eval_batch_size`: 16
- `num_train_epochs`: 1
- `warmup_ratio`: 0.1
- `fp16`: True
- `batch_sampler`: no_duplicates
#### All Hyperparameters