CoolFace
Modelpublic

sparse-encoder/example-splade-distilbert-base-uncased-quora-duplicates

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
0likes24downloads
Model Card

splade-distilbert-base-uncased trained on Quora Duplicates Questions

This is a SPLADE Sparse Encoder model finetuned from distilbert/distilbert-base-uncased on the quora-duplicates dataset using the sentence-transformers 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: distilbert/distilbert-base-uncased <!-- at revision 12040accade4e8a0f71eabdb258fecc2e7e948be -->
  • Maximum Sequence Length: 256 tokens
  • Output Dimensionality: 30522 dimensions
  • Similarity Function: Dot Product
  • Training Dataset:
  • quora-duplicates
  • Language: en
  • License: apache-2.0

Model Sources

Full Model Architecture

SparseEncoder(
  (0): MLMTransformer({'max_seq_length': 256, 'do_lower_case': False}) with MLMTransformer model: DistilBertForMaskedLM 
  (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/splade-distilbert-base-uncased-quora-duplicates")
# Run inference
sentences = [
    'What accomplishments did Hillary Clinton achieve during her time as Secretary of State?',
    "What are Hillary Clinton's most recognized accomplishments while Secretary of State?",
    'What are Hillary Clinton’s qualifications to be President?',
]
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]

<!--

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. -->

Evaluation

Metrics

Sparse Binary Classification
MetricValue
cosine_accuracy0.758
cosineaccuracythreshold0.8166
cosine_f10.6793
cosinef1threshold0.5696
cosine_precision0.5488
cosine_recall0.8913
cosine_ap0.6888
cosine_mcc0.5082
dot_accuracy0.765
dotaccuracythreshold51.6699
dot_f10.6762
dotf1threshold46.5249
dot_precision0.5817
dot_recall0.8075
dot_ap0.6336
dot_mcc0.4996
euclidean_accuracy0.677
euclideanaccuracythreshold-14.2724
euclidean_f10.486
euclideanf1threshold-0.6445
euclidean_precision0.3213
euclidean_recall0.9969
euclidean_ap0.2033
euclidean_mcc-0.0459
manhattan_accuracy0.677
manhattanaccuracythreshold-161.7768
manhattan_f10.486
manhattanf1threshold-3.0495
manhattan_precision0.3213
manhattan_recall0.9969
manhattan_ap0.2044
manhattan_mcc-0.0459
max_accuracy0.765
maxaccuracythreshold51.6699
max_f10.6793
maxf1threshold46.5249
max_precision0.5817
max_recall0.9969
max_ap0.6888
max_mcc0.5082
active_dims78.3228
sparsity_ratio0.9974
Sparse Information Retrieval
  • Datasets: NanoMSMARCO, NanoNQ, NanoNFCorpus, NanoQuoraRetrieval, NanoClimateFEVER, NanoDBPedia, NanoFEVER, NanoFiQA2018, NanoHotpotQA, NanoMSMARCO, NanoNFCorpus, NanoNQ, NanoQuoraRetrieval, NanoSCIDOCS, NanoArguAna, NanoSciFact and NanoTouche2020
  • Evaluated with <code>SparseInformationRetrievalEvaluator</code>
MetricNanoMSMARCONanoNQNanoNFCorpusNanoQuoraRetrievalNanoClimateFEVERNanoDBPediaNanoFEVERNanoFiQA2018NanoHotpotQANanoSCIDOCSNanoArguAnaNanoSciFactNanoTouche2020
dot_accuracy@10.220.380.340.940.180.60.580.280.780.360.10.520.3878
dot_accuracy@30.420.540.50.980.320.840.760.420.840.580.340.620.7551
dot_accuracy@50.520.620.540.980.40.840.80.460.920.680.420.640.8367
dot_accuracy@100.760.620.580.980.480.920.860.50.980.760.440.760.9592
dot_precision@10.220.380.340.940.180.60.580.280.780.360.10.520.3878
dot_precision@30.140.180.30670.39330.10670.52670.26670.180.37330.27330.11330.21330.4694
dot_precision@50.1040.1240.260.2480.0840.4560.1680.1360.2840.2120.0840.140.4163
dot_precision@100.0760.0640.1980.1320.0540.4220.090.0840.160.1520.0440.0840.3388
dot_recall@10.220.360.01160.81730.0850.04570.54670.14180.390.07570.10.4750.0238
dot_recall@30.420.520.06060.9280.14670.15370.74670.24290.560.16970.340.580.0893
dot_recall@50.520.60.08260.9460.17830.19080.78670.27720.710.21770.420.6150.1288
dot_recall@100.760.610.0980.970.2150.29360.84670.32890.80.31070.440.740.2166
dot_ndcg@100.45320.48280.24670.94670.18450.50710.7070.28810.71430.30290.27820.60210.3762
dot_mrr@100.36010.45370.4220.960.26740.71470.67650.35620.83620.49440.22470.57990.5807
dot_map@1000.37330.44540.0940.92910.14760.39070.66510.24150.61810.21670.23330.55510.2561
queryactivedims74.7674.7479.776.5889.8669.5289.8882.8691.9894.3189.182.4679.1225
querysparsityratio0.99760.99760.99740.99750.99710.99770.99710.99730.9970.99690.99380.99730.9974
corpusactivedims103.0652141.3148202.172777.5906221.7553135.9335221.2156130.937152.0157199.6463164.0333194.2494135.0078
corpussparsityratio0.99660.99540.99340.99750.99270.99550.99280.99570.9950.99350.99460.99360.9956
Sparse Nano BEIR
json
  {
      "dataset_names": [
          "msmarco",
          "nq",
          "nfcorpus",
          "quoraretrieval"
      ]
  }
MetricValue
dot_accuracy@10.47
dot_accuracy@30.61
dot_accuracy@50.665
dot_accuracy@100.735
dot_precision@10.47
dot_precision@30.255
dot_precision@50.184
dot_precision@100.1175
dot_recall@10.3522
dot_recall@30.4821
dot_recall@50.5372
dot_recall@100.6095
dot_ndcg@100.5324
dot_mrr@100.5489
dot_map@1000.4605
queryactivedims76.445
querysparsityratio0.9975
corpusactivedims122.7978
corpussparsityratio0.996
Sparse Nano BEIR
json
  {
      "dataset_names": [
          "climatefever",
          "dbpedia",
          "fever",
          "fiqa2018",
          "hotpotqa",
          "msmarco",
          "nfcorpus",
          "nq",
          "quoraretrieval",
          "scidocs",
          "arguana",
          "scifact",
          "touche2020"
      ]
  }
MetricValue
dot_accuracy@10.436
dot_accuracy@30.6089
dot_accuracy@50.6659
dot_accuracy@100.7384
dot_precision@10.436
dot_precision@30.2725
dot_precision@50.2089
dot_precision@100.1461
dot_recall@10.2533
dot_recall@30.3813
dot_recall@50.4364
dot_recall@100.51
dot_ndcg@100.4685
dot_mrr@100.5328
dot_map@1000.3974
queryactivedims90.3914
querysparsityratio0.997
corpusactivedims152.3669
corpussparsityratio0.995

<!--

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

quora-duplicates
  • Dataset: quora-duplicates at 451a485
  • Size: 99,000 training samples
  • Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
  • Approximate statistics based on the first 1000 samples: | | anchor | positive | negative | |:--------|:---------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------| | type | string | string | string | | details | <ul><li>min: 6 tokens</li><li>mean: 14.1 tokens</li><li>max: 39 tokens</li></ul> | <ul><li>min: 6 tokens</li><li>mean: 13.83 tokens</li><li>max: 41 tokens</li></ul> | <ul><li>min: 6 tokens</li><li>mean: 15.21 tokens</li><li>max: 75 tokens</li></ul> |
  • Samples: | anchor | positive | negative | |:----------------------------------------------------------------------|:---------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>What are the best GMAT coaching institutes in Delhi NCR?</code> | <code>Which are the best GMAT coaching institutes in Delhi/NCR?</code> | <code>What are the best GMAT coaching institutes in Delhi-Noida Area?</code> | | <code>Is a third world war coming?</code> | <code>Is World War 3 more imminent than expected?</code> | <code>Since the UN is unable to control terrorism and groups like ISIS, al-Qaeda and countries that promote terrorism (even though it consumed those countries), can we assume that the world is heading towards World War III?</code> | | <code>Should I build iOS or Android apps first?</code> | <code>Should people choose Android or iOS first to build their App?</code> | <code>How much more effort is it to build your app on both iOS and Android?</code> |
  • Loss: <code>SpladeLoss</code> with these parameters:
json
  {
      "loss": "SparseMultipleNegativesRankingLoss(scale=1.0, similarity_fct='dot_score')",
      "lambda_corpus": 3e-05,
      "lambda_query": 5e-05
  }

Evaluation Dataset

quora-duplicates
  • Dataset: quora-duplicates at 451a485
  • Size: 1,000 evaluation samples
  • Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
  • Approximate statistics based on the first 1000 samples: | | anchor | positive | negative | |:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------| | type | string | string | string | | details | <ul><li>min: 6 tokens</li><li>mean: 14.05 tokens</li><li>max: 40 tokens</li></ul> | <ul><li>min: 6 tokens</li><li>mean: 14.14 tokens</li><li>max: 44 tokens</li></ul> | <ul><li>min: 6 tokens</li><li>mean: 14.56 tokens</li><li>max: 60 tokens</li></ul> |
  • Samples: | anchor | positive | negative | |:-------------------------------------------------------------------|:------------------------------------------------------------|:-----------------------------------------------------------------| | <code>What happens if we use petrol in diesel vehicles?</code> | <code>Why can't we use petrol in diesel?</code> | <code>Why are diesel engines noisier than petrol engines?</code> | | <code>Why is Saltwater taffy candy imported in Switzerland?</code> | <code>Why is Saltwater taffy candy imported in Laos?</code> | <code>Is salt a consumer product?</code> | | <code>Which is your favourite film in 2016?</code> | <code>What movie is the best movie of 2016?</code> | <code>What will the best movie of 2017 be?</code> |
  • Loss: <code>SpladeLoss</code> with these parameters:
json
  {
      "loss": "SparseMultipleNegativesRankingLoss(scale=1.0, similarity_fct='dot_score')",
      "lambda_corpus": 3e-05,
      "lambda_query": 5e-05
  }

Training Hyperparameters

Non-Default Hyperparameters
  • eval_strategy: steps
  • per_device_train_batch_size: 12
  • per_device_eval_batch_size: 12
  • learning_rate: 2e-05
  • num_train_epochs: 1
  • bf16: True
  • load_best_model_at_end: True
  • batch_sampler: no_duplicates
All Hyperparameters

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

  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 12
  • per_device_eval_batch_size: 12
  • 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: 2e-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: 1
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.0
  • 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: True
  • fp16: False
  • 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}
  • tp_size: 0
  • 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: adamw_torch
  • 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: False
  • resume_from_checkpoint: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_private_repo: None
  • hub_always_push: False
  • 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
  • dispatch_batches: None
  • split_batches: 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
  • eval_use_gather_object: False
  • average_tokens_across_devices: False
  • prompts: None
  • batch_sampler: no_duplicates
  • multi_dataset_batch_sampler: proportional

</details>

Training Logs

EpochStepTraining LossValidation Lossquora_duplicates_dev_max_apNanoMSMARCO_dot_ndcg@10NanoNQ_dot_ndcg@10NanoNFCorpus_dot_ndcg@10NanoQuoraRetrieval_dot_ndcg@10NanoBEIR_mean_dot_ndcg@10NanoClimateFEVER_dot_ndcg@10NanoDBPedia_dot_ndcg@10NanoFEVER_dot_ndcg@10NanoFiQA2018_dot_ndcg@10NanoHotpotQA_dot_ndcg@10NanoSCIDOCS_dot_ndcg@10NanoArguAna_dot_ndcg@10NanoSciFact_dot_ndcg@10NanoTouche2020_dot_ndcg@10
0.02422008.3389----------------
0.04854000.4397----------------
0.07276000.3737----------------
0.09708000.2666----------------
0.121210000.288----------------
0.145512000.1977----------------
0.169714000.2707----------------
0.193916000.1951----------------
0.21650-0.16690.64720.30520.27930.17110.92810.4209---------
0.218218000.2178----------------
0.242420000.2174----------------
0.266722000.1832----------------
0.290924000.1879----------------
0.315226000.1723----------------
0.339428000.1543----------------
0.363630000.1559----------------
0.387932000.1575----------------
0.43300-0.11490.67490.38940.44670.23600.92920.5003---------
0.412134000.1395----------------
0.436436000.1596----------------
0.460638000.1595----------------
0.484840000.1211----------------
0.509142000.1163----------------
0.533344000.1182----------------
0.557646000.1337----------------
0.581848000.1362----------------
0.64950-0.10010.68020.40930.42690.23410.93650.5017---------
0.606150000.1112----------------
0.630352000.1064----------------
0.654554000.119----------------
0.678856000.1077----------------
0.703058000.1398----------------
0.727360000.09----------------
0.751562000.0903----------------
0.775864000.1082----------------
0.866000.11220.09010.69410.44510.47570.25420.94110.5290---------
0.824268000.0708----------------
0.848570000.1291----------------
0.872772000.1165----------------
0.897074000.0735----------------
0.921276000.0775----------------
0.945578000.0945----------------
0.969780000.0912----------------
0.993982000.104----------------
1.08250-0.06860.68880.45320.48280.24670.94670.5324---------
-1-1---0.45320.48280.24670.94670.46850.18450.50710.70700.28810.71430.30290.27820.60210.3762
  • The bold row denotes the saved checkpoint.

Environmental Impact

Carbon emissions were measured using CodeCarbon.

  • Energy Consumed: 0.025 kWh
  • Carbon Emitted: 0.001 kg of CO2
  • Hours Used: 0.222 hours

Training Hardware

  • On Cloud: No
  • GPU Model: 1 x NVIDIA GeForce RTX 3070 Ti Laptop GPU
  • CPU Model: AMD Ryzen 9 6900HX with Radeon Graphics
  • RAM Size: 30.61 GB

Framework Versions

  • Python: 3.12.9
  • Sentence Transformers: 4.2.0.dev0
  • Transformers: 4.50.3
  • PyTorch: 2.6.0+cu124
  • Accelerate: 1.6.0
  • Datasets: 3.5.0
  • Tokenizers: 0.21.1

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},
}
SparseMultipleNegativesRankingLoss
bibtex
@misc{henderson2017efficient,
    title={Efficient Natural Language Response Suggestion for Smart Reply},
    author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
    year={2017},
    eprint={1705.00652},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}
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. -->