---
language:
- en
library_name: sentence-transformers
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- loss:MSELoss
base_model: nreimers/TinyBERT_L-4_H-312_v2
metrics:
- pearson_cosine
- spearman_cosine
- pearson_manhattan
- spearman_manhattan
- pearson_euclidean
- spearman_euclidean
- pearson_dot
- spearman_dot
- pearson_max
- spearman_max
- negative_mse
widget:
- source_sentence: A woman at home.
sentences:
- The woman is inside.
- The woman is performing for an audience.
- The two men are freinds
- source_sentence: boys play football
sentences:
- Rival college football players are playing a football game.
- A man looks at his watch at a bus stop.
- A woman walking on an old bridge near a mountain.
- source_sentence: Nobody has a pot
sentences:
- Nobody has a suit
- A woman riding a bicycle on the street.
- The front is decorated with Ethiopian themes and motifs.
- source_sentence: A dog plays ball.
sentences:
- A dog with a ball.
- A man looking into a microscope in a lab
- Children go past their parents.
- source_sentence: A person standing
sentences:
- There is a person standing outside
- A young man plays a racing video game.
- Two children playing on the floor with toy trains.
pipeline_tag: sentence-similarity
co2_eq_emissions:
emissions: 3.457859864142588
energy_consumed: 0.00889591477312334
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: 0.054
hardware_used: 1 x NVIDIA GeForce RTX 3090
model-index:
- name: SentenceTransformer based on nreimers/TinyBERT_L-4_H-312_v2
results:
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts dev
type: sts-dev
metrics:
- type: pearson_cosine
value: 0.8077673131159315
name: Pearson Cosine
- type: spearman_cosine
value: 0.8208863013753134
name: Spearman Cosine
- type: pearson_manhattan
value: 0.8225516575982812
name: Pearson Manhattan
- type: spearman_manhattan
value: 0.8203236078973807
name: Spearman Manhattan
- type: pearson_euclidean
value: 0.8215663439432439
name: Pearson Euclidean
- type: spearman_euclidean
value: 0.8202318953605339
name: Spearman Euclidean
- type: pearson_dot
value: 0.7901487535994149
name: Pearson Dot
- type: spearman_dot
value: 0.7914362691291718
name: Spearman Dot
- type: pearson_max
value: 0.8225516575982812
name: Pearson Max
- type: spearman_max
value: 0.8208863013753134
name: Spearman Max
- task:
type: knowledge-distillation
name: Knowledge Distillation
dataset:
name: Unknown
type: unknown
metrics:
- type: negative_mse
value: -50.125449895858765
name: Negative Mse
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts test
type: sts-test
metrics:
- type: pearson_cosine
value: 0.7516961775809978
name: Pearson Cosine
- type: spearman_cosine
value: 0.7558402072520215
name: Spearman Cosine
- type: pearson_manhattan
value: 0.7762734499549059
name: Pearson Manhattan
- type: spearman_manhattan
value: 0.75965556867712
name: Spearman Manhattan
- type: pearson_euclidean
value: 0.7705568379382428
name: Pearson Euclidean
- type: spearman_euclidean
value: 0.7553604477247078
name: Spearman Euclidean
- type: pearson_dot
value: 0.7306801501272192
name: Pearson Dot
- type: spearman_dot
value: 0.7097993872384684
name: Spearman Dot
- type: pearson_max
value: 0.7762734499549059
name: Pearson Max
- type: spearman_max
value: 0.75965556867712
name: Spearman Max
---
# SentenceTransformer based on nreimers/TinyBERT_L-4_H-312_v2
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [nreimers/TinyBERT_L-4_H-312_v2](https://huggingface.co/nreimers/TinyBERT_L-4_H-312_v2) on the [sentence-transformers/wikipedia-en-sentences](https://huggingface.co/datasets/sentence-transformers/wikipedia-en-sentences) dataset. It maps sentences & paragraphs to a 312-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:** [nreimers/TinyBERT_L-4_H-312_v2](https://huggingface.co/nreimers/TinyBERT_L-4_H-312_v2)
- **Maximum Sequence Length:** 512 tokens
- **Output Dimensionality:** 312 tokens
- **Similarity Function:** Cosine Similarity
- **Training Dataset:**
- [sentence-transformers/wikipedia-en-sentences](https://huggingface.co/datasets/sentence-transformers/wikipedia-en-sentences)
- **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: BertModel
(1): Pooling({'word_embedding_dimension': 312, '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/TinyBERT_L-4_H-312_v2-distilled-from-stsb-roberta-base-v2")
# Run inference
sentences = [
'A person standing',
'There is a person standing outside',
'A young man plays a racing video game.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 312]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings)
print(similarities.shape)
# [3, 3]
```
## Evaluation
### Metrics
#### Semantic Similarity
* Dataset: `sts-dev`
* Evaluated with [EmbeddingSimilarityEvaluator
](https://sbert.net/docs/package_reference/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator)
| Metric | Value |
|:--------------------|:-----------|
| pearson_cosine | 0.8078 |
| **spearman_cosine** | **0.8209** |
| pearson_manhattan | 0.8226 |
| spearman_manhattan | 0.8203 |
| pearson_euclidean | 0.8216 |
| spearman_euclidean | 0.8202 |
| pearson_dot | 0.7901 |
| spearman_dot | 0.7914 |
| pearson_max | 0.8226 |
| spearman_max | 0.8209 |
#### Knowledge Distillation
* Evaluated with [MSEEvaluator
](https://sbert.net/docs/package_reference/evaluation.html#sentence_transformers.evaluation.MSEEvaluator)
| Metric | Value |
|:-----------------|:-------------|
| **negative_mse** | **-50.1254** |
#### Semantic Similarity
* Dataset: `sts-test`
* Evaluated with [EmbeddingSimilarityEvaluator
](https://sbert.net/docs/package_reference/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator)
| Metric | Value |
|:--------------------|:-----------|
| pearson_cosine | 0.7517 |
| **spearman_cosine** | **0.7558** |
| pearson_manhattan | 0.7763 |
| spearman_manhattan | 0.7597 |
| pearson_euclidean | 0.7706 |
| spearman_euclidean | 0.7554 |
| pearson_dot | 0.7307 |
| spearman_dot | 0.7098 |
| pearson_max | 0.7763 |
| spearman_max | 0.7597 |
## Training Details
### Training Dataset
#### sentence-transformers/wikipedia-en-sentences
* Dataset: [sentence-transformers/wikipedia-en-sentences](https://huggingface.co/datasets/sentence-transformers/wikipedia-en-sentences) at [4a0972d](https://huggingface.co/datasets/sentence-transformers/wikipedia-en-sentences/tree/4a0972dcb781b5b5d27799798f032606421dd422)
* Size: 200,000 training samples
* Columns: sentence
and label
* Approximate statistics based on the first 1000 samples:
| | sentence | label |
|:--------|:----------------------------------------------------------------------------------|:-------------------------------------|
| type | string | list |
| details |
A person on a horse jumps over a broken down airplane.
| [-0.09614687412977219, 0.6815224885940552, 2.702199935913086, 1.8371250629425049, -1.2949433326721191, ...]
|
| Children smiling and waving at camera
| [2.769360303878784, 3.074428081512451, -7.291755676269531, 5.248741149902344, 2.85081148147583, ...]
|
| A boy is jumping on skateboard in the middle of a red bridge.
| [-3.0669667720794678, 2.9899890422821045, -1.253997802734375, 6.15218448638916, 0.5838223099708557, ...]
|
* Loss: [MSELoss
](https://sbert.net/docs/package_reference/losses.html#mseloss)
### Evaluation Dataset
#### sentence-transformers/wikipedia-en-sentences
* Dataset: [sentence-transformers/wikipedia-en-sentences](https://huggingface.co/datasets/sentence-transformers/wikipedia-en-sentences) at [4a0972d](https://huggingface.co/datasets/sentence-transformers/wikipedia-en-sentences/tree/4a0972dcb781b5b5d27799798f032606421dd422)
* Size: 10,000 evaluation samples
* Columns: sentence
and label
* Approximate statistics based on the first 1000 samples:
| | sentence | label |
|:--------|:----------------------------------------------------------------------------------|:-------------------------------------|
| type | string | list |
| details | Two women are embracing while holding to go packages.
| [6.200135707855225, -2.0865142345428467, -2.1313390731811523, -1.9593913555145264, -1.081985592842102, ...]
|
| 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.
| [1.7725015878677368, 0.6873414516448975, -2.5191268920898438, 3.866339683532715, 2.853647470474243, ...]
|
| A man selling donuts to a customer during a world exhibition event held in the city of Angeles
| [-3.317653179168701, 3.0908589363098145, 0.1683920919895172, -2.4405274391174316, -3.1366524696350098, ...]
|
* Loss: [MSELoss
](https://sbert.net/docs/package_reference/losses.html#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