---
base_model: microsoft/mpnet-base
datasets:
- sentence-transformers/all-nli
language:
- en
library_name: sentence-transformers
license: apache-2.0
metrics:
- cosine_accuracy
- dot_accuracy
- manhattan_accuracy
- euclidean_accuracy
- max_accuracy
pipeline_tag: sentence-similarity
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:100000
- loss:MultipleNegativesRankingLoss
widget:
- source_sentence: People on bicycles waiting at an intersection.
sentences:
- More than one person on a bicycle is obeying traffic laws.
- The people are on skateboards.
- People waiting at a light on bikes.
- source_sentence: A dog is in the water.
sentences:
- A white dog with brown spots standing in water.
- A woman in a white outfit holds her purse while on a crowded bus.
- A wakeboarder is traveling across the water behind a ramp.
- source_sentence: The people are sleeping.
sentences:
- A man and young boy asleep in a chair.
- A father and his son cuddle while sleeping.
- Several people are sitting on the back of a truck outside.
- source_sentence: A dog is swimming.
sentences:
- A brown god relaxes on a brick sidewalk.
- The furry brown dog is swimming in the ocean.
- a black dog swimming in the water with a tennis ball in his mouth
- source_sentence: A dog is swimming.
sentences:
- A woman in all black throws a football indoors while man looks at his cellphone
in the background.
- A white dog with a stick in his mouth standing next to a black dog.
- A dog with yellow fur swims, neck deep, in water.
model-index:
- name: MPNet base trained on AllNLI triplets
results:
- task:
type: triplet
name: Triplet
dataset:
name: all nli dev
type: all-nli-dev
metrics:
- type: cosine_accuracy
value: 0.9059842041312273
name: Cosine Accuracy
- type: dot_accuracy
value: 0.09386391251518833
name: Dot Accuracy
- type: manhattan_accuracy
value: 0.900820170109356
name: Manhattan Accuracy
- type: euclidean_accuracy
value: 0.9017314702308628
name: Euclidean Accuracy
- type: max_accuracy
value: 0.9059842041312273
name: Max Accuracy
- task:
type: triplet
name: Triplet
dataset:
name: all nli test
type: all-nli-test
metrics:
- type: cosine_accuracy
value: 0.9185958541382963
name: Cosine Accuracy
- type: dot_accuracy
value: 0.08019367529126949
name: Dot Accuracy
- type: manhattan_accuracy
value: 0.9142078983204721
name: Manhattan Accuracy
- type: euclidean_accuracy
value: 0.9142078983204721
name: Euclidean Accuracy
- type: max_accuracy
value: 0.9185958541382963
name: Max Accuracy
---
# MPNet base trained on AllNLI triplets
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [microsoft/mpnet-base](https://huggingface.co/microsoft/mpnet-base) on the [sentence-transformers/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 tokens
- **Similarity Function:** Cosine Similarity
- **Training Dataset:**
- [sentence-transformers/all-nli](https://huggingface.co/datasets/sentence-transformers/all-nli)
- **Language:** en
- **License:** apache-2.0
### 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("korruz/mpnet-base-all-nli-triplet")
# Run inference
sentences = [
'A dog is swimming.',
'A dog with yellow fur swims, neck deep, in water.',
'A white dog with a stick in his mouth standing next to a black dog.',
]
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
#### Triplet
* Dataset: `all-nli-dev`
* Evaluated with [TripletEvaluator
](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.TripletEvaluator)
| Metric | Value |
|:-------------------|:----------|
| cosine_accuracy | 0.906 |
| dot_accuracy | 0.0939 |
| manhattan_accuracy | 0.9008 |
| euclidean_accuracy | 0.9017 |
| **max_accuracy** | **0.906** |
#### Triplet
* Dataset: `all-nli-test`
* Evaluated with [TripletEvaluator
](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.TripletEvaluator)
| Metric | Value |
|:-------------------|:-----------|
| cosine_accuracy | 0.9186 |
| dot_accuracy | 0.0802 |
| manhattan_accuracy | 0.9142 |
| euclidean_accuracy | 0.9142 |
| **max_accuracy** | **0.9186** |
## Training Details
### Training Dataset
#### sentence-transformers/all-nli
* Dataset: [sentence-transformers/all-nli](https://huggingface.co/datasets/sentence-transformers/all-nli) at [d482672](https://huggingface.co/datasets/sentence-transformers/all-nli/tree/d482672c8e74ce18da116f430137434ba2e52fab)
* Size: 100,000 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: [MultipleNegativesRankingLoss
](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters:
```json
{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: steps
- `per_device_train_batch_size`: 16
- `per_device_eval_batch_size`: 16
- `learning_rate`: 2e-05
- `num_train_epochs`: 1
- `warmup_ratio`: 0.1
- `fp16`: True
- `batch_sampler`: no_duplicates
#### All Hyperparameters