Views
No views yet
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})
)pip install -U sentence-transformers1from sentence_transformers import SparseEncoder
2
3# Download from the 🤗 Hub
4model = SparseEncoder("arthurbresnu/splade-distilbert-base-uncased-gooaq")
5# Run inference
6sentences = [
7 'how many days for doxycycline to work on sinus infection?',
8 '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.',
9 '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.',
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# (3, 30522)
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities.shape)
18# [3, 3]NanoMSMARCO, NanoNFCorpus, NanoNQ, NanoClimateFEVER, NanoDBPedia, NanoFEVER, NanoFiQA2018, NanoHotpotQA, NanoMSMARCO, NanoNFCorpus, NanoNQ, NanoQuoraRetrieval, NanoSCIDOCS, NanoArguAna, NanoSciFact and NanoTouche2020SparseInformationRetrievalEvaluator| Metric | NanoMSMARCO | NanoNFCorpus | NanoNQ | NanoClimateFEVER | NanoDBPedia | NanoFEVER | NanoFiQA2018 | NanoHotpotQA | NanoQuoraRetrieval | NanoSCIDOCS | NanoArguAna | NanoSciFact | NanoTouche2020 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| dot_accuracy@1 | 0.24 | 0.38 | 0.36 | 0.26 | 0.54 | 0.56 | 0.36 | 0.66 | 0.58 | 0.4 | 0.1 | 0.54 | 0.6122 |
| dot_accuracy@3 | 0.5 | 0.5 | 0.58 | 0.4 | 0.68 | 0.78 | 0.52 | 0.86 | 0.76 | 0.58 | 0.38 | 0.64 | 0.8571 |
| dot_accuracy@5 | 0.58 | 0.52 | 0.66 | 0.42 | 0.76 | 0.86 | 0.54 | 0.92 | 0.86 | 0.66 | 0.46 | 0.66 | 0.9184 |
| dot_accuracy@10 | 0.72 | 0.66 | 0.72 | 0.64 | 0.9 | 0.92 | 0.62 | 0.92 | 0.94 | 0.74 | 0.54 | 0.78 | 0.9388 |
| dot_precision@1 | 0.24 | 0.38 | 0.36 | 0.26 | 0.54 | 0.56 | 0.36 | 0.66 | 0.58 | 0.4 | 0.1 | 0.54 | 0.6122 |
| dot_precision@3 | 0.1667 | 0.2933 | 0.1933 | 0.14 | 0.4333 | 0.26 | 0.2467 | 0.4333 | 0.26 | 0.2533 | 0.1267 | 0.22 | 0.5374 |
| dot_precision@5 | 0.116 | 0.268 | 0.136 | 0.092 | 0.4 | 0.172 | 0.168 | 0.288 | 0.184 | 0.228 | 0.092 | 0.144 | 0.5102 |
| dot_precision@10 | 0.072 | 0.228 | 0.078 | 0.08 | 0.36 | 0.096 | 0.106 | 0.156 | 0.112 | 0.154 | 0.054 | 0.086 | 0.451 |
| dot_recall@1 | 0.24 | 0.0398 | 0.34 | 0.13 | 0.0473 | 0.5467 | 0.1886 | 0.33 | 0.57 | 0.0847 | 0.1 | 0.505 | 0.0413 |
| dot_recall@3 | 0.5 | 0.0584 | 0.54 | 0.18 | 0.0914 | 0.7467 | 0.3217 | 0.65 | 0.7233 | 0.1587 | 0.38 | 0.6 | 0.1085 |
| dot_recall@5 | 0.58 | 0.0766 | 0.63 | 0.19 | 0.1226 | 0.8067 | 0.3532 | 0.72 | 0.8233 | 0.2357 | 0.46 | 0.635 | 0.1729 |
| dot_recall@10 | 0.72 | 0.11 | 0.69 | 0.3073 | 0.2466 | 0.8767 | 0.4552 | 0.78 | 0.8953 | 0.3167 | 0.54 | 0.76 | 0.2942 |
| dot_ndcg@10 | 0.4785 | 0.2816 | 0.519 | 0.2528 | 0.4305 | 0.7203 | 0.3784 | 0.6986 | 0.7379 | 0.3073 | 0.3141 | 0.6331 | 0.4998 |
| dot_mrr@10 | 0.4017 | 0.4572 | 0.4758 | 0.3483 | 0.6441 | 0.6844 | 0.4432 | 0.7597 | 0.6864 | 0.5031 | 0.2419 | 0.6099 | 0.7427 |
| dot_map@100 | 0.414 | 0.1143 | 0.4691 | 0.195 | 0.324 | 0.6648 | 0.3198 | 0.6326 | 0.6882 | 0.2314 | 0.2545 | 0.5921 | 0.3718 |
| query_active_dims | 109.7 | 140.06 | 115.3 | 215.4 | 147.72 | 201.54 | 87.62 | 131.76 | 56.7 | 219.98 | 392.4 | 239.02 | 41.0612 |
| query_sparsity_ratio | 0.9964 | 0.9954 | 0.9962 | 0.9929 | 0.9952 | 0.9934 | 0.9971 | 0.9957 | 0.9981 | 0.9928 | 0.9871 | 0.9922 | 0.9987 |
| corpus_active_dims | 265.6181 | 371.9038 | 336.9138 | 334.8184 | 295.1452 | 374.9946 | 275.468 | 330.989 | 63.4294 | 370.2647 | 371.9895 | 362.6149 | 307.7058 |
| corpus_sparsity_ratio | 0.9913 | 0.9878 | 0.989 | 0.989 | 0.9903 | 0.9877 | 0.991 | 0.9892 | 0.9979 | 0.9879 | 0.9878 | 0.9881 | 0.9899 |
NanoBEIR_meanSparseNanoBEIREvaluator with these parameters:
1{
2 "dataset_names": [
3 "msmarco",
4 "nfcorpus",
5 "nq"
6 ]
7}| Metric | Value |
|---|---|
| dot_accuracy@1 | 0.3 |
| dot_accuracy@3 | 0.5 |
| dot_accuracy@5 | 0.58 |
| dot_accuracy@10 | 0.6733 |
| dot_precision@1 | 0.3 |
| dot_precision@3 | 0.2067 |
| dot_precision@5 | 0.1733 |
| dot_precision@10 | 0.118 |
| dot_recall@1 | 0.1801 |
| dot_recall@3 | 0.3399 |
| dot_recall@5 | 0.4152 |
| dot_recall@10 | 0.5011 |
| dot_ndcg@10 | 0.4016 |
| dot_mrr@10 | 0.4195 |
| dot_map@100 | 0.3082 |
| query_active_dims | 138.12 |
| query_sparsity_ratio | 0.9955 |
| corpus_active_dims | 346.3697 |
| corpus_sparsity_ratio | 0.9887 |
NanoBEIR_meanSparseNanoBEIREvaluator with these parameters:
1{
2 "dataset_names": [
3 "climatefever",
4 "dbpedia",
5 "fever",
6 "fiqa2018",
7 "hotpotqa",
8 "msmarco",
9 "nfcorpus",
10 "nq",
11 "quoraretrieval",
12 "scidocs",
13 "arguana",
14 "scifact",
15 "touche2020"
16 ]
17}| Metric | Value |
|---|---|
| dot_accuracy@1 | 0.4302 |
| dot_accuracy@3 | 0.6182 |
| dot_accuracy@5 | 0.6783 |
| dot_accuracy@10 | 0.7722 |
| dot_precision@1 | 0.4302 |
| dot_precision@3 | 0.2742 |
| dot_precision@5 | 0.2152 |
| dot_precision@10 | 0.1564 |
| dot_recall@1 | 0.2433 |
| dot_recall@3 | 0.3891 |
| dot_recall@5 | 0.4466 |
| dot_recall@10 | 0.5378 |
| dot_ndcg@10 | 0.4809 |
| dot_mrr@10 | 0.5383 |
| dot_map@100 | 0.4055 |
| query_active_dims | 161.5901 |
| query_sparsity_ratio | 0.9947 |
| corpus_active_dims | 302.8481 |
| corpus_sparsity_ratio | 0.9901 |
question and answer| question | answer | |
|---|---|---|
| type | string | string |
| details |
|
|
| question | answer |
|---|---|
what are the 5 characteristics of a star? | Key Concept: Characteristics used to classify stars include color, temperature, size, composition, and brightness. |
are copic markers alcohol ink? | Copic Ink is alcohol-based and flammable. Keep away from direct sunlight and extreme temperatures. |
what is the difference between appellate term and appellate division? | 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. |
SpladeLoss with these parameters:
1{
2 "loss": "SparseMultipleNegativesRankingLoss(scale=1.0, similarity_fct='dot_score')",
3 "lambda_corpus": 3e-05,
4 "lambda_query": 5e-05
5}question and answer| question | answer | |
|---|---|---|
| type | string | string |
| details |
|
|
| question | answer |
|---|---|
should you take ibuprofen with high blood pressure? | 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. |
how old do you have to be to work in sc? | 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. |
how to write a topic proposal for a research paper? | ['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.'] |
SpladeLoss with these parameters:
1{
2 "loss": "SparseMultipleNegativesRankingLoss(scale=1.0, similarity_fct='dot_score')",
3 "lambda_corpus": 3e-05,
4 "lambda_query": 5e-05
5}eval_strategy: stepsper_device_train_batch_size: 32per_device_eval_batch_size: 32learning_rate: 2e-05num_train_epochs: 1bf16: Trueload_best_model_at_end: Truebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 32per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 1max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.0warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falseuse_ipex: Falsebf16: Truefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Trueignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}tp_size: 0fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseinclude_for_metrics: []eval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters:auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Nonedispatch_batches: Nonesplit_batches: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | Validation Loss | NanoMSMARCO_dot_ndcg@10 | NanoNFCorpus_dot_ndcg@10 | NanoNQ_dot_ndcg@10 | NanoBEIR_mean_dot_ndcg@10 | NanoClimateFEVER_dot_ndcg@10 | NanoDBPedia_dot_ndcg@10 | NanoFEVER_dot_ndcg@10 | NanoFiQA2018_dot_ndcg@10 | NanoHotpotQA_dot_ndcg@10 | NanoQuoraRetrieval_dot_ndcg@10 | NanoSCIDOCS_dot_ndcg@10 | NanoArguAna_dot_ndcg@10 | NanoSciFact_dot_ndcg@10 | NanoTouche2020_dot_ndcg@10 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0.0323 | 100 | 15.2006 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.0646 | 200 | 0.2384 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.0970 | 300 | 0.1932 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.1293 | 400 | 0.1428 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.1616 | 500 | 0.144 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.1939 | 600 | 0.1345 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.1972 | 610 | - | 0.1199 | 0.4364 | 0.2195 | 0.4998 | 0.3853 | - | - | - | - | - | - | - | - | - | - |
| 0.2262 | 700 | 0.1406 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.2586 | 800 | 0.1012 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.2909 | 900 | 0.112 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.3232 | 1000 | 0.0736 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.3555 | 1100 | 0.0943 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.3878 | 1200 | 0.0901 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.3943 | 1220 | - | 0.1126 | 0.4706 | 0.2490 | 0.5154 | 0.4117 | - | - | - | - | - | - | - | - | - | - |
| 0.4202 | 1300 | 0.0988 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.4525 | 1400 | 0.0953 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.4848 | 1500 | 0.1145 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.5171 | 1600 | 0.0928 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.5495 | 1700 | 0.0963 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.5818 | 1800 | 0.0724 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.5915 | 1830 | - | 0.0736 | 0.4576 | 0.2457 | 0.5015 | 0.4016 | - | - | - | - | - | - | - | - | - | - |
| 0.6141 | 1900 | 0.0753 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.6464 | 2000 | 0.0657 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.6787 | 2100 | 0.0741 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.7111 | 2200 | 0.0671 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.7434 | 2300 | 0.1013 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.7757 | 2400 | 0.0795 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.7886 | 2440 | - | 0.0719 | 0.4785 | 0.2816 | 0.519 | 0.4264 | - | - | - | - | - | - | - | - | - | - |
| 0.8080 | 2500 | 0.0666 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.8403 | 2600 | 0.0589 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.8727 | 2700 | 0.0569 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.9050 | 2800 | 0.0754 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.9373 | 2900 | 0.0724 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.9696 | 3000 | 0.0658 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.9858 | 3050 | - | 0.0661 | 0.4447 | 0.2587 | 0.5014 | 0.4016 | - | - | - | - | - | - | - | - | - | - |
| -1 | -1 | - | - | 0.4785 | 0.2816 | 0.5190 | 0.4809 | 0.2528 | 0.4305 | 0.7203 | 0.3784 | 0.6986 | 0.7379 | 0.3073 | 0.3141 | 0.6331 | 0.4998 |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}1@misc{formal2022distillationhardnegativesampling,
2 title={From Distillation to Hard Negative Sampling: Making Sparse Neural IR Models More Effective},
3 author={Thibault Formal and Carlos Lassance and Benjamin Piwowarski and Stéphane Clinchant},
4 year={2022},
5 eprint={2205.04733},
6 archivePrefix={arXiv},
7 primaryClass={cs.IR},
8 url={https://arxiv.org/abs/2205.04733},
9}1@misc{henderson2017efficient,
2 title={Efficient Natural Language Response Suggestion for Smart Reply},
3 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},
4 year={2017},
5 eprint={1705.00652},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}1@article{paria2020minimizing,
2 title={Minimizing flops to learn efficient sparse representations},
3 author={Paria, Biswajit and Yeh, Chih-Kuan and Yen, Ian EH and Xu, Ning and Ravikumar, Pradeep and P{'o}czos, Barnab{'a}s},
4 journal={arXiv preprint arXiv:2004.05665},
5 year={2020}
6 }