Sparse CSR model trained on Natural Questions

This is a CSR Sparse Encoder model finetuned from mixedbread-ai/mxbai-embed-large-v1 on the gooaq dataset using the sentence-transformers library. It maps sentences & paragraphs to a 4096-dimensional sparse vector space and can be used for semantic search and sparse retrieval.

Model Details

Model Description

  • Model Type: CSR Sparse Encoder
  • Base model: mixedbread-ai/mxbai-embed-large-v1
  • Maximum Sequence Length: 512 tokens
  • Output Dimensionality: 4096 dimensions
  • Similarity Function: Dot Product
  • Training Dataset:
  • Language: en
  • License: apache-2.0

Model Sources

Full Model Architecture

SparseEncoder(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel 
  (1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
  (2): CSRSparsity({'input_dim': 1024, 'hidden_dim': 4096, 'k': 256, 'k_aux': 512, 'normalize': False, 'dead_threshold': 30})
)

Usage

Direct Usage (Sentence Transformers)

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/csr-mxbai-embed-large-v1-gooaq-1e-5-512bs")
# Run inference
sentences = [
    'are you human korean novela?',
    "Are You Human? (Korean: 너도 인간이니; RR: Neodo Inganini; lit. Are You Human Too?) is a 2018 South Korean television series starring Seo Kang-jun and Gong Seung-yeon. It aired on KBS2's Mondays and Tuesdays at 22:00 (KST) time slot, from June 4 to August 7, 2018.",
    'A relative of European pear varieties like Bartlett and Anjou, the Asian pear is great used in recipes or simply eaten out of hand. It retains a crispness that works well in slaws and salads, and it holds its shape better than European pears when baked and cooked.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# (3, 4096)

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]

Evaluation

Metrics

Sparse Information Retrieval

Metric NanoMSMARCO_128 NanoNFCorpus_128 NanoNQ_128
dot_accuracy@1 0.36 0.36 0.38
dot_accuracy@3 0.64 0.46 0.58
dot_accuracy@5 0.74 0.52 0.66
dot_accuracy@10 0.86 0.68 0.78
dot_precision@1 0.36 0.36 0.38
dot_precision@3 0.2133 0.32 0.2
dot_precision@5 0.148 0.28 0.136
dot_precision@10 0.086 0.246 0.082
dot_recall@1 0.36 0.0215 0.37
dot_recall@3 0.64 0.048 0.54
dot_recall@5 0.74 0.0637 0.62
dot_recall@10 0.86 0.0979 0.73
dot_ndcg@10 0.6055 0.2819 0.5492
dot_mrr@10 0.5249 0.4416 0.5042
dot_map@100 0.53 0.1105 0.4927
row_non_zero_mean_query 128.0 128.0 128.0
row_sparsity_mean_query 0.9688 0.9688 0.9688
row_non_zero_mean_corpus 128.0 128.0 128.0
row_sparsity_mean_corpus 0.9688 0.9688 0.9688

Sparse Nano BEIR

  • Dataset: NanoBEIR_mean_128
  • Evaluated with SparseNanoBEIREvaluator with these parameters:
    {
        "dataset_names": [
            "msmarco",
            "nfcorpus",
            "nq"
        ],
        "max_active_dims": 128
    }
    
Metric Value
dot_accuracy@1 0.3667
dot_accuracy@3 0.56
dot_accuracy@5 0.64
dot_accuracy@10 0.7733
dot_precision@1 0.3667
dot_precision@3 0.2444
dot_precision@5 0.188
dot_precision@10 0.138
dot_recall@1 0.2505
dot_recall@3 0.4093
dot_recall@5 0.4746
dot_recall@10 0.5626
dot_ndcg@10 0.4789
dot_mrr@10 0.4902
dot_map@100 0.3777
row_non_zero_mean_query 128.0
row_sparsity_mean_query 0.9688
row_non_zero_mean_corpus 128.0
row_sparsity_mean_corpus 0.9688

Sparse Information Retrieval

Metric NanoMSMARCO_256 NanoNFCorpus_256 NanoNQ_256
dot_accuracy@1 0.44 0.32 0.44
dot_accuracy@3 0.64 0.48 0.68
dot_accuracy@5 0.74 0.6 0.72
dot_accuracy@10 0.9 0.72 0.82
dot_precision@1 0.44 0.32 0.44
dot_precision@3 0.2133 0.34 0.2333
dot_precision@5 0.148 0.316 0.152
dot_precision@10 0.09 0.274 0.086
dot_recall@1 0.44 0.0394 0.42
dot_recall@3 0.64 0.073 0.63
dot_recall@5 0.74 0.0953 0.68
dot_recall@10 0.9 0.1342 0.77
dot_ndcg@10 0.6594 0.3211 0.6015
dot_mrr@10 0.5844 0.4373 0.565
dot_map@100 0.5877 0.1478 0.5493
row_non_zero_mean_query 256.0 256.0 256.0
row_sparsity_mean_query 0.9375 0.9375 0.9375
row_non_zero_mean_corpus 256.0 256.0 256.0
row_sparsity_mean_corpus 0.9375 0.9375 0.9375

Sparse Nano BEIR

  • Dataset: NanoBEIR_mean_256
  • Evaluated with SparseNanoBEIREvaluator with these parameters:
    {
        "dataset_names": [
            "msmarco",
            "nfcorpus",
            "nq"
        ],
        "max_active_dims": 256
    }
    
Metric Value
dot_accuracy@1 0.4
dot_accuracy@3 0.6
dot_accuracy@5 0.6867
dot_accuracy@10 0.8133
dot_precision@1 0.4
dot_precision@3 0.2622
dot_precision@5 0.2053
dot_precision@10 0.15
dot_recall@1 0.2998
dot_recall@3 0.4477
dot_recall@5 0.5051
dot_recall@10 0.6014
dot_ndcg@10 0.5273
dot_mrr@10 0.5289
dot_map@100 0.4283
row_non_zero_mean_query 256.0
row_sparsity_mean_query 0.9375
row_non_zero_mean_corpus 256.0
row_sparsity_mean_corpus 0.9375

Training Details

Training Dataset

gooaq

  • Dataset: gooaq at b089f72
  • Size: 3,011,496 training samples
  • Columns: question and answer
  • Approximate statistics based on the first 1000 samples:
    question answer
    type string string
    details
    • min: 8 tokens
    • mean: 11.87 tokens
    • max: 23 tokens
    • min: 14 tokens
    • mean: 60.09 tokens
    • max: 201 tokens
  • Samples:
    question answer
    what is the difference between clay and mud mask? The main difference between the two is that mud is a skin-healing agent, while clay is a cosmetic, drying agent. Clay masks are most useful for someone who has oily skin and is prone to breakouts of acne and blemishes.
    myki how much on card? A full fare myki card costs $6 and a concession, seniors or child myki costs $3. For more information about how to use your myki, visit ptv.vic.gov.au or call 1800 800 007.
    how to find out if someone blocked your phone number on iphone? If you get a notification like "Message Not Delivered" or you get no notification at all, that's a sign of a potential block. Next, you could try calling the person. If the call goes right to voicemail or rings once (or a half ring) then goes to voicemail, that's further evidence you may have been blocked.
  • Loss: CSRLoss with these parameters:
    {
        "beta": 0.1,
        "gamma": 1.0,
        "loss": "SparseMultipleNegativesRankingLoss(scale=1.0, similarity_fct='dot_score')"
    }
    

Evaluation Dataset

gooaq

  • Dataset: gooaq at b089f72
  • Size: 1,000 evaluation samples
  • Columns: question and answer
  • Approximate statistics based on the first 1000 samples:
    question answer
    type string string
    details
    • min: 8 tokens
    • mean: 11.88 tokens
    • max: 22 tokens
    • min: 14 tokens
    • mean: 61.03 tokens
    • max: 127 tokens
  • Samples:
    question answer
    how do i program my directv remote with my tv? ['Press MENU on your remote.', 'Select Settings & Help > Settings > Remote Control > Program Remote.', 'Choose the device (TV, audio, DVD) you wish to program. ... ', 'Follow the on-screen prompts to complete programming.']
    are rodrigues fruit bats nocturnal? Before its numbers were threatened by habitat destruction, storms, and hunting, some of those groups could number 500 or more members. Sunrise, sunset. Rodrigues fruit bats are most active at dawn, at dusk, and at night.
    why does your heart rate increase during exercise bbc bitesize? During exercise there is an increase in physical activity and muscle cells respire more than they do when the body is at rest. The heart rate increases during exercise. The rate and depth of breathing increases - this makes sure that more oxygen is absorbed into the blood, and more carbon dioxide is removed from it.
  • Loss: CSRLoss with these parameters:
    {
        "beta": 0.1,
        "gamma": 1.0,
        "loss": "SparseMultipleNegativesRankingLoss(scale=1.0, similarity_fct='dot_score')"
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 512
  • per_device_eval_batch_size: 512
  • learning_rate: 1e-05
  • num_train_epochs: 1
  • warmup_ratio: 0.1
  • bf16: True
  • load_best_model_at_end: True
  • batch_sampler: no_duplicates

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 512
  • per_device_eval_batch_size: 512
  • 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: 1e-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.1
  • 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: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': 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

Training Logs

Epoch Step Training Loss Validation Loss NanoMSMARCO_128_dot_ndcg@10 NanoNFCorpus_128_dot_ndcg@10 NanoNQ_128_dot_ndcg@10 NanoBEIR_mean_128_dot_ndcg@10 NanoMSMARCO_256_dot_ndcg@10 NanoNFCorpus_256_dot_ndcg@10 NanoNQ_256_dot_ndcg@10 NanoBEIR_mean_256_dot_ndcg@10
-1 -1 - - 0.6421 0.2724 0.5528 0.4891 0.6425 0.2985 0.6194 0.5201
0.0170 100 0.5414 - - - - - - - - -
0.0340 200 0.5387 - - - - - - - - -
0.0510 300 0.5183 - - - - - - - - -
0.0680 400 0.5215 - - - - - - - - -
0.0850 500 0.5011 - - - - - - - - -
0.1020 600 0.5 - - - - - - - - -
0.1190 700 0.4885 - - - - - - - - -
0.1360 800 0.4777 0.3915 0.6173 0.2782 0.5465 0.4807 0.6406 0.3038 0.6318 0.5254
0.1530 900 0.4793 - - - - - - - - -
0.1700 1000 0.472 - - - - - - - - -
0.1870 1100 0.4679 - - - - - - - - -
0.2040 1200 0.4666 - - - - - - - - -
0.2210 1300 0.4569 - - - - - - - - -
0.2380 1400 0.4642 - - - - - - - - -
0.2550 1500 0.4611 - - - - - - - - -
0.272 1600 0.4537 0.3851 0.6314 0.266 0.5664 0.4879 0.6451 0.3238 0.6363 0.5351
0.2890 1700 0.4554 - - - - - - - - -
0.3060 1800 0.4475 - - - - - - - - -
0.3230 1900 0.4512 - - - - - - - - -
0.3400 2000 0.4522 - - - - - - - - -
0.3570 2100 0.4475 - - - - - - - - -
0.3740 2200 0.4499 - - - - - - - - -
0.3910 2300 0.4467 - - - - - - - - -
0.4080 2400 0.4467 0.3940 0.6264 0.2643 0.5719 0.4875 0.6092 0.3350 0.6363 0.5268
0.4250 2500 0.4477 - - - - - - - - -
0.4420 2600 0.4466 - - - - - - - - -
0.4590 2700 0.4436 - - - - - - - - -
0.4760 2800 0.4434 - - - - - - - - -
0.4930 2900 0.4437 - - - - - - - - -
0.5100 3000 0.4381 - - - - - - - - -
0.5270 3100 0.4426 - - - - - - - - -
0.5440 3200 0.4461 0.3850 0.5866 0.2857 0.5567 0.4763 0.6232 0.3313 0.6220 0.5255
0.5610 3300 0.4453 - - - - - - - - -
0.5780 3400 0.4361 - - - - - - - - -
0.5950 3500 0.436 - - - - - - - - -
0.6120 3600 0.4444 - - - - - - - - -
0.6290 3700 0.4405 - - - - - - - - -
0.6460 3800 0.4346 - - - - - - - - -
0.6630 3900 0.4345 - - - - - - - - -
0.6800 4000 0.4399 0.3857 0.5963 0.2898 0.5537 0.4800 0.6479 0.3129 0.6058 0.5222
0.6970 4100 0.434 - - - - - - - - -
0.7140 4200 0.4353 - - - - - - - - -
0.7310 4300 0.4277 - - - - - - - - -
0.7480 4400 0.4361 - - - - - - - - -
0.7650 4500 0.445 - - - - - - - - -
0.7820 4600 0.4331 - - - - - - - - -
0.7990 4700 0.4329 - - - - - - - - -
0.8160 4800 0.4336 0.3827 0.5929 0.2894 0.5617 0.4813 0.6444 0.3241 0.6120 0.5268
0.8330 4900 0.4319 - - - - - - - - -
0.8501 5000 0.4342 - - - - - - - - -
0.8671 5100 0.439 - - - - - - - - -
0.8841 5200 0.434 - - - - - - - - -
0.9011 5300 0.4396 - - - - - - - - -
0.9181 5400 0.4355 - - - - - - - - -
0.9351 5500 0.4326 - - - - - - - - -
0.9521 5600 0.4304 0.3810 0.6055 0.2819 0.5492 0.4789 0.6594 0.3211 0.6015 0.5273
0.9691 5700 0.4316 - - - - - - - - -
0.9861 5800 0.427 - - - - - - - - -
  • The bold row denotes the saved checkpoint.

Environmental Impact

Carbon emissions were measured using CodeCarbon.

  • Energy Consumed: 0.906 kWh
  • Carbon Emitted: 0.352 kg of CO2
  • Hours Used: 2.117 hours

Training Hardware

  • On Cloud: No
  • GPU Model: 1 x NVIDIA GeForce RTX 3090
  • CPU Model: 13th Gen Intel(R) Core(TM) i7-13700K
  • RAM Size: 31.78 GB

Framework Versions

  • Python: 3.11.6
  • Sentence Transformers: 4.2.0.dev0
  • Transformers: 4.49.0
  • PyTorch: 2.6.0+cu124
  • Accelerate: 1.5.1
  • Datasets: 2.21.0
  • Tokenizers: 0.21.1

Citation

BibTeX

Sentence Transformers

@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",
}

CSRLoss

@misc{wen2025matryoshkarevisitingsparsecoding,
      title={Beyond Matryoshka: Revisiting Sparse Coding for Adaptive Representation},
      author={Tiansheng Wen and Yifei Wang and Zequn Zeng and Zhong Peng and Yudi Su and Xinyang Liu and Bo Chen and Hongwei Liu and Stefanie Jegelka and Chenyu You},
      year={2025},
      eprint={2503.01776},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2503.01776},
}

SparseMultipleNegativesRankingLoss

@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}
}
Downloads last month
0
Safetensors
Model size
335M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for tomaarsen/csr-mxbai-embed-large-v1-gooaq-1e-5-512bs

Finetuned
(20)
this model

Dataset used to train tomaarsen/csr-mxbai-embed-large-v1-gooaq-1e-5-512bs

Evaluation results