CoolFace
Modelpublic

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

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

splade-distilbert-base-uncased trained on GooAQ

This is a SPLADE Sparse Encoder model finetuned from distilbert/distilbert-base-uncased on the gooaq 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:
  • gooaq
  • 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-gooaq")
# Run inference
sentences = [
    'how many days for doxycycline to work on sinus infection?',
    'Treatment of suspected bacterial infection is with antibiotics, such as amoxicillin/clavulanate or doxycycline, given for 5 to 7 days for acute sinusitis and for up to 6 weeks for chronic sinusitis.',
    'Most engagements typically have a cocktail dress code, calling for dresses at, or slightly above, knee-length and high heels. If your party states a different dress code, however, such as semi-formal or dressy-casual, you may need to dress up or down accordingly.',
]
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.240.380.360.260.540.560.360.660.580.40.10.540.6122
dot_accuracy@30.50.50.580.40.680.780.520.860.760.580.380.640.8571
dot_accuracy@50.580.520.660.420.760.860.540.920.860.660.460.660.9184
dot_accuracy@100.720.660.720.640.90.920.620.920.940.740.540.780.9388
dot_precision@10.240.380.360.260.540.560.360.660.580.40.10.540.6122
dot_precision@30.16670.29330.19330.140.43330.260.24670.43330.260.25330.12670.220.5374
dot_precision@50.1160.2680.1360.0920.40.1720.1680.2880.1840.2280.0920.1440.5102
dot_precision@100.0720.2280.0780.080.360.0960.1060.1560.1120.1540.0540.0860.451
dot_recall@10.240.03980.340.130.04730.54670.18860.330.570.08470.10.5050.0413
dot_recall@30.50.05840.540.180.09140.74670.32170.650.72330.15870.380.60.1085
dot_recall@50.580.07660.630.190.12260.80670.35320.720.82330.23570.460.6350.1729
dot_recall@100.720.110.690.30730.24660.87670.45520.780.89530.31670.540.760.2942
dot_ndcg@100.47850.28160.5190.25280.43050.72030.37840.69860.73790.30730.31410.63310.4998
dot_mrr@100.40170.45720.47580.34830.64410.68440.44320.75970.68640.50310.24190.60990.7427
dot_map@1000.4140.11430.46910.1950.3240.66480.31980.63260.68820.23140.25450.59210.3718
queryactivedims109.7140.06115.3215.4147.72201.5487.62131.7656.7219.98392.4239.0241.0612
querysparsityratio0.99640.99540.99620.99290.99520.99340.99710.99570.99810.99280.98710.99220.9987
corpusactivedims265.6181371.9038336.9138334.8184295.1452374.9946275.468330.98963.4294370.2647371.9895362.6149307.7058
corpussparsityratio0.99130.98780.9890.9890.99030.98770.9910.98920.99790.98790.98780.98810.9899
Sparse Nano BEIR
json
  {
      "dataset_names": [
          "msmarco",
          "nfcorpus",
          "nq"
      ]
  }
MetricValue
dot_accuracy@10.3
dot_accuracy@30.5
dot_accuracy@50.58
dot_accuracy@100.6733
dot_precision@10.3
dot_precision@30.2067
dot_precision@50.1733
dot_precision@100.118
dot_recall@10.1801
dot_recall@30.3399
dot_recall@50.4152
dot_recall@100.5011
dot_ndcg@100.4016
dot_mrr@100.4195
dot_map@1000.3082
queryactivedims138.12
querysparsityratio0.9955
corpusactivedims346.3697
corpussparsityratio0.9887
Sparse Nano BEIR
json
  {
      "dataset_names": [
          "climatefever",
          "dbpedia",
          "fever",
          "fiqa2018",
          "hotpotqa",
          "msmarco",
          "nfcorpus",
          "nq",
          "quoraretrieval",
          "scidocs",
          "arguana",
          "scifact",
          "touche2020"
      ]
  }
MetricValue
dot_accuracy@10.4302
dot_accuracy@30.6182
dot_accuracy@50.6783
dot_accuracy@100.7722
dot_precision@10.4302
dot_precision@30.2742
dot_precision@50.2152
dot_precision@100.1564
dot_recall@10.2433
dot_recall@30.3891
dot_recall@50.4466
dot_recall@100.5378
dot_ndcg@100.4809
dot_mrr@100.5383
dot_map@1000.4055
queryactivedims161.5901
querysparsityratio0.9947
corpusactivedims302.8481
corpussparsityratio0.9901

<!--

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

gooaq
  • Dataset: gooaq at b089f72
  • Size: 99,000 training samples
  • Columns: <code>question</code> and <code>answer</code>
  • Approximate statistics based on the first 1000 samples: | | question | answer | |:--------|:----------------------------------------------------------------------------------|:------------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 8 tokens</li><li>mean: 11.79 tokens</li><li>max: 24 tokens</li></ul> | <ul><li>min: 14 tokens</li><li>mean: 60.02 tokens</li><li>max: 153 tokens</li></ul> |
  • Samples: | question | answer | |:-----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>what are the 5 characteristics of a star?</code> | <code>Key Concept: Characteristics used to classify stars include color, temperature, size, composition, and brightness.</code> | | <code>are copic markers alcohol ink?</code> | <code>Copic Ink is alcohol-based and flammable. Keep away from direct sunlight and extreme temperatures.</code> | | <code>what is the difference between appellate term and appellate division?</code> | <code>Appellate terms An appellate term is an intermediate appellate court that hears appeals from the inferior courts within their designated counties or judicial districts, and are intended to ease the workload on the Appellate Division and provide a less expensive forum closer to the people.</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

gooaq
  • Dataset: gooaq at b089f72
  • Size: 1,000 evaluation samples
  • Columns: <code>question</code> and <code>answer</code>
  • Approximate statistics based on the first 1000 samples: | | question | answer | |:--------|:----------------------------------------------------------------------------------|:------------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 8 tokens</li><li>mean: 11.93 tokens</li><li>max: 25 tokens</li></ul> | <ul><li>min: 14 tokens</li><li>mean: 60.84 tokens</li><li>max: 127 tokens</li></ul> |
  • Samples: | question | answer | |:-----------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>should you take ibuprofen with high blood pressure?</code> | <code>In general, people with high blood pressure should use acetaminophen or possibly aspirin for over-the-counter pain relief. Unless your health care provider has said it's OK, you should not use ibuprofen, ketoprofen, or naproxen sodium. If aspirin or acetaminophen doesn't help with your pain, call your doctor.</code> | | <code>how old do you have to be to work in sc?</code> | <code>The general minimum age of employment for South Carolina youth is 14, although the state allows younger children who are performers to work in show business. If their families are agricultural workers, children younger than age 14 may also participate in farm labor.</code> | | <code>how to write a topic proposal for a research paper?</code> | <code>['Write down the main topic of your paper. ... ', 'Write two or three short sentences under the main topic that explain why you chose that topic. ... ', 'Write a thesis sentence that states the angle and purpose of your research paper. ... ', 'List the items you will cover in the body of the paper that support your thesis statement.']</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: 32
  • per_device_eval_batch_size: 32
  • 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: 32
  • per_device_eval_batch_size: 32
  • 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.032310015.2006---------------
0.06462000.2384---------------
0.09703000.1932---------------
0.12934000.1428---------------
0.16165000.144---------------
0.19396000.1345---------------
0.1972610-0.11990.43640.21950.49980.3853----------
0.22627000.1406---------------
0.25868000.1012---------------
0.29099000.112---------------
0.323210000.0736---------------
0.355511000.0943---------------
0.387812000.0901---------------
0.39431220-0.11260.47060.24900.51540.4117----------
0.420213000.0988---------------
0.452514000.0953---------------
0.484815000.1145---------------
0.517116000.0928---------------
0.549517000.0963---------------
0.581818000.0724---------------
0.59151830-0.07360.45760.24570.50150.4016----------
0.614119000.0753---------------
0.646420000.0657---------------
0.678721000.0741---------------
0.711122000.0671---------------
0.743423000.1013---------------
0.775724000.0795---------------
0.78862440-0.07190.47850.28160.5190.4264----------
0.808025000.0666---------------
0.840326000.0589---------------
0.872727000.0569---------------
0.905028000.0754---------------
0.937329000.0724---------------
0.969630000.0658---------------
0.98583050-0.06610.44470.25870.50140.4016----------
-1-1--0.47850.28160.51900.48090.25280.43050.72030.37840.69860.73790.30730.31410.63310.4998
  • The bold row denotes the saved checkpoint.

Environmental Impact

Carbon emissions were measured using CodeCarbon.

  • Energy Consumed: 0.019 kWh
  • Carbon Emitted: 0.001 kg of CO2
  • Hours Used: 0.174 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. -->