Views
No views yet
SparseEncoder(
(0): Transformer({'transformer_task': 'fill-mask', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}}, 'module_output_name': 'token_embeddings', 'architecture': 'ModernBertForMaskedLM'})
(1): SpladePooling({'pooling_strategy': 'max', 'activation_function': 'relu', 'embedding_dimension': 50368})
)pip install -U sentence-transformers1from sentence_transformers import SparseEncoder
2
3# Download from the 🤗 Hub
4model = SparseEncoder("capemox/splade-ettin-encoder-17m-gooaq")
5# Run inference
6sentences = [
7 'how close is the closest star?',
8 'The two main stars are Alpha Centauri A and Alpha Centauri B, which form a binary pair. They are an average of 4.3 light-years from Earth. The third star is Proxima Centauri. It is about 4.22 light-years from Earth and is the closest star other than the sun.',
9 'One gallon can of paint will cover up to 400 square feet, which is enough to cover a small room like a bathroom. Two gallon cans of paint cover up to 800 square feet, which is enough to cover an average size room. This is the most common amount needed, especially when considering second coat coverage.',
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# [3, 50368]
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities)
18# tensor([[144.9772, 158.3885, 140.6785],
19# [158.3885, 496.0056, 344.2902],
20# [140.6785, 344.2902, 528.3322]])NanoMSMARCO_256, NanoNFCorpus_256, NanoNQ_256, NanoClimateFEVER_256, NanoDBPedia_256, NanoFEVER_256, NanoFiQA2018_256, NanoHotpotQA_256, NanoMSMARCO_256, NanoNFCorpus_256, NanoNQ_256, NanoQuoraRetrieval_256, NanoSCIDOCS_256, NanoArguAna_256, NanoSciFact_256 and NanoTouche2020_256SparseInformationRetrievalEvaluator with these parameters:
1{
2 "max_active_dims": 256
3}| Metric | NanoMSMARCO_256 | NanoNFCorpus_256 | NanoNQ_256 | NanoClimateFEVER_256 | NanoDBPedia_256 | NanoFEVER_256 | NanoFiQA2018_256 | NanoHotpotQA_256 | NanoQuoraRetrieval_256 | NanoSCIDOCS_256 | NanoArguAna_256 | NanoSciFact_256 | NanoTouche2020_256 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| dot_accuracy@1 | 0.2 | 0.22 | 0.1 | 0.2 | 0.4 | 0.34 | 0.18 | 0.58 | 0.16 | 0.34 | 0.04 | 0.3 | 0.4898 |
| dot_accuracy@3 | 0.34 | 0.34 | 0.28 | 0.38 | 0.66 | 0.7 | 0.3 | 0.7 | 0.38 | 0.5 | 0.32 | 0.44 | 0.7755 |
| dot_accuracy@5 | 0.42 | 0.38 | 0.4 | 0.42 | 0.74 | 0.78 | 0.4 | 0.78 | 0.4 | 0.58 | 0.42 | 0.64 | 0.8776 |
| dot_accuracy@10 | 0.6 | 0.52 | 0.54 | 0.48 | 0.84 | 0.92 | 0.44 | 0.84 | 0.46 | 0.72 | 0.48 | 0.7 | 0.9796 |
| dot_precision@1 | 0.2 | 0.22 | 0.1 | 0.2 | 0.4 | 0.34 | 0.18 | 0.58 | 0.16 | 0.34 | 0.04 | 0.3 | 0.4898 |
| dot_precision@3 | 0.1133 | 0.1933 | 0.0933 | 0.1267 | 0.3733 | 0.2333 | 0.14 | 0.32 | 0.1267 | 0.22 | 0.1067 | 0.1533 | 0.4218 |
| dot_precision@5 | 0.084 | 0.18 | 0.08 | 0.092 | 0.348 | 0.156 | 0.124 | 0.216 | 0.08 | 0.18 | 0.084 | 0.14 | 0.4 |
| dot_precision@10 | 0.06 | 0.14 | 0.058 | 0.066 | 0.324 | 0.094 | 0.074 | 0.126 | 0.048 | 0.138 | 0.048 | 0.078 | 0.3469 |
| dot_recall@1 | 0.2 | 0.0069 | 0.09 | 0.085 | 0.0438 | 0.3067 | 0.0822 | 0.29 | 0.16 | 0.0727 | 0.04 | 0.275 | 0.034 |
| dot_recall@3 | 0.34 | 0.0187 | 0.25 | 0.1783 | 0.0853 | 0.6567 | 0.1734 | 0.48 | 0.354 | 0.1377 | 0.32 | 0.42 | 0.0824 |
| dot_recall@5 | 0.42 | 0.0306 | 0.36 | 0.2 | 0.1356 | 0.7367 | 0.2406 | 0.54 | 0.374 | 0.1857 | 0.42 | 0.61 | 0.1281 |
| dot_recall@10 | 0.6 | 0.0458 | 0.52 | 0.26 | 0.2097 | 0.8767 | 0.2906 | 0.63 | 0.444 | 0.2837 | 0.48 | 0.68 | 0.2193 |
| dot_ndcg@10 | 0.3714 | 0.1571 | 0.2925 | 0.2151 | 0.3792 | 0.5965 | 0.2237 | 0.5601 | 0.3147 | 0.2673 | 0.2567 | 0.4731 | 0.389 |
| dot_mrr@10 | 0.302 | 0.2964 | 0.2323 | 0.2989 | 0.5519 | 0.5313 | 0.2532 | 0.6587 | 0.277 | 0.4424 | 0.1845 | 0.4177 | 0.6561 |
| dot_map@100 | 0.3209 | 0.0466 | 0.2305 | 0.1742 | 0.2587 | 0.4997 | 0.1863 | 0.494 | 0.2826 | 0.1904 | 0.1898 | 0.4079 | 0.27 |
| query_active_dims | 252.1 | 255.62 | 256.0 | 256.0 | 253.96 | 256.0 | 240.22 | 256.0 | 229.0 | 256.0 | 256.0 | 256.0 | 216.8571 |
| query_sparsity_ratio | 0.995 | 0.9949 | 0.9949 | 0.9949 | 0.995 | 0.9949 | 0.9952 | 0.9949 | 0.9955 | 0.9949 | 0.9949 | 0.9949 | 0.9957 |
| corpus_active_dims | 256.0 | 256.0 | 256.0 | 256.0 | 256.0 | 256.0 | 256.0 | 256.0 | 234.9956 | 256.0 | 256.0 | 256.0 | 255.9241 |
| corpus_sparsity_ratio | 0.9949 | 0.9949 | 0.9949 | 0.9949 | 0.9949 | 0.9949 | 0.9949 | 0.9949 | 0.9953 | 0.9949 | 0.9949 | 0.9949 | 0.9949 |
| avg_flops | 104.6667 | 101.2659 | 114.127 | 129.3998 | 108.9664 | 120.7999 | 116.0173 | 114.6017 | 119.7198 | 123.3701 | 150.7188 | 129.6654 | 86.4117 |
NanoBEIR_mean_256SparseNanoBEIREvaluator with these parameters:
1{
2 "dataset_names": [
3 "msmarco",
4 "nfcorpus",
5 "nq"
6 ],
7 "dataset_id": "sentence-transformers/NanoBEIR-en",
8 "max_active_dims": 256
9}| Metric | Value |
|---|---|
| dot_accuracy@1 | 0.18 |
| dot_accuracy@3 | 0.3267 |
| dot_accuracy@5 | 0.42 |
| dot_accuracy@10 | 0.54 |
| dot_precision@1 | 0.18 |
| dot_precision@3 | 0.1356 |
| dot_precision@5 | 0.1173 |
| dot_precision@10 | 0.0867 |
| dot_recall@1 | 0.0991 |
| dot_recall@3 | 0.2158 |
| dot_recall@5 | 0.2848 |
| dot_recall@10 | 0.379 |
| dot_ndcg@10 | 0.273 |
| dot_mrr@10 | 0.2783 |
| dot_map@100 | 0.1991 |
| query_active_dims | 254.54 |
| query_sparsity_ratio | 0.9949 |
| corpus_active_dims | 256.0 |
| corpus_sparsity_ratio | 0.9949 |
| avg_flops | 105.0486 |
NanoBEIR_mean_256SparseNanoBEIREvaluator 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 "dataset_id": "sentence-transformers/NanoBEIR-en",
18 "max_active_dims": 256
19}| Metric | Value |
|---|---|
| dot_accuracy@1 | 0.2731 |
| dot_accuracy@3 | 0.4704 |
| dot_accuracy@5 | 0.5567 |
| dot_accuracy@10 | 0.6554 |
| dot_precision@1 | 0.2731 |
| dot_precision@3 | 0.2017 |
| dot_precision@5 | 0.1665 |
| dot_precision@10 | 0.1231 |
| dot_recall@1 | 0.1297 |
| dot_recall@3 | 0.269 |
| dot_recall@5 | 0.337 |
| dot_recall@10 | 0.4261 |
| dot_ndcg@10 | 0.3459 |
| dot_mrr@10 | 0.3925 |
| dot_map@100 | 0.2732 |
| query_active_dims | 249.2619 |
| query_sparsity_ratio | 0.9951 |
| corpus_active_dims | 254.1114 |
| corpus_sparsity_ratio | 0.995 |
| avg_flops | 109.026 |
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', gather_across_devices=False, directions=('query_to_doc',), partition_mode='joint', hardness_mode=None, hardness_strength=0.0)",
3 "document_regularizer_weight": 3e-05,
4 "query_regularizer_weight": 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', gather_across_devices=False, directions=('query_to_doc',), partition_mode='joint', hardness_mode=None, hardness_strength=0.0)",
3 "document_regularizer_weight": 3e-05,
4 "query_regularizer_weight": 5e-05
5}per_device_train_batch_size: 32num_train_epochs: 1learning_rate: 2e-05bf16: Trueper_device_eval_batch_size: 32load_best_model_at_end: Truebatch_sampler: no_duplicatesper_device_train_batch_size: 32num_train_epochs: 1max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0optim: 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: trackioper_device_eval_batch_size: 32prediction_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_256_dot_ndcg@10 | NanoNFCorpus_256_dot_ndcg@10 | NanoNQ_256_dot_ndcg@10 | NanoBEIR_mean_256_dot_ndcg@10 | NanoClimateFEVER_256_dot_ndcg@10 | NanoDBPedia_256_dot_ndcg@10 | NanoFEVER_256_dot_ndcg@10 | NanoFiQA2018_256_dot_ndcg@10 | NanoHotpotQA_256_dot_ndcg@10 | NanoQuoraRetrieval_256_dot_ndcg@10 | NanoSCIDOCS_256_dot_ndcg@10 | NanoArguAna_256_dot_ndcg@10 | NanoSciFact_256_dot_ndcg@10 | NanoTouche2020_256_dot_ndcg@10 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0.0323 | 100 | 954.7106 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.0646 | 200 | 17.8241 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.0970 | 300 | 4.5136 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.1293 | 400 | 2.5427 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.1616 | 500 | 1.4733 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.1939 | 600 | 1.0940 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.1972 | 610 | - | 0.8522 | 0.1440 | 0.0453 | 0.0771 | 0.0888 | - | - | - | - | - | - | - | - | - | - |
| 0.2262 | 700 | 0.7541 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.2586 | 800 | 0.7425 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.2909 | 900 | 0.5966 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.3232 | 1000 | 0.5606 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.3555 | 1100 | 0.5440 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.3878 | 1200 | 0.4032 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.3943 | 1220 | - | 0.4165 | 0.2494 | 0.0613 | 0.2065 | 0.1724 | - | - | - | - | - | - | - | - | - | - |
| 0.4202 | 1300 | 0.3995 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.4525 | 1400 | 0.2976 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.4848 | 1500 | 0.2971 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.5171 | 1600 | 0.2716 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.5495 | 1700 | 0.2577 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.5818 | 1800 | 0.2370 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.5915 | 1830 | - | 0.2104 | 0.3406 | 0.1173 | 0.2414 | 0.2331 | - | - | - | - | - | - | - | - | - | - |
| 0.6141 | 1900 | 0.2360 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.6464 | 2000 | 0.2238 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.6787 | 2100 | 0.2237 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.7111 | 2200 | 0.2162 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.7434 | 2300 | 0.2044 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.7757 | 2400 | 0.2202 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.7886 | 2440 | - | 0.1736 | 0.3932 | 0.1545 | 0.2717 | 0.2731 | - | - | - | - | - | - | - | - | - | - |
| 0.8080 | 2500 | 0.1672 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.8403 | 2600 | 0.2122 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.8727 | 2700 | 0.1704 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.9050 | 2800 | 0.1870 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.9373 | 2900 | 0.1671 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.9696 | 3000 | 0.1386 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.9858 | 3050 | - | 0.17 | 0.3714 | 0.1571 | 0.2925 | 0.2737 | - | - | - | - | - | - | - | - | - | - |
| 1.0 | 3094 | - | 0.1706 | 0.3675 | 0.1624 | 0.2892 | 0.2730 | - | - | - | - | - | - | - | - | - | - |
| -1 | -1 | - | - | 0.3714 | 0.1571 | 0.2925 | 0.3459 | 0.2151 | 0.3792 | 0.5965 | 0.2237 | 0.5601 | 0.3147 | 0.2673 | 0.2567 | 0.4731 | 0.3890 |
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{oord2019representationlearningcontrastivepredictive,
2 title={Representation Learning with Contrastive Predictive Coding},
3 author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
4 year={2019},
5 eprint={1807.03748},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG},
8 url={https://arxiv.org/abs/1807.03748},
9}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}