tomaarsen/multivector-ModernBERT-base-msmarco-contrastive
ColBERT ModernBERT-base trained on MS MARCO triplets
This is a Multi-Vector Encoder model finetuned from answerdotai/ModernBERT-base on the msmarco-bm25 dataset using the sentence-transformers library. It maps inputs to sequences of 128-dimensional token-level vectors and scores them with late interaction (MaxSim), useful for semantic search with late interaction.
Model Details
Model Description
- Model Type: Multi-Vector Encoder
- Base model: answerdotai/ModernBERT-base <!-- at revision 8949b909ec900327062f0ebf497f51aef5e6f0c8 -->
- Maximum Sequence Length: 8192 tokens
- Output Dimensionality: 128 dimensions
- Similarity Function: maxsim
- Supported Modality: Text
- Training Dataset:
- msmarco-bm25
- Language: en
- License: apache-2.0
Model Sources
- Documentation: Sentence Transformers Documentation
- Documentation: Multi-Vector Encoder Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Multi-Vector Encoders on Hugging Face
Full Model Architecture
MultiVectorEncoder(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'query_expansion': {'strategy': 'min', 'attend': False, 'token': None, 'length': 32}, 'architecture': 'ModernBertModel'})
(1): Dense({'in_features': 768, 'out_features': 128, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity', 'module_input_name': 'token_embeddings', 'module_output_name': 'token_embeddings'})
(2): MultiVectorMask({'skiplist_words': [], 'keep_only_token_ids': None})
(3): Normalize({'module_input_name': 'token_embeddings', 'module_output_name': 'token_embeddings'})
)Usage
Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
pip install -U sentence-transformersThen you can load this model and run inference.
from sentence_transformers import MultiVectorEncoder
# Download from the 🤗 Hub
model = MultiVectorEncoder("tomaarsen/multivector-ModernBERT-base-msmarco")
# Run inference: each input becomes a sequence of per-token vectors (variable length).
queries = [
'what does marijuana cost per joint',
]
documents = [
'With a 50-50 ratio of marijuana to tobacco, the cost of producing a pack of 20 pre-rolled joints could be brought down to just a little more than $20â\x80\x94so a $40 pack at the store. It isnâ\x80\x99t as easy as it seems, though. The government has a vested interest in producing income from the selling of marijuana.nother solution: mix the marijuana with tobacco. If marijuana cigarettes were to be mixed with tobacco, at a 50-50 ratio, it would bring the cost down significantly. Many tobacco farmers will wholesale a pound of their product for less than $2.',
'What does a dime,dub,eigth,quarter,and a zip of marijuana look like and cost?',
'In January of 1980, residents decided to incorporate by an overwhelming margin. The Town of Farragut was incorporated on January 16, 1980, with the first board of Mayor and Alderman elected on April 1, 1980.',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings[0].shape, document_embeddings[0].shape)
# (32, 128) (129, 128)
# Get the MaxSim similarity scores
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[24.6630, 18.9976, 9.6529]])<!--
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
Multi Vector Information Retrieval
- Datasets:
NanoMSMARCO,NanoNQ,NanoFiQA2018,NanoClimateFEVER,NanoDBPedia,NanoFEVER,NanoFiQA2018,NanoHotpotQA,NanoMSMARCO,NanoNFCorpus,NanoNQ,NanoQuoraRetrieval,NanoSCIDOCS,NanoArguAna,NanoSciFactandNanoTouche2020 - Evaluated with <code>MultiVectorInformationRetrievalEvaluator</code>
Multi Vector Nano BEIR
- Dataset:
NanoBEIR_mean - Evaluated with <code>MultiVectorNanoBEIREvaluator</code> with these parameters:
{
"dataset_names": [
"msmarco",
"nq",
"fiqa2018"
],
"dataset_id": "sentence-transformers/NanoBEIR-en"
}Multi Vector Nano BEIR
- Dataset:
NanoBEIR_mean - Evaluated with <code>MultiVectorNanoBEIREvaluator</code> with these parameters:
{
"dataset_names": [
"climatefever",
"dbpedia",
"fever",
"fiqa2018",
"hotpotqa",
"msmarco",
"nfcorpus",
"nq",
"quoraretrieval",
"scidocs",
"arguana",
"scifact",
"touche2020"
],
"dataset_id": "sentence-transformers/NanoBEIR-en"
}<!--
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
msmarco-bm25
- Dataset: msmarco-bm25 at ce8a493
- Size: 50,000 training samples
- Columns: <code>query</code>, <code>positive</code>, and <code>negative</code>
- Approximate statistics based on the first 100 samples: | | query | positive | negative | |:---------|:--------------------------------------------------------------------------------|:------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------| | type | string | string | string | | modality | text | text | text | | details | <ul><li>min: 5 tokens</li><li>mean: 9.2 tokens</li><li>max: 23 tokens</li></ul> | <ul><li>min: 24 tokens</li><li>mean: 85.21 tokens</li><li>max: 234 tokens</li></ul> | <ul><li>min: 24 tokens</li><li>mean: 78.79 tokens</li><li>max: 189 tokens</li></ul> |
- Samples: | query | positive | negative | |:---------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>how many days to renew philippine passport to usa</code> | <code>The United States requires non-citizens to keep a foreign passport that is valid for six months beyond their date of departure. If you are in the United States legally, then you can renew your Philippine passport at the consulate general's office in Los Angeles.</code> | <code>How much does it cost to renew a Philippines passport? Philippine Passport Fees for Renewal is P 950 for 15 working days and 1,200 for 7 working days. This is according to the Department of Freign Affairs website.</code> | | <code>which sexually transmitted diseases can lead to infections inside joint spaces?</code> | <code>Gonorrhea is a sexually transmitted disease (STD) that can infect both men and women. It can cause infections in the genitals, rectum, and throat.It is a very common infection, especially among young people ages 15-24 years.omen with gonorrhea are at risk of developing serious complications from the infection, even if they donât have any symptoms. Symptoms in women can include: 1 Painful or burning sensation when urinating; 2 Increased vaginal discharge; 3 Vaginal bleeding between periods.</code> | <code>STDs and Infertility. Sexually transmitted diseases, STDs, also called sexually transmitted infections or STIs, can cause immediate, annoying symptoms with long-lasting, serious repercussions. Few people realize that these sexually transmitted diseases can cause damage that may eventually lead to infertility.</code> | | <code>when was eviva amore constructed</code> | <code>Nasher Sculpture Center Press Images Back of the garden, Nasher Sculpture Center; photo by Tim Hursley. Mark di Suvero, Eviva Amore, 2001 in gardens of Nasher Sculpture Center; photo by Tim Hursley. Jaume Plensa, The Long Night (From Ausias March to Vincent Andres Andrés) , estelles, estellés 2007 At Nasher; sculpture center Photo By. tim hursley</code> | <code>Richard Serra, My Curves Are Not Mad, 1987 and Augustus Rodin, Eve, 1881 (cast before 1932) at Nasher Sculpture Center; photo by Tim Hursley. Mark di Suvero, Eviva Amore, 2001 at dusk in gardens of Nasher Sculpture Center; photo by Tim Hursley. Jeremy Strick, Director of the Nasher Sculpture.</code> |
- Loss: <code>MultiVectorMultipleNegativesRankingLoss</code> with these parameters:
{
"score_metric": "colbert_scores",
"scale": 1.0,
"score_mini_batch_size": null,
"size_average": true,
"gather_across_devices": false
}Evaluation Dataset
msmarco-bm25
- Dataset: msmarco-bm25 at ce8a493
- Size: 1,000 evaluation samples
- Columns: <code>query</code>, <code>positive</code>, and <code>negative</code>
- Approximate statistics based on the first 100 samples: | | query | positive | negative | |:---------|:---------------------------------------------------------------------------------|:------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------| | type | string | string | string | | modality | text | text | text | | details | <ul><li>min: 4 tokens</li><li>mean: 9.15 tokens</li><li>max: 19 tokens</li></ul> | <ul><li>min: 39 tokens</li><li>mean: 82.03 tokens</li><li>max: 199 tokens</li></ul> | <ul><li>min: 27 tokens</li><li>mean: 81.62 tokens</li><li>max: 157 tokens</li></ul> |
- Samples: | query | positive | negative | |:------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>what is chor means</code> | <code>⢠CHORE (noun) The noun CHORE has 1 sense: 1. a specific piece of work required to be done as a duty or for a specific fee. Familiarity information: CHORE used as a noun is very rare.</code> | <code>Any two different languages and not just English and other language. Example 1. Chore (pronounced as cHor) means 'a routine task' in English language. Whereas Chor {à¤à¥à¤°} (also pronounced as CHor) means a thief or a burglar in both Hindi and Marathi language.</code> | | <code>how is gravity measured</code> | <code>The gravity of Earth, which is denoted by g, refers to the acceleration that the Earth imparts to objects on or near its surface due to gravity. In SI units this acceleration is measured in metres per second squared (in symbols, m/s2 or m·sâ2) or equivalently in newtons per kilogram (N/kg or N·kgâ1).</code> | <code>When the wort is first added to the yeast, the specific gravity of the mixture is measured. Later, the specific gravity may be measured again to determine how much alcohol is in the beer, and to know when to stop the fermentation.hen the wort is first added to the yeast, the specific gravity of the mixture is measured. Later, the specific gravity may be measured again to determine how much alcohol is in the beer, and to know when to stop the fermentation.</code> | | <code>salary of doctor during fellowship</code> | <code>Average fellowship salary and wage. The median expected salary for a Fellowship physician in the United States averages to about $150,353 per annum and an average hourly wage is around $20 per hour. fellowship physician in USA receives an average yearly salary ranging from between $34,225 â $59,542. In addition, a yearly bonus of around $4,888 will be included as part of the annual salary package.</code> | <code>Medical Fellowship Salary. Medical Fellowship average salary is $55,008, median salary is $- with a salary range from $- to $-.Medical Fellowship salaries are collected from government agencies and companies. Each salary is associated with a real job position.Medical Fellowship salary statistics is not exclusive and is for reference only.They are presented as is and updated regularly.edical Fellowship salaries are collected from government agencies and companies. Each salary is associated with a real job position. Medical Fellowship salary statistics is not exclusive and is for reference only. They are presented as is and updated regularly.</code> |
- Loss: <code>MultiVectorMultipleNegativesRankingLoss</code> with these parameters:
{
"score_metric": "colbert_scores",
"scale": 1.0,
"score_mini_batch_size": null,
"size_average": true,
"gather_across_devices": false
}Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size: 32num_train_epochs: 1learning_rate: 3e-05warmup_steps: 0.05bf16: Trueper_device_eval_batch_size: 32load_best_model_at_end: Truebatch_sampler: no_duplicates
All Hyperparameters
<details><summary>Click to expand</summary>
per_device_train_batch_size: 32num_train_epochs: 1max_steps: -1learning_rate: 3e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.05optim: adamwtorchfusedoptim_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: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_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: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': 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_static_graph: Noneddp_backend: Noneddp_timeout: 1800fsdp: Nonefsdp_config: Nonedeepspeed: 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: {}max_length: None
</details>
Training Logs
<details><summary>Click to expand</summary>
- The bold row denotes the saved checkpoint. </details>
Training Time
- Training: 13.6 minutes
- Evaluation: 5.1 minutes
- Total: 18.7 minutes
Framework Versions
- Python: 3.11.13
- Sentence Transformers: 5.7.0.dev0
- Transformers: 5.14.1
- PyTorch: 2.11.0+cu128
- Accelerate: 1.5.2
- Datasets: 3.5.0
- Tokenizers: 0.22.2
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",
}MultiVectorMultipleNegativesRankingLoss
@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. -->
