CoolFace
Modelpublic

sparse-encoder/example-splade-distilbert-base-uncased-nq

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

splade-distilbert-base-uncased trained on Natural Questions

This is a SPLADE Sparse Encoder model finetuned from distilbert/distilbert-base-uncased on the natural-questions 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:
  • natural-questions
  • 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-nq")
# Run inference
sentences = [
    'is send in the clowns from a musical',
    'Send In the Clowns "Send In the Clowns" is a song written by Stephen Sondheim for the 1973 musical A Little Night Music, an adaptation of Ingmar Bergman\'s film Smiles of a Summer Night. It is a ballad from Act Two, in which the character Desirée reflects on the ironies and disappointments of her life. Among other things, she looks back on an affair years earlier with the lawyer Fredrik, who was deeply in love with her but whose marriage proposals she had rejected. Meeting him after so long, she realizes she is in love with him and finally ready to marry him, but now it is he who rejects her: he is in an unconsummated marriage with a much younger woman. Desirée proposes marriage to rescue him from this situation, but he declines, citing his dedication to his bride. Reacting to his rejection, Desirée sings this song. The song is later reprised as a coda after Fredrik\'s young wife runs away with his son, and Fredrik is finally free to accept Desirée\'s offer.[1]',
    'The Suite Life on Deck The Suite Life on Deck is an American sitcom that aired on Disney Channel from September 26, 2008 to May 6, 2011. It is a sequel/spin-off of the Disney Channel Original Series The Suite Life of Zack & Cody. The series follows twin brothers Zack and Cody Martin and hotel heiress London Tipton in a new setting, the SS Tipton, where they attend classes at "Seven Seas High School" and meet Bailey Pickett while Mr. Moseby manages the ship. The ship travels around the world to nations such as Italy, France, Greece, India, Sweden and the United Kingdom where the characters experience different cultures, adventures, and situations.[1]',
]
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 Information Retrieval
  • Datasets: NanoMSMARCO, NanoNFCorpus, NanoNQ, NanoClimateFEVER, NanoDBPedia, NanoFEVER, NanoFiQA2018, NanoHotpotQA, NanoMSMARCO, NanoNFCorpus, NanoNQ, NanoQuoraRetrieval, NanoSCIDOCS, NanoArguAna, NanoSciFact and NanoTouche2020
  • Evaluated with <code>SparseInformationRetrievalEvaluator</code>
MetricNanoMSMARCONanoNFCorpusNanoNQNanoClimateFEVERNanoDBPediaNanoFEVERNanoFiQA2018NanoHotpotQANanoQuoraRetrievalNanoSCIDOCSNanoArguAnaNanoSciFactNanoTouche2020
dot_accuracy@10.280.380.360.260.620.540.220.740.80.440.10.440.5714
dot_accuracy@30.50.460.580.420.820.720.420.90.920.620.520.540.7959
dot_accuracy@50.660.520.660.480.860.820.440.90.940.660.660.640.8367
dot_accuracy@100.740.620.760.620.920.920.540.980.980.760.780.70.9796
dot_precision@10.280.380.360.260.620.540.220.740.80.440.10.440.5714
dot_precision@30.16670.320.20.15330.52670.240.16670.420.360.27330.17330.20.5578
dot_precision@50.1320.2920.140.1080.4640.1680.1120.2840.2360.220.1320.1440.4735
dot_precision@100.0740.2360.080.0780.4320.0960.0720.1640.130.1640.0780.0780.3939
dot_recall@10.280.02420.340.1250.07040.52670.12340.370.7240.09170.10.4050.0388
dot_recall@30.50.05310.560.20170.13320.68670.29040.630.86130.16870.520.5250.1084
dot_recall@50.660.07270.640.240.17830.76670.30840.710.9060.22570.660.630.1584
dot_recall@100.740.09590.720.32170.30240.87670.38040.820.96330.33570.780.680.2557
dot_ndcg@100.49580.27850.53420.2660.52850.69630.28430.72510.88270.32690.44170.55380.4521
dot_mrr@100.41850.43940.48370.36180.73120.65320.31840.82670.86740.53520.33310.52170.7053
dot_map@1000.42940.11740.47990.2080.39810.63840.24330.63150.85070.24960.33990.51770.3369
queryactivedims52.5662.545.6489.948.7882.7252.9269.8249.6286.16119.26111.3851.1633
querysparsityratio0.99830.9980.99850.99710.99840.99730.99830.99770.99840.99720.99610.99640.9983
corpusactivedims106.134126.2465104.3785107.8876112.2791121.6111104.2389134.849954.1169115.1506117.8589109.9668122.408
corpussparsityratio0.99650.99590.99660.99650.99630.9960.99660.99560.99820.99620.99610.99640.996
Sparse Nano BEIR
json
  {
      "dataset_names": [
          "msmarco",
          "nfcorpus",
          "nq"
      ]
  }
MetricValue
dot_accuracy@10.34
dot_accuracy@30.5133
dot_accuracy@50.6133
dot_accuracy@100.7067
dot_precision@10.34
dot_precision@30.2289
dot_precision@50.188
dot_precision@100.13
dot_recall@10.2147
dot_recall@30.371
dot_recall@50.4576
dot_recall@100.5186
dot_ndcg@100.4362
dot_mrr@100.4472
dot_map@1000.3422
queryactivedims53.5667
querysparsityratio0.9982
corpusactivedims110.0135
corpussparsityratio0.9964
Sparse Nano BEIR
json
  {
      "dataset_names": [
          "climatefever",
          "dbpedia",
          "fever",
          "fiqa2018",
          "hotpotqa",
          "msmarco",
          "nfcorpus",
          "nq",
          "quoraretrieval",
          "scidocs",
          "arguana",
          "scifact",
          "touche2020"
      ]
  }
MetricValue
dot_accuracy@10.4424
dot_accuracy@30.632
dot_accuracy@50.6982
dot_accuracy@100.7923
dot_precision@10.4424
dot_precision@30.2891
dot_precision@50.2235
dot_precision@100.1597
dot_recall@10.2476
dot_recall@30.403
dot_recall@50.4736
dot_recall@100.5594
dot_ndcg@100.4974
dot_mrr@100.5535
dot_map@1000.4185
queryactivedims70.9861
querysparsityratio0.9977
corpusactivedims109.8633
corpussparsityratio0.9964

<!--

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

natural-questions
  • Dataset: natural-questions at f9e894e
  • Size: 99,000 training samples
  • Columns: <code>query</code> and <code>answer</code>
  • Approximate statistics based on the first 1000 samples: | | query | answer | |:--------|:-----------------------------------------------------------------------------------|:------------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 10 tokens</li><li>mean: 11.71 tokens</li><li>max: 26 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 131.81 tokens</li><li>max: 450 tokens</li></ul> |
  • Samples: | query | answer | |:--------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>who played the father in papa don't preach</code> | <code>Alex McArthur Alex McArthur (born March 6, 1957) is an American actor.</code> | | <code>where was the location of the battle of hastings</code> | <code>Battle of Hastings The Battle of Hastings[a] was fought on 14 October 1066 between the Norman-French army of William, the Duke of Normandy, and an English army under the Anglo-Saxon King Harold Godwinson, beginning the Norman conquest of England. It took place approximately 7 miles (11 kilometres) northwest of Hastings, close to the present-day town of Battle, East Sussex, and was a decisive Norman victory.</code> | | <code>how many puppies can a dog give birth to</code> | <code>Canine reproduction The largest litter size to date was set by a Neapolitan Mastiff in Manea, Cambridgeshire, UK on November 29, 2004; the litter was 24 puppies.[22]</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

natural-questions
  • Dataset: natural-questions at f9e894e
  • Size: 1,000 evaluation samples
  • Columns: <code>query</code> and <code>answer</code>
  • Approximate statistics based on the first 1000 samples: | | query | answer | |:--------|:-----------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 10 tokens</li><li>mean: 11.69 tokens</li><li>max: 23 tokens</li></ul> | <ul><li>min: 15 tokens</li><li>mean: 134.01 tokens</li><li>max: 512 tokens</li></ul> |
  • Samples: | query | answer | |:-------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>where is the tiber river located in italy</code> | <code>Tiber The Tiber (/ˈtaɪbər/, Latin: Tiberis,[1] Italian: Tevere [ˈteːvere])[2] is the third-longest river in Italy, rising in the Apennine Mountains in Emilia-Romagna and flowing 406 kilometres (252 mi) through Tuscany, Umbria and Lazio, where it is joined by the river Aniene, to the Tyrrhenian Sea, between Ostia and Fiumicino.[3] It drains a basin estimated at 17,375 square kilometres (6,709 sq mi). The river has achieved lasting fame as the main watercourse of the city of Rome, founded on its eastern banks.</code> | | <code>what kind of car does jay gatsby drive</code> | <code>Jay Gatsby At the Buchanan home, Jordan Baker, Nick, Jay, and the Buchanans decide to visit New York City. Tom borrows Gatsby's yellow Rolls Royce to drive up to the city. On the way to New York City, Tom makes a detour at a gas station in "the Valley of Ashes", a run-down part of Long Island. The owner, George Wilson, shares his concern that his wife, Myrtle, may be having an affair. This unnerves Tom, who has been having an affair with Myrtle, and he leaves in a hurry.</code> | | <code>who sings if i can dream about you</code> | <code>I Can Dream About You "I Can Dream About You" is a song performed by American singer Dan Hartman on the soundtrack album of the film Streets of Fire. Released in 1984 as a single from the soundtrack, and included on Hartman's album I Can Dream About You, it reached number 6 on the Billboard Hot 100.[1]</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 LossNanoMSMARCO_dot_ndcg@10NanoNFCorpus_dot_ndcg@10NanoNQ_dot_ndcg@10NanoBEIR_mean_dot_ndcg@10NanoClimateFEVER_dot_ndcg@10NanoDBPedia_dot_ndcg@10NanoFEVER_dot_ndcg@10NanoFiQA2018_dot_ndcg@10NanoHotpotQA_dot_ndcg@10NanoQuoraRetrieval_dot_ndcg@10NanoSCIDOCS_dot_ndcg@10NanoArguAna_dot_ndcg@10NanoSciFact_dot_ndcg@10NanoTouche2020_dot_ndcg@10
0.02422006.3626---------------
0.04854000.0957---------------
0.07276000.0927---------------
0.09708000.0588---------------
0.121210000.0408---------------
0.145512000.0515---------------
0.169714000.0517---------------
0.193916000.0213---------------
0.21650-0.05200.49290.26180.45720.4040----------
0.218218000.019---------------
0.242420000.0333---------------
0.266722000.0282---------------
0.290924000.0418---------------
0.315226000.0386---------------
0.339428000.0289---------------
0.363630000.0242---------------
0.387932000.0335---------------
0.43300-0.03600.47150.28080.53400.4288----------
0.412134000.0264---------------
0.436436000.0331---------------
0.460638000.0339---------------
0.484840000.0225---------------
0.509142000.0164---------------
0.533344000.0247---------------
0.557646000.0213---------------
0.581848000.0187---------------
0.64950-0.02170.49010.29300.50720.4301----------
0.606150000.0153---------------
0.630352000.0186---------------
0.654554000.0096---------------
0.678856000.0115---------------
0.703058000.0255---------------
0.727360000.0219---------------
0.751562000.033---------------
0.775864000.0199---------------
0.866000.01750.02240.47000.27430.51360.4193----------
0.824268000.0236---------------
0.848570000.0145---------------
0.872772000.0372---------------
0.897074000.0107---------------
0.921276000.0131---------------
0.945578000.0127---------------
0.969780000.0207---------------
0.993982000.0217---------------
1.08250-0.02190.49580.27850.53420.4362----------
-1-1--0.49580.27850.53420.49740.26600.52850.69630.28430.72510.88270.32690.44170.55380.4521
  • The bold row denotes the saved checkpoint.

Environmental Impact

Carbon emissions were measured using CodeCarbon.

  • Energy Consumed: 0.040 kWh
  • Carbon Emitted: 0.002 kg of CO2
  • Hours Used: 0.322 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. -->