Team Ai
Modelpublic

rasyosef/splade-small

sourceHugging Facemitupdated 5mo agoView on Hugging Face
2likes415downloads
Model Card

SPLADE-Small

This is a SPLADE sparse retrieval model based on BERT-Small (29M) that was trained by distilling a Cross-Encoder on the MSMARCO dataset. The cross-encoder used was ms-marco-MiniLM-L6-v2.

This SPLADE model is 2x smaller than Naver's official splade-v3-distilbert while having 91% of it's performance on the MSMARCO benchmark. This model is small enough to be used without a GPU on a dataset of a few thousand documents.

  • β€”Collection: https://huggingface.co/collections/rasyosef/splade-tiny-msmarco-687c548c0691d95babf65b70
  • β€”Distillation Dataset: https://huggingface.co/datasets/yosefw/msmarco-train-distil-v2
  • β€”Code: https://github.com/rasyosef/splade-tiny-msmarco

Performance

The splade models were evaluated on 55 thousand queries and 8.84 million documents from the MSMARCO dataset.

Size (# Params)MRR@10 (MS MARCO dev)
BM25-18.0--
rasyosef/splade-tiny4.4M30.9
rasyosef/splade-mini11.2M34.1
rasyosef/splade-small28.8M35.4
naver/splade-v3-distilbert67.0M38.7

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("rasyosef/splade-small")
# Run inference
queries = [
    "how many tablespoons of garlic powder are in an ounce",
]
documents = [
    '1 Fluid Ounce (fl oz) = 2 tablespoons   16 Tablespoons = 1 cup   16 Fluid Ounce (fl oz) = 2 cup. two ! 9.7 grams of garlic powder will be present in a tablespoon. 1 dry ounce is between 2 and 2.38 tablespoons, 16 tablespoons is incorrect. --------------------- 16 tablespoons per dry ounce. It is approximately 1/2 ounce. Usually 1/4 to 1/2 tsp.',
    'Spices, garlic powder weigh(s) 164 gram per (metric cup) or 5.47 ounce per (US cup)',
    'How many teaspoons of garlic powder equal a clove of garlic? Weigh the garlic clove and then weigh the garlic powder to make sure it is the same weight. That is how much powder equals a clove of garlic.',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 30522] [3, 30522]

# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[26.3104, 20.4381, 15.5539]])

Model Details

Model Description

  • β€”Model Type: SPLADE Sparse Encoder
  • β€”Base model: prajjwal1/bert-small
  • β€”Maximum Sequence Length: 512 tokens
  • β€”Output Dimensionality: 30522 dimensions
  • β€”Similarity Function: Dot Product <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

SparseEncoder(
  (0): MLMTransformer({'max_seq_length': 512, 'do_lower_case': False, 'architecture': 'BertForMaskedLM'})
  (1): SpladePooling({'pooling_strategy': 'max', 'activation_function': 'relu', 'word_embedding_dimension': 30522})
)

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

More

<details><summary>Click to expand</summary>

Evaluation

Metrics

Sparse Information Retrieval
MetricValue
dot_accuracy@10.4547
dot_accuracy@30.7685
dot_accuracy@50.8786
dot_accuracy@100.9484
dot_precision@10.4547
dot_precision@30.2634
dot_precision@50.1828
dot_precision@100.0998
dot_recall@10.44
dot_recall@30.7543
dot_recall@50.8678
dot_recall@100.9424
dot_ndcg@100.7031
dot_mrr@100.6288
dot_map@1000.6253
queryactivedims24.9142
querysparsityratio0.9992
corpusactivedims171.8592
corpussparsityratio0.9944

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

Unnamed Dataset
  • β€”Size: 800,000 training samples
  • β€”Columns: <code>query</code>, <code>positive</code>, <code>negative1</code>, <code>negative2</code>, <code>negative3</code>, <code>negative4</code>, and <code>label</code>
  • β€”Approximate statistics based on the first 1000 samples: | | query | positive | negative1 | negative2 | negative3 | negative4 | label | |:--------|:---------------------------------------------------------------------------------|:------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------|:-----------------------------------| | type | string | string | string | string | string | string | list | | details | <ul><li>min: 4 tokens</li><li>mean: 8.96 tokens</li><li>max: 37 tokens</li></ul> | <ul><li>min: 19 tokens</li><li>mean: 79.51 tokens</li><li>max: 230 tokens</li></ul> | <ul><li>min: 22 tokens</li><li>mean: 78.09 tokens</li><li>max: 203 tokens</li></ul> | <ul><li>min: 14 tokens</li><li>mean: 77.84 tokens</li><li>max: 215 tokens</li></ul> | <ul><li>min: 15 tokens</li><li>mean: 76.65 tokens</li><li>max: 249 tokens</li></ul> | <ul><li>min: 19 tokens</li><li>mean: 74.67 tokens</li><li>max: 227 tokens</li></ul> | <ul><li>size: 4 elements</li></ul> |
  • β€”Samples: | query | positive | negative1 | negative2 | negative3 | negative4 | label | |:----------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------| | <code>who was president during detente</code> | <code>DΓ©tente ended after the Soviet intervention in Afghanistan, which led to the United States boycott of the 1980 Olympics in Moscow. Ronald Reagan's election as president in 1980, based in large part on an anti-dΓ©tente campaign, marked the close of dΓ©tente and a return to Cold War tensions.</code> | <code>Soviet Premier Alexei Kosygin (front) next to U.S. President Lyndon B. Johnson (behind) during the Glassboro Summit Conference The most obvious manifestation of dΓ©tente was the series of summits held between the leaders of the two superpowers and the treaties that resulted from these meetings.</code> | <code>The activities of President Ronald Reagan returned tensions to a fever pitch. Soviet relations with the People's Republic of China DΓ©tente could probably not have taken place, and certainly wouldn't have assumed the form that it did, without the rift that developed between the world's two primary communist regimes, the Soviet Union and the People's Republic of China (PRC).</code> | <code>DΓ©tente is the easing of strained relations, especially in a political situation. The term originates in the time of the Triple Entente and Entente cordiale in reference to an easing of tensions between England and France who, subsequent to being commingled polities under Norman rule, were warring rivals for the better part of a millennium but pursuant to a policy of dΓ©tente became enduring allies. In the context of the Cold War, the lessening of tensions between the East and West, along ...</code> | <code>DΓ©tente (French pronunciation: ​[detΙ‘Μƒt], meaning relaxation)[1] is the easing of strained relations, especially in political situation.</code> | <code>[1.0, 2.1879749298095703, 8.371654510498047, 10.16702938079834]</code> | | <code>what is an ftp file</code> | <code>File Transfer Protocol (FTP) is a standard Internet protocol for transmitting files between computers on the Internet over TCP/IP connections. FTP is a client-server protocol that relies on two communications channels between client and server: a command channel for controlling the conversation and a data channel for transmitting file content. Clients initiate conversations with servers by requesting to download a file.</code> | <code>The FTP (File Transfer Protocol) utility program is commonly used for copying files to and from other computers. These computers may be at the same site or at different sites thousands of miles apart. FTP is a general protocol that works on UNIX systems as well as a variety of other (non-UNIX) systems.</code> | <code>To transfer files via File Transfer Protocol (FTP), you need to establish an FTP connection. To make an FTP connection you can use a standard Web browser (Internet Explorer, Mozilla Firefox, etc.) or an FTP Client. To transfer a file with FTP you need to have an FTP accounts for the web space you are going to transfer the file to. FTP hosting account where you plan to upload your files.</code> | <code>The Difference Between FTP Servers and File Servers. When two terms are similar and even describe a similar concept, people have a tendency to start using them interchangeably. This is definitely true in the case of FTP servers and file servers, which sound like they accomplish the same goal but in reality are two very different animals altogether.</code> | <code>The command-line secure file transfer program (sftp) and graphical SFTP clients, such as WinSCP and Fetch, use SSH2 encryption to authenticate and establish secure channels between networked hosts.</code> | <code>[1.0, 5.810799598693848, 7.961757183074951, 18.629709243774414]</code> | | <code>what causes a t wave abnormality</code> | <code>T –wave abnormalities may not necessarily indicate the presence of a severe heart condition. There are non-specific wave changes that result from common, non-specific causes of T-wave abnormality which includes the following: 1 No obvious causes, which are usually associated with women. Fever.</code> | <code>5 Causes Of T-Wave Abnormality. T wave is basically the diagrammatically representation of ventricular polarization called electrocardiography. The structure of a T wave is like slight inverted upward stroke that follow a peak generated by R and S waves. One heart beat is represented in form of Q, R, S and T wave. The abnormality in T waves may be indicated by longer, flatter or higher peaks in the diagram. The measurement of heart beat in such a way makes it possible to diagnose heart related problems easily. If you are suffering from any heart related disease, the electrocardiogram will show an abnormality in the T wave. In this write up we will discuss various causes of abnormality in T wave measurement.</code> | <code>Specific states or conditions that cause T-wave abnormality. Complete inversions can signify the presence of cardiovascular diseases and other serious complications, which include the following: Ischemia is a condition in which oxygenated blood becomes constrained in a certain body part.</code> | <code>T Wave Abnormalities. christine m. smith. I just received a copy of an ECG I had done in Sept 1998. The preliminary report was borderline ECG and the final interpretation was Abnormal ECG. There was normal sinus rhythm and Nonspecific Anterior T abnormalities. When compared to an ECG taken in 1986 there was minimal T wave change. I have been told by many that abnormalities like this are usually no problem.</code> | <code>Prolonged Q-T interval. Long QT syndrome is a heart rhythm disorder that can cause serious irregular heart rhythms (arrhythmias). In a normal heart, your heart circulates blood throughout your body during each heartbeat. Your heart's chambers contract and relax to pump blood.</code> | <code>[1.0, 1.0, 5.3564229011535645, 11.585516929626465]</code> |
  • β€”Loss: <code>SpladeLoss</code> with these parameters:
json
  {
      "loss": "SparseMarginMSELoss",
      "document_regularizer_weight": 0.12,
      "query_regularizer_weight": 0.2
  }

Training Hyperparameters

Non-Default Hyperparameters
  • β€”eval_strategy: epoch
  • β€”per_device_train_batch_size: 48
  • β€”per_device_eval_batch_size: 48
  • β€”learning_rate: 4e-05
  • β€”num_train_epochs: 4
  • β€”lr_scheduler_type: cosine
  • β€”warmup_ratio: 0.025
  • β€”fp16: True
  • β€”load_best_model_at_end: True
  • β€”push_to_hub: True
All Hyperparameters

<details><summary>Click to expand</summary>

  • β€”overwrite_output_dir: False
  • β€”do_predict: False
  • β€”eval_strategy: epoch
  • β€”prediction_loss_only: True
  • β€”per_device_train_batch_size: 48
  • β€”per_device_eval_batch_size: 48
  • β€”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: 4e-05
  • β€”weight_decay: 0.0
  • β€”adam_beta1: 0.9
  • β€”adam_beta2: 0.999
  • β€”adam_epsilon: 1e-08
  • β€”max_grad_norm: 1.0
  • β€”num_train_epochs: 4
  • β€”max_steps: -1
  • β€”lr_scheduler_type: cosine
  • β€”lr_scheduler_kwargs: {}
  • β€”warmup_ratio: 0.025
  • β€”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: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • β€”fsdp_transformer_layer_cls_to_wrap: None
  • β€”accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • β€”deepspeed: None
  • β€”label_smoothing_factor: 0.0
  • β€”optim: adamwtorchfused
  • β€”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: True
  • β€”resume_from_checkpoint: None
  • β€”hub_model_id: None
  • β€”hub_strategy: every_save
  • β€”hub_private_repo: None
  • β€”hub_always_push: False
  • β€”hub_revision: None
  • β€”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
  • β€”liger_kernel_config: None
  • β€”eval_use_gather_object: False
  • β€”average_tokens_across_devices: False
  • β€”prompts: None
  • β€”batch_sampler: batch_sampler
  • β€”multi_dataset_batch_sampler: proportional
  • β€”router_mapping: {}
  • β€”learning_rate_mapping: {}

</details>

Training Logs

EpochStepTraining Lossdot_ndcg@10
1.0166678.3630.6961
2.0333346.50210.7031
3.0500015.22090.7031

Framework Versions

  • β€”Python: 3.12.11
  • β€”Sentence Transformers: 5.1.0
  • β€”Transformers: 4.55.3
  • β€”PyTorch: 2.8.0+cu126
  • β€”Accelerate: 1.10.0
  • β€”Datasets: 4.0.0
  • β€”Tokenizers: 0.21.4

Citation

BibTeX

Sentence Transformers
bibtex
@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",
}
SpladeLoss
bibtex
@misc{formal2022distillationhardnegativesampling,
      title={From Distillation to Hard Negative Sampling: Making Sparse Neural IR Models More Effective},
      author={Thibault Formal and Carlos Lassance and Benjamin Piwowarski and StΓ©phane Clinchant},
      year={2022},
      eprint={2205.04733},
      archivePrefix={arXiv},
      primaryClass={cs.IR},
      url={https://arxiv.org/abs/2205.04733},
}
SparseMarginMSELoss
bibtex
@misc{hofstΓ€tter2021improving,
    title={Improving Efficient Neural Ranking Models with Cross-Architecture Knowledge Distillation},
    author={Sebastian HofstΓ€tter and Sophia Althammer and Michael SchrΓΆder and Mete Sertkan and Allan Hanbury},
    year={2021},
    eprint={2010.02666},
    archivePrefix={arXiv},
    primaryClass={cs.IR}
}
FlopsLoss
bibtex
@article{paria2020minimizing,
    title={Minimizing flops to learn efficient sparse representations},
    author={Paria, Biswajit and Yeh, Chih-Kuan and Yen, Ian EH and Xu, Ning and Ravikumar, Pradeep and P{'o}czos, Barnab{'a}s},
    journal={arXiv preprint arXiv:2004.05665},
    year={2020}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. --> </details>