Downloads · 30 days
7
5% of all-time downloads
tomaarsen/splade-distilbert-base-uncased-nq-16bs
splade-distilbert-base-uncased-nq-16bs is a feature extraction model from tomaarsen. Use it when you need embeddings to search or compare text. It is set up for sentence-transformers. The card lists the license as apache-2.0.
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 s…
Downloads · 30 days
7
5% of all-time downloads
All-time downloads
150
Public
Parameters
67M
268 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors268 MB · 100%
From the Hugging Face model README
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.
SparseEncoder(
(0): MLMTransformer({'max_seq_length': 256, 'do_lower_case': False, 'architecture': 'DistilBertForMaskedLM'})
(1): SpladePooling({'pooling_strategy': 'max', 'activation_function': 'relu', 'word_embedding_dimension': 30522})
)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SparseEncoder
# Download from the 🤗 Hub
model = SparseEncoder("tomaarsen/splade-distilbert-base-uncased-nq-16bs")
# Run inference
queries = [
"who is cornelius in the book of acts",
]
documents = [
'Cornelius the Centurion Cornelius (Greek: Κορνήλιος) was a Roman centurion who is considered by Christians to be one of the first Gentiles to convert to the faith, as related in Acts of the Apostles.',
"Joe Ranft Ranft reunited with Lasseter when he was hired by Pixar in 1991 as their head of story.[1] There he worked on all of their films produced up to 2006; this included Toy Story (for which he received an Academy Award nomination) and A Bug's Life, as the co-story writer and others as story supervisor. His final film was Cars. He also voiced characters in many of the films, including Heimlich the caterpillar in A Bug's Life, Wheezy the penguin in Toy Story 2, and Jacques the shrimp in Finding Nemo.[1]",
'Wonderful Tonight "Wonderful Tonight" is a ballad written by Eric Clapton. It was included on Clapton\'s 1977 album Slowhand. Clapton wrote the song about Pattie Boyd.[1] The female vocal harmonies on the song are provided by Marcella Detroit (then Marcy Levy) and Yvonne Elliman.',
]
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([[29.2192, 2.4709, 1.7873]])
<!--
### 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.*
-->
NanoMSMARCO, NanoNFCorpus and NanoNQ| Metric | NanoMSMARCO | NanoNFCorpus | NanoNQ |
|---|---|---|---|
| dot_accuracy@1 | 0.3 | 0.38 | 0.3 |
| dot_accuracy@3 | 0.44 | 0.44 | 0.64 |
| dot_accuracy@5 | 0.6 | 0.54 | 0.66 |
| dot_accuracy@10 | 0.68 | 0.56 | 0.74 |
| dot_precision@1 | 0.3 | 0.38 | 0.3 |
| dot_precision@3 | 0.1467 | 0.32 | 0.2133 |
| dot_precision@5 | 0.12 | 0.3 | 0.132 |
| dot_precision@10 | 0.068 | 0.236 | 0.076 |
| dot_recall@1 | 0.3 | 0.0239 | 0.29 |
| dot_recall@3 | 0.44 | 0.0538 | 0.6 |
| dot_recall@5 | 0.6 | 0.0714 | 0.61 |
| dot_recall@10 | 0.68 | 0.0957 | 0.7 |
| dot_ndcg@10 | 0.4717 | 0.28 | 0.5182 |
| dot_mrr@10 | 0.4068 | 0.4359 | 0.4727 |
| dot_map@100 | 0.4194 | 0.1135 | 0.4609 |
| query_active_dims | 70.78 | 97.02 | 49.68 |
| query_sparsity_ratio | 0.9977 | 0.9968 | 0.9984 |
| corpus_active_dims | 150.2397 | 163.3874 | 141.9744 |
| corpus_sparsity_ratio | 0.9951 | 0.9946 | 0.9953 |
| avg_flops | 6.0766 | 10.3436 | 3.9758 |
NanoBEIR_mean{
"dataset_names": [
"msmarco",
"nfcorpus",
"nq"
],
"dataset_id": "sentence-transformers/NanoBEIR-en"
}
| Metric | Value |
|---|---|
| dot_accuracy@1 | 0.3267 |
| dot_accuracy@3 | 0.5067 |
| dot_accuracy@5 | 0.6 |
| dot_accuracy@10 | 0.66 |
| dot_precision@1 | 0.3267 |
| dot_precision@3 | 0.2267 |
| dot_precision@5 | 0.184 |
| dot_precision@10 | 0.1267 |
| dot_recall@1 | 0.2046 |
| dot_recall@3 | 0.3646 |
| dot_recall@5 | 0.4271 |
| dot_recall@10 | 0.4919 |
| dot_ndcg@10 | 0.4233 |
| dot_mrr@10 | 0.4384 |
| dot_map@100 | 0.3312 |
| query_active_dims | 72.4933 |
| query_sparsity_ratio | 0.9976 |
| corpus_active_dims | 150.0256 |
| corpus_sparsity_ratio | 0.9951 |
| avg_flops | 5.651 |
| 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: 128.91 tokens</li><li>max: 256 tokens</li></ul> |
| 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": "SparseMultipleNegativesRankingLoss(scale=1.0, similarity_fct='dot_score', gather_across_devices=False, directions=('query_to_doc',), partition_mode='joint')",
"document_regularizer_weight": 3e-05,
"query_regularizer_weight": 5e-05
}
| 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: 129.31 tokens</li><li>max: 256 tokens</li></ul> |
| 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": "SparseMultipleNegativesRankingLoss(scale=1.0, similarity_fct='dot_score', gather_across_devices=False, directions=('query_to_doc',), partition_mode='joint')",
"document_regularizer_weight": 3e-05,
"query_regularizer_weight": 5e-05
}
per_device_train_batch_size: 16num_train_epochs: 1learning_rate: 2e-05warmup_steps: 0.1bf16: Trueeval_strategy: stepsper_device_eval_batch_size: 16load_best_model_at_end: Truebatch_sampler: no_duplicatesper_device_train_batch_size: 16num_train_epochs: 1max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.1optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1.0label_smoothing_factor: 0.0bf16: Truefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: trackioeval_strategy: stepsper_device_eval_batch_size: 16prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Trueignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Falsedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_backend: Noneddp_timeout: 1800fsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}deepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss | NanoMSMARCO_dot_ndcg@10 | NanoNFCorpus_dot_ndcg@10 | NanoNQ_dot_ndcg@10 | NanoBEIR_mean_dot_ndcg@10 |
|---|---|---|---|---|---|---|---|
| 0.0501 | 310 | 59.7460 | - | - | - | - | - |
| 0.1002 | 620 | 0.0927 | - | - | - | - | - |
| 0.1503 | 930 | 0.0513 | - | - | - | - | - |
| 0.2001 | 1238 | - | 0.0827 | 0.4945 | 0.2530 | 0.4913 | 0.4129 |
| 0.2004 | 1240 | 0.0474 | - | - | - | - | - |
| 0.2505 | 1550 | 0.0462 | - | - | - | - | - |
| 0.3006 | 1860 | 0.0313 | - | - | - | - | - |
| 0.3507 | 2170 | 0.0258 | - | - | - | - | - |
| 0.4001 | 2476 | - | 0.0427 | 0.4717 | 0.28 | 0.5182 | 0.4233 |
| 0.4008 | 2480 | 0.0414 | - | - | - | - | - |
| 0.4509 | 2790 | 0.0306 | - | - | - | - | - |
| 0.5010 | 3100 | 0.0316 | - | - | - | - | - |
| 0.5511 | 3410 | 0.0300 | - | - | - | - | - |
| 0.6002 | 3714 | - | 0.0652 | 0.4169 | 0.2041 | 0.5020 | 0.3743 |
| 0.6012 | 3720 | 0.0293 | - | - | - | - | - |
| 0.6513 | 4030 | 0.0257 | - | - | - | - | - |
| 0.7014 | 4340 | 0.0219 | - | - | - | - | - |
| 0.7515 | 4650 | 0.0242 | - | - | - | - | - |
| 0.8003 | 4952 | - | 0.0475 | 0.4366 | 0.2656 | 0.4988 | 0.4003 |
| 0.8016 | 4960 | 0.0215 | - | - | - | - | - |
| 0.8516 | 5270 | 0.0248 | - | - | - | - | - |
| 0.9017 | 5580 | 0.0230 | - | - | - | - | - |
| 0.9518 | 5890 | 0.0191 | - | - | - | - | - |
| -1 | -1 | - | - | 0.4717 | 0.2800 | 0.5182 | 0.4233 |
@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",
}
@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},
}
@misc{oord2019representationlearningcontrastivepredictive,
title={Representation Learning with Contrastive Predictive Coding},
author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
year={2019},
eprint={1807.03748},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/1807.03748},
}
@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.*
-->