---
language:
- en
license: apache-2.0
tags:
- sentence-transformers
- sparse-encoder
- sparse
- splade
- generated_from_trainer
- dataset_size:10000
- loss:SpladeLoss
- loss:SparseMultipleNegativesRankingLoss
- loss:FlopsLoss
base_model: naver/splade-cocondenser-ensembledistil
widget:
- text: Two kids at a ballgame wash their hands.
- text: Two dogs near a lake, while a person rides by on a horse.
- text: This mother and her daughter and granddaughter are having car trouble, and
the poor little girl looks hot out in the heat.
- text: A young man competes in the Olympics in the pole vaulting competition.
- text: A man is playing with the brass pots
datasets:
- sentence-transformers/all-nli
pipeline_tag: feature-extraction
library_name: sentence-transformers
metrics:
- pearson_cosine
- spearman_cosine
- active_dims
- sparsity_ratio
co2_eq_emissions:
emissions: 0.16583474956305416
energy_consumed: 0.0029592738907377744
source: codecarbon
training_type: fine-tuning
on_cloud: false
cpu_model: AMD Ryzen 9 6900HX with Radeon Graphics
ram_total_size: 30.6114501953125
hours_used: 0.025
hardware_used: 1 x NVIDIA GeForce RTX 3070 Ti Laptop GPU
model-index:
- name: splade-cocondenser-ensembledistil trained on Natural Language Inference (NLI)
results:
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts dev
type: sts-dev
metrics:
- type: pearson_cosine
value: 0.8553775938865431
name: Pearson Cosine
- type: spearman_cosine
value: 0.8486465022828363
name: Spearman Cosine
- type: active_dims
value: 99.12466812133789
name: Active Dims
- type: sparsity_ratio
value: 0.9967523534459951
name: Sparsity Ratio
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts test
type: sts-test
metrics:
- type: pearson_cosine
value: 0.8223180736705796
name: Pearson Cosine
- type: spearman_cosine
value: 0.8068358333807579
name: Spearman Cosine
- type: active_dims
value: 95.42276763916016
name: Active Dims
- type: sparsity_ratio
value: 0.9968736397470952
name: Sparsity Ratio
---
# splade-cocondenser-ensembledistil trained on Natural Language Inference (NLI)
This is a [SPLADE Sparse Encoder](https://www.sbert.net/docs/sparse_encoder/usage/usage.html) model finetuned from [naver/splade-cocondenser-ensembledistil](https://huggingface.co/naver/splade-cocondenser-ensembledistil) on the [all-nli](https://huggingface.co/datasets/sentence-transformers/all-nli) dataset using the [sentence-transformers](https://www.SBERT.net) library. It maps sentences & paragraphs to a 30522-dimensional sparse vector space and can be used for semantic search and sparse retrieval.
## Model Details
### Model Description
- **Model Type:** SPLADE Sparse Encoder
- **Base model:** [naver/splade-cocondenser-ensembledistil](https://huggingface.co/naver/splade-cocondenser-ensembledistil)
- **Maximum Sequence Length:** 256 tokens
- **Output Dimensionality:** 30522 dimensions
- **Similarity Function:** Dot Product
- **Training Dataset:**
- [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)
- **Documentation:** [Sparse Encoder Documentation](https://www.sbert.net/docs/sparse_encoder/usage/usage.html)
- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
- **Hugging Face:** [Sparse Encoders on Hugging Face](https://huggingface.co/models?library=sentence-transformers&other=sparse-encoder)
### Full Model Architecture
```
SparseEncoder(
(0): MLMTransformer({'max_seq_length': 256, 'do_lower_case': False}) with MLMTransformer model: BertForMaskedLM
(1): SpladePooling({'pooling_strategy': 'max', 'activation_function': 'relu', 'word_embedding_dimension': 30522})
)
```
## 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 SparseEncoder
# Download from the 🤗 Hub
model = SparseEncoder("arthurbresnu/example-splade-cocondenser-ensembledistil-nli")
# Run inference
sentences = [
'A man is sitting in on the side of the street with brass pots.',
'A man is playing with the brass pots',
'A group of adults are swimming at the beach.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# (3, 30522)
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
```
## Evaluation
### Metrics
#### Semantic Similarity
* Datasets: `sts-dev` and `sts-test`
* Evaluated with [SparseEmbeddingSimilarityEvaluator
](https://sbert.net/docs/package_reference/sparse_encoder/evaluation.html#sentence_transformers.sparse_encoder.evaluation.SparseEmbeddingSimilarityEvaluator)
| Metric | sts-dev | sts-test |
|:--------------------|:-----------|:-----------|
| pearson_cosine | 0.8554 | 0.8223 |
| **spearman_cosine** | **0.8486** | **0.8068** |
| active_dims | 99.1247 | 95.4228 |
| sparsity_ratio | 0.9968 | 0.9969 |
## 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: 10,000 training samples
* Columns: sentence1
, sentence2
, and score
* Approximate statistics based on the first 1000 samples:
| | sentence1 | sentence2 | score |
|:--------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:--------------------------------------------------------------|
| type | string | string | float |
| details |
A person on a horse jumps over a broken down airplane.
| A person is training his horse for a competition.
| 0.5
|
| A person on a horse jumps over a broken down airplane.
| A person is at a diner, ordering an omelette.
| 0.0
|
| A person on a horse jumps over a broken down airplane.
| A person is outdoors, on a horse.
| 1.0
|
* Loss: [SpladeLoss
](https://sbert.net/docs/package_reference/sparse_encoder/losses.html#spladeloss) with these parameters:
```json
{
"loss": "SparseMultipleNegativesRankingLoss(scale=1, similarity_fct='dot_score')",
"lambda_corpus": 0.003
}
```
### 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: 1,000 evaluation samples
* Columns: sentence1
, sentence2
, and score
* Approximate statistics based on the first 1000 samples:
| | sentence1 | sentence2 | score |
|:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:--------------------------------------------------------------|
| type | string | string | float |
| details | Two women are embracing while holding to go packages.
| The sisters are hugging goodbye while holding to go packages after just eating lunch.
| 0.5
|
| Two women are embracing while holding to go packages.
| Two woman are holding packages.
| 1.0
|
| Two women are embracing while holding to go packages.
| The men are fighting outside a deli.
| 0.0
|
* Loss: [SpladeLoss
](https://sbert.net/docs/package_reference/sparse_encoder/losses.html#spladeloss) with these parameters:
```json
{
"loss": "SparseMultipleNegativesRankingLoss(scale=1, similarity_fct='dot_score')",
"lambda_corpus": 0.003
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: steps
- `per_device_train_batch_size`: 16
- `per_device_eval_batch_size`: 16
- `learning_rate`: 4e-06
- `num_train_epochs`: 1
- `bf16`: True
- `load_best_model_at_end`: True
- `batch_sampler`: no_duplicates
#### All Hyperparameters