CrossEncoder based on bansalaman18/bert-uncased_L-4_H-512_A-8
This is a Cross Encoder model finetuned from bansalaman18/bert-uncased_L-4_H-512_A-8 on the msmarco dataset using the sentence-transformers library. It computes scores for pairs of texts, which can be used for text reranking and semantic search.
Model Details
Model Description
- Model Type: Cross Encoder
- Base model: bansalaman18/bert-uncased_L-4_H-512_A-8
- Maximum Sequence Length: 512 tokens
- Number of Output Labels: 1 label
- Training Dataset:
- Language: en
Model Sources
- Documentation: Sentence Transformers Documentation
- Documentation: Cross Encoder Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Cross Encoders on Hugging Face
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 CrossEncoder
# Download from the 🤗 Hub
model = CrossEncoder("bansalaman18/reranker-bert-uncased_L-4_H-512_A-8-msmarco-bce")
# Get scores for pairs of texts
pairs = [
['who is wale the rapper', "Wale (rapper)'s wiki: Olubowale Victor Akintimehin (born September 21, 1984), better known by his stage name Wale (/Ë\x88wÉ\x94Ë\x90leɪ/ WAW-lay), is an American rapper from Washington, D.C. He rose to prominence in 2006, when his song Dig Dug (Shake It) became popular in his hometown. Wale became locally recognized and continued recording music for the regional audience."],
['what is platinum used for', 'The periodic table is a chart that shows how elements are related to one another. Indium is a transition metal that is also part of the platinum family. The metals in the platinum family are also known as the noble metals. They have this name because they do not react well with other elements and compounds. They appear to be too superior to react with most other substances. In fact, iridium is the most corrosion-resistant metal known.'],
['where is the gonzaga university located', 'Where We Are. The Boise State University Department of Public Safety substation is located in Capitol Village at 2245 University Drive. Our office is open 24 hours a day, 7 days a week, so we are always available. Physical Address: 2245 University Drive, Boise, Idaho 83706.'],
['most common protein in the human body', 'Protein is the second category of food that a human body can get energy from. Most people know protein as animal meat-a hamburger, a chicken leg. These are all proteins. You can also extract protein from certain plants.Soy protein isolate is a well known protein that comes from soybeans.uman Body Four Energy Sources. The human body can only metabolize four types of energy sources. These four categories are carbohydrates (sugars and starches), fats (includes oils), proteins (animal and vegetable), and alcohol.'],
['where is azilda ontario', 'Azilda railway station is a Via Rail flag stop station located in Azilda, Ontario, in the city of Greater Sudbury community of Rayside-Balfour. It is on the Canadian Pacific Railway transcontinental main line, and is served by the regional rail Sudbury â\x80\x93 White River train. Map 12 (PDF) (Map). 1 : 1,600,000.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'who is wale the rapper',
[
"Wale (rapper)'s wiki: Olubowale Victor Akintimehin (born September 21, 1984), better known by his stage name Wale (/Ë\x88wÉ\x94Ë\x90leɪ/ WAW-lay), is an American rapper from Washington, D.C. He rose to prominence in 2006, when his song Dig Dug (Shake It) became popular in his hometown. Wale became locally recognized and continued recording music for the regional audience.",
'The periodic table is a chart that shows how elements are related to one another. Indium is a transition metal that is also part of the platinum family. The metals in the platinum family are also known as the noble metals. They have this name because they do not react well with other elements and compounds. They appear to be too superior to react with most other substances. In fact, iridium is the most corrosion-resistant metal known.',
'Where We Are. The Boise State University Department of Public Safety substation is located in Capitol Village at 2245 University Drive. Our office is open 24 hours a day, 7 days a week, so we are always available. Physical Address: 2245 University Drive, Boise, Idaho 83706.',
'Protein is the second category of food that a human body can get energy from. Most people know protein as animal meat-a hamburger, a chicken leg. These are all proteins. You can also extract protein from certain plants.Soy protein isolate is a well known protein that comes from soybeans.uman Body Four Energy Sources. The human body can only metabolize four types of energy sources. These four categories are carbohydrates (sugars and starches), fats (includes oils), proteins (animal and vegetable), and alcohol.',
'Azilda railway station is a Via Rail flag stop station located in Azilda, Ontario, in the city of Greater Sudbury community of Rayside-Balfour. It is on the Canadian Pacific Railway transcontinental main line, and is served by the regional rail Sudbury â\x80\x93 White River train. Map 12 (PDF) (Map). 1 : 1,600,000.',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
Evaluation
Metrics
Cross Encoder Reranking
- Datasets:
NanoMSMARCO_R100
,NanoNFCorpus_R100
andNanoNQ_R100
- Evaluated with
CrossEncoderRerankingEvaluator
with these parameters:{ "at_k": 10, "always_rerank_positives": true }
Metric | NanoMSMARCO_R100 | NanoNFCorpus_R100 | NanoNQ_R100 |
---|---|---|---|
map | 0.0664 (-0.4232) | 0.3041 (+0.0431) | 0.1094 (-0.3102) |
mrr@10 | 0.0383 (-0.4392) | 0.4851 (-0.0148) | 0.0819 (-0.3448) |
ndcg@10 | 0.0484 (-0.4921) | 0.3186 (-0.0064) | 0.1066 (-0.3940) |
Cross Encoder Nano BEIR
- Dataset:
NanoBEIR_R100_mean
- Evaluated with
CrossEncoderNanoBEIREvaluator
with these parameters:{ "dataset_names": [ "msmarco", "nfcorpus", "nq" ], "rerank_k": 100, "at_k": 10, "always_rerank_positives": true }
Metric | Value |
---|---|
map | 0.1600 (-0.2301) |
mrr@10 | 0.2018 (-0.2662) |
ndcg@10 | 0.1579 (-0.2975) |
Training Details
Training Dataset
msmarco
- Dataset: msmarco at 9e329ed
- Size: 90,000 training samples
- Columns:
query
,passage
, andscore
- Approximate statistics based on the first 1000 samples:
query passage score type string string float details - min: 10 characters
- mean: 34.26 characters
- max: 168 characters
- min: 60 characters
- mean: 343.34 characters
- max: 984 characters
- min: 0.0
- mean: 0.53
- max: 1.0
- Samples:
query passage score who is the actor that plays the tanned colonel for kfc?
James Rebhorn Actor, Scent of a Woman James Robert Rebhorn (September 1, 1948 - March 21, 2014) was an American actor who appeared in over 100 films, television series, and plays. At the time of his death, he had recurring roles in the current series White Collar and Homeland.
0.0
asking for an increase in credit limit harm your credit score
If you request a credit line increase, you should ask the lender whether it will result in your credit report being pulled. If it does, this will show up as an inquiry on your report and generally remains on your credit report for two years.Too many inquiries can lower your credit score.f you request a credit line increase, you should ask the lender whether it will result in your credit report being pulled. If it does, this will show up as an inquiry on your report and generally remains on your credit report for two years.
1.0
what is a sheep ked
Cysteine is required by sheep to produce wool: It is an essential amino acid that must be taken in from their feed. As a consequence, during drought conditions, sheep produce less wool; however, transgenic sheep that can make their own cysteine have been developed.
0.0
- Loss:
BinaryCrossEntropyLoss
with these parameters:{ "activation_fn": "torch.nn.modules.linear.Identity", "pos_weight": null }
Evaluation Dataset
msmarco
- Dataset: msmarco at 9e329ed
- Size: 10,000 evaluation samples
- Columns:
query
,passage
, andscore
- Approximate statistics based on the first 1000 samples:
query passage score type string string float details - min: 11 characters
- mean: 34.79 characters
- max: 118 characters
- min: 86 characters
- mean: 353.31 characters
- max: 970 characters
- min: 0.0
- mean: 0.52
- max: 1.0
- Samples:
query passage score who is wale the rapper
Wale (rapper)'s wiki: Olubowale Victor Akintimehin (born September 21, 1984), better known by his stage name Wale (/ËwÉËleɪ/ WAW-lay), is an American rapper from Washington, D.C. He rose to prominence in 2006, when his song Dig Dug (Shake It) became popular in his hometown. Wale became locally recognized and continued recording music for the regional audience.
1.0
what is platinum used for
The periodic table is a chart that shows how elements are related to one another. Indium is a transition metal that is also part of the platinum family. The metals in the platinum family are also known as the noble metals. They have this name because they do not react well with other elements and compounds. They appear to be too superior to react with most other substances. In fact, iridium is the most corrosion-resistant metal known.
0.0
where is the gonzaga university located
Where We Are. The Boise State University Department of Public Safety substation is located in Capitol Village at 2245 University Drive. Our office is open 24 hours a day, 7 days a week, so we are always available. Physical Address: 2245 University Drive, Boise, Idaho 83706.
0.0
- Loss:
BinaryCrossEntropyLoss
with these parameters:{ "activation_fn": "torch.nn.modules.linear.Identity", "pos_weight": null }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy
: stepsper_device_train_batch_size
: 16per_device_eval_batch_size
: 16learning_rate
: 2e-05num_train_epochs
: 1warmup_ratio
: 0.1seed
: 12bf16
: Truehalf_precision_backend
: cpu_ampdataloader_num_workers
: 4load_best_model_at_end
: True
All Hyperparameters
Click to expand
overwrite_output_dir
: Falsedo_predict
: Falseeval_strategy
: stepsprediction_loss_only
: Trueper_device_train_batch_size
: 16per_device_eval_batch_size
: 16per_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.1warmup_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
: 12data_seed
: Nonejit_mode_eval
: Falseuse_ipex
: Falsebf16
: Truefp16
: Falsefp16_opt_level
: O1half_precision_backend
: cpu_ampbf16_full_eval
: Falsefp16_full_eval
: Falsetf32
: Nonelocal_rank
: 0ddp_backend
: Nonetpu_num_cores
: Nonetpu_metrics_debug
: Falsedebug
: []dataloader_drop_last
: Falsedataloader_num_workers
: 4dataloader_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
: 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
: batch_samplermulti_dataset_batch_sampler
: proportionalrouter_mapping
: {}learning_rate_mapping
: {}
Training Logs
Epoch | Step | Training Loss | Validation Loss | NanoMSMARCO_R100_ndcg@10 | NanoNFCorpus_R100_ndcg@10 | NanoNQ_R100_ndcg@10 | NanoBEIR_R100_mean_ndcg@10 |
---|---|---|---|---|---|---|---|
-1 | -1 | - | - | 0.0441 (-0.4963) | 0.3050 (-0.0201) | 0.0582 (-0.4424) | 0.1357 (-0.3196) |
0.0002 | 1 | 0.7036 | - | - | - | - | - |
0.1778 | 1000 | 0.6957 | 0.6984 | 0.0411 (-0.4994) | 0.2691 (-0.0560) | 0.0130 (-0.4876) | 0.1077 (-0.3476) |
0.3556 | 2000 | 0.6901 | 0.7008 | 0.0452 (-0.4952) | 0.3050 (-0.0200) | 0.0937 (-0.4069) | 0.1480 (-0.3074) |
0.5333 | 3000 | 0.678 | 0.6776 | 0.0488 (-0.4916) | 0.3064 (-0.0186) | 0.1108 (-0.3899) | 0.1553 (-0.3000) |
0.7111 | 4000 | 0.6724 | 0.6617 | 0.0397 (-0.5007) | 0.3169 (-0.0081) | 0.1040 (-0.3966) | 0.1536 (-0.3018) |
0.8889 | 5000 | 0.6706 | 0.6583 | 0.0484 (-0.4921) | 0.3186 (-0.0064) | 0.1066 (-0.3940) | 0.1579 (-0.2975) |
-1 | -1 | - | - | 0.0484 (-0.4921) | 0.3186 (-0.0064) | 0.1066 (-0.3940) | 0.1579 (-0.2975) |
- The bold row denotes the saved checkpoint.
Framework Versions
- Python: 3.11.13
- Sentence Transformers: 5.0.0
- Transformers: 4.51.0
- PyTorch: 2.6.0
- Accelerate: 1.8.1
- Datasets: 3.6.0
- Tokenizers: 0.21.4-dev.0
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",
}
- Downloads last month
- 8
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
🙋
Ask for provider support
Model tree for bansalaman18/reranker-bert-uncased_L-4_H-512_A-8-msmarco-bce
Base model
bansalaman18/bert-uncased_L-4_H-512_A-8Dataset used to train bansalaman18/reranker-bert-uncased_L-4_H-512_A-8-msmarco-bce
Evaluation results
- Map on NanoMSMARCO R100self-reported0.066
- Mrr@10 on NanoMSMARCO R100self-reported0.038
- Ndcg@10 on NanoMSMARCO R100self-reported0.048
- Map on NanoNFCorpus R100self-reported0.304
- Mrr@10 on NanoNFCorpus R100self-reported0.485
- Ndcg@10 on NanoNFCorpus R100self-reported0.319
- Map on NanoNQ R100self-reported0.109
- Mrr@10 on NanoNQ R100self-reported0.082
- Ndcg@10 on NanoNQ R100self-reported0.107
- Map on NanoBEIR R100 meanself-reported0.160