CoolFace
Modelpublic

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

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

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 <!-- at revision db9d1fe0f31addb4978201b2bf3e577f3f8900d2 -->
  • —Maximum Sequence Length: 512 tokens
  • —Output Dimensionality: 4096 dimensions
  • —Similarity Function: Dot Product
  • —Training Dataset:
  • —gooaq
  • —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:

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("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]

<!--

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
json
  {
      "max_active_dims": 128
  }
MetricNanoMSMARCO_128NanoNFCorpus_128NanoNQ_128
dot_accuracy@10.360.360.38
dot_accuracy@30.640.460.58
dot_accuracy@50.740.520.66
dot_accuracy@100.860.680.78
dot_precision@10.360.360.38
dot_precision@30.21330.320.2
dot_precision@50.1480.280.136
dot_precision@100.0860.2460.082
dot_recall@10.360.02150.37
dot_recall@30.640.0480.54
dot_recall@50.740.06370.62
dot_recall@100.860.09790.73
dot_ndcg@100.60550.28190.5492
dot_mrr@100.52490.44160.5042
dot_map@1000.530.11050.4927
rownonzeromeanquery128.0128.0128.0
rowsparsitymean_query0.96880.96880.9688
rownonzeromeancorpus128.0128.0128.0
rowsparsitymean_corpus0.96880.96880.9688
Sparse Nano BEIR
json
  {
      "dataset_names": [
          "msmarco",
          "nfcorpus",
          "nq"
      ],
      "max_active_dims": 128
  }
MetricValue
dot_accuracy@10.3667
dot_accuracy@30.56
dot_accuracy@50.64
dot_accuracy@100.7733
dot_precision@10.3667
dot_precision@30.2444
dot_precision@50.188
dot_precision@100.138
dot_recall@10.2505
dot_recall@30.4093
dot_recall@50.4746
dot_recall@100.5626
dot_ndcg@100.4789
dot_mrr@100.4902
dot_map@1000.3777
rownonzeromeanquery128.0
rowsparsitymean_query0.9688
rownonzeromeancorpus128.0
rowsparsitymean_corpus0.9688
Sparse Information Retrieval
json
  {
      "max_active_dims": 256
  }
MetricNanoMSMARCO_256NanoNFCorpus_256NanoNQ_256
dot_accuracy@10.440.320.44
dot_accuracy@30.640.480.68
dot_accuracy@50.740.60.72
dot_accuracy@100.90.720.82
dot_precision@10.440.320.44
dot_precision@30.21330.340.2333
dot_precision@50.1480.3160.152
dot_precision@100.090.2740.086
dot_recall@10.440.03940.42
dot_recall@30.640.0730.63
dot_recall@50.740.09530.68
dot_recall@100.90.13420.77
dot_ndcg@100.65940.32110.6015
dot_mrr@100.58440.43730.565
dot_map@1000.58770.14780.5493
rownonzeromeanquery256.0256.0256.0
rowsparsitymean_query0.93750.93750.9375
rownonzeromeancorpus256.0256.0256.0
rowsparsitymean_corpus0.93750.93750.9375
Sparse Nano BEIR
json
  {
      "dataset_names": [
          "msmarco",
          "nfcorpus",
          "nq"
      ],
      "max_active_dims": 256
  }
MetricValue
dot_accuracy@10.4
dot_accuracy@30.6
dot_accuracy@50.6867
dot_accuracy@100.8133
dot_precision@10.4
dot_precision@30.2622
dot_precision@50.2053
dot_precision@100.15
dot_recall@10.2998
dot_recall@30.4477
dot_recall@50.5051
dot_recall@100.6014
dot_ndcg@100.5273
dot_mrr@100.5289
dot_map@1000.4283
rownonzeromeanquery256.0
rowsparsitymean_query0.9375
rownonzeromeancorpus256.0
rowsparsitymean_corpus0.9375

<!--

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: 3,011,496 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.87 tokens</li><li>max: 23 tokens</li></ul> | <ul><li>min: 14 tokens</li><li>mean: 60.09 tokens</li><li>max: 201 tokens</li></ul> |
  • —Samples: | question | answer | |:-----------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>what is the difference between clay and mud mask?</code> | <code>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.</code> | | <code>myki how much on card?</code> | <code>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.</code> | | <code>how to find out if someone blocked your phone number on iphone?</code> | <code>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.</code> |
  • —Loss: <code>CSRLoss</code> with these parameters:
json
  {
      "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: <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.88 tokens</li><li>max: 22 tokens</li></ul> | <ul><li>min: 14 tokens</li><li>mean: 61.03 tokens</li><li>max: 127 tokens</li></ul> |
  • —Samples: | question | answer | |:-----------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>how do i program my directv remote with my tv?</code> | <code>['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.']</code> | | <code>are rodrigues fruit bats nocturnal?</code> | <code>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.</code> | | <code>why does your heart rate increase during exercise bbc bitesize?</code> | <code>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.</code> |
  • —Loss: <code>CSRLoss</code> with these parameters:
json
  {
      "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

<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: 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: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —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_128_dot_ndcg@10NanoNFCorpus_128_dot_ndcg@10NanoNQ_128_dot_ndcg@10NanoBEIR_mean_128_dot_ndcg@10NanoMSMARCO_256_dot_ndcg@10NanoNFCorpus_256_dot_ndcg@10NanoNQ_256_dot_ndcg@10NanoBEIR_mean_256_dot_ndcg@10
-1-1--0.64210.27240.55280.48910.64250.29850.61940.5201
0.01701000.5414---------
0.03402000.5387---------
0.05103000.5183---------
0.06804000.5215---------
0.08505000.5011---------
0.10206000.5---------
0.11907000.4885---------
0.13608000.47770.39150.61730.27820.54650.48070.64060.30380.63180.5254
0.15309000.4793---------
0.170010000.472---------
0.187011000.4679---------
0.204012000.4666---------
0.221013000.4569---------
0.238014000.4642---------
0.255015000.4611---------
0.27216000.45370.38510.63140.2660.56640.48790.64510.32380.63630.5351
0.289017000.4554---------
0.306018000.4475---------
0.323019000.4512---------
0.340020000.4522---------
0.357021000.4475---------
0.374022000.4499---------
0.391023000.4467---------
0.408024000.44670.39400.62640.26430.57190.48750.60920.33500.63630.5268
0.425025000.4477---------
0.442026000.4466---------
0.459027000.4436---------
0.476028000.4434---------
0.493029000.4437---------
0.510030000.4381---------
0.527031000.4426---------
0.544032000.44610.38500.58660.28570.55670.47630.62320.33130.62200.5255
0.561033000.4453---------
0.578034000.4361---------
0.595035000.436---------
0.612036000.4444---------
0.629037000.4405---------
0.646038000.4346---------
0.663039000.4345---------
0.680040000.43990.38570.59630.28980.55370.48000.64790.31290.60580.5222
0.697041000.434---------
0.714042000.4353---------
0.731043000.4277---------
0.748044000.4361---------
0.765045000.445---------
0.782046000.4331---------
0.799047000.4329---------
0.816048000.43360.38270.59290.28940.56170.48130.64440.32410.61200.5268
0.833049000.4319---------
0.850150000.4342---------
0.867151000.439---------
0.884152000.434---------
0.901153000.4396---------
0.918154000.4355---------
0.935155000.4326---------
0.952156000.43040.38100.60550.28190.54920.47890.65940.32110.60150.5273
0.969157000.4316---------
0.986158000.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
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",
}
CSRLoss
bibtex
@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
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}
}

<!--

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. -->