CrossEncoder based on Alibaba-NLP/gte-reranker-modernbert-base
This is a Cross Encoder model finetuned from Alibaba-NLP/gte-reranker-modernbert-base 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: Alibaba-NLP/gte-reranker-modernbert-base
- Maximum Sequence Length: 384 tokens
- Number of Output Labels: 1 label
- Supported Modality: Text
Model Sources
- Documentation: Sentence Transformers Documentation
- Documentation: Cross Encoder Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Cross Encoders on Hugging Face
Full Model Architecture
CrossEncoder(
(0): Transformer({'transformer_task': 'sequence-classification', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}}, 'module_output_name': 'scores', 'architecture': 'ModernBertForSequenceClassification'})
)
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("cross_encoder_model_id")
# Get scores for pairs of inputs
pairs = [
['!awnmower tires without rims', 'American Lawn Mower Company 1204-14 14-Inch 4-Blade Push Reel Lawn Mower, Red | American Lawn Mower Company | Red | 4-blade reel with a cutting width of 14” and durable 8.5” polymer wheels for maximum maneuverability | Mechanical lawn mower with an adjustable blade height of 0.5”-1.75” with scissor action cut | Manual grass cutter blades made of heat-treated alloy steel that stays sharp for years | Environment-friendly alternative to gas-powered lawn mowers which is pollution-free and noise-free; Low maintenance, lightweight and easy to use | Capable of cutting grass up to 4 inches tall'],
['!awnmower tires without rims', 'Oregon 72-107 Universal Wheel 7X150 Diamond Plastic | Oregon | ⭐️ Exclusive | 7 x 1.50" | ID 1/2-Inch | Hub Is Offset Plastic | Hub Length Is 1 3/8-Inch | Tread Design: Diamond'],
['!awnmower tires without rims', 'Carlisle Turf Saver Lawn & Garden Tire - 15X6-6 A | Carlisle Paddles | Fit Type: Vehicle Specific | Enhanced durability with its broad-shouldered, puncture resistant construction'],
['!awnmower tires without rims', "Honda 44710-VG3-010 Front Wheels, (Set of 2) | Honda | Sold on Amazon | Honda Front Wheels (Set of 2) PLEASE NOTE: Check your owner's manual to be sure 44710-VL0-L02ZB, 44710-VG3-000 is the correct replacement part for your mower model. Consult owner's manual for proper part number identification and proper installation."],
['!awnmower tires without rims', 'Honda 42710-VE2-M02ZE (Replaces 42710-VE2-M01ZE) Lawn Mower Rear Wheel Set of 2 | Honda | Set of 2 Honda OEM Rear Wheels | Replaces 42710-VE2-M01ZE and 42710-VG3-B00 | 8 inch in diameter | Fits: HRB216 HXA, HRB216 HXAA, HRB216 TDA, HRB216 TDAA, HRB216 TXA, HRB216 TXAA, HRB217 HXA, HRB217 TDA, HRR216 S3DA, HRR216 SDA, HRR216K2 SDAA, HRR216K2 TDAA, HRR216K2 TKAA, HRR216K3 TDA, HRR216K4 TDA, HRS216 SDA, HRS216K1 SDA, HRS216K1 SDAA, HRS216K2 SDAA, HRS216K3 SDAA, HRT216 S3DA, HRT216 SDA, HRT216K1 S3DA, HRT216K1 S3DA-A, HRT216'],
]
scores = model.predict(pairs)
print(scores)
# [0.2121 0.5576 0.8152 0.4738 0.6792]
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'!awnmower tires without rims',
[
'American Lawn Mower Company 1204-14 14-Inch 4-Blade Push Reel Lawn Mower, Red | American Lawn Mower Company | Red | 4-blade reel with a cutting width of 14” and durable 8.5” polymer wheels for maximum maneuverability | Mechanical lawn mower with an adjustable blade height of 0.5”-1.75” with scissor action cut | Manual grass cutter blades made of heat-treated alloy steel that stays sharp for years | Environment-friendly alternative to gas-powered lawn mowers which is pollution-free and noise-free; Low maintenance, lightweight and easy to use | Capable of cutting grass up to 4 inches tall',
'Oregon 72-107 Universal Wheel 7X150 Diamond Plastic | Oregon | ⭐️ Exclusive | 7 x 1.50" | ID 1/2-Inch | Hub Is Offset Plastic | Hub Length Is 1 3/8-Inch | Tread Design: Diamond',
'Carlisle Turf Saver Lawn & Garden Tire - 15X6-6 A | Carlisle Paddles | Fit Type: Vehicle Specific | Enhanced durability with its broad-shouldered, puncture resistant construction',
"Honda 44710-VG3-010 Front Wheels, (Set of 2) | Honda | Sold on Amazon | Honda Front Wheels (Set of 2) PLEASE NOTE: Check your owner's manual to be sure 44710-VL0-L02ZB, 44710-VG3-000 is the correct replacement part for your mower model. Consult owner's manual for proper part number identification and proper installation.",
'Honda 42710-VE2-M02ZE (Replaces 42710-VE2-M01ZE) Lawn Mower Rear Wheel Set of 2 | Honda | Set of 2 Honda OEM Rear Wheels | Replaces 42710-VE2-M01ZE and 42710-VG3-B00 | 8 inch in diameter | Fits: HRB216 HXA, HRB216 HXAA, HRB216 TDA, HRB216 TDAA, HRB216 TXA, HRB216 TXAA, HRB217 HXA, HRB217 TDA, HRR216 S3DA, HRR216 SDA, HRR216K2 SDAA, HRR216K2 TDAA, HRR216K2 TKAA, HRR216K3 TDA, HRR216K4 TDA, HRS216 SDA, HRS216K1 SDA, HRS216K1 SDAA, HRS216K2 SDAA, HRS216K3 SDAA, HRT216 S3DA, HRT216 SDA, HRT216K1 S3DA, HRT216K1 S3DA-A, HRT216',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
Training Details
Training Dataset
Unnamed Dataset
- Size: 377,350 training samples
- Columns: query, document, and label
- Approximate statistics based on the first 100 samples:
query document label type string string float modality text text details min: 5 tokensmean: 10.0 tokensmax: 11 tokens min: 32 tokensmean: 206.83 tokensmax: 256 tokens min: 0.0mean: 0.57max: 1.0 - Samples:
query document label !awnmower tires without rims American Lawn Mower Company 1204-14 14-Inch 4-Blade Push Reel Lawn Mower, Red | American Lawn Mower Company | Red | 4-blade reel with a cutting width of 14” and durable 8.5” polymer wheels for maximum maneuverability | Mechanical lawn mower with an adjustable blade height of 0.5”-1.75” with scissor action cut | Manual grass cutter blades made of heat-treated alloy steel that stays sharp for years | Environment-friendly alternative to gas-powered lawn mowers which is pollution-free and noise-free; Low maintenance, lightweight and easy to use | Capable of cutting grass up to 4 inches tall 0.0 !awnmower tires without rims Oregon 72-107 Universal Wheel 7X150 Diamond Plastic | Oregon | ⭐️ Exclusive | 7 x 1.50" | ID 1/2-Inch | Hub Is Offset Plastic | Hub Length Is 1 3/8-Inch | Tread Design: Diamond 1.0 !awnmower tires without rims Carlisle Turf Saver Lawn & Garden Tire - 15X6-6 A | Carlisle Paddles | Fit Type: Vehicle Specific | Enhanced durability with its broad-shouldered, puncture resistant construction 1.0 - Loss: BinaryCrossEntropyLoss with these parameters:
{ "activation_fn": "torch.nn.modules.linear.Identity", "pos_weight": null }
Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size: 64num_train_epochs: 1learning_rate: 2e-05optim: adamw_torchbf16: Truedata_seed: 42
All Hyperparameters
per_device_train_batch_size: 64num_train_epochs: 1max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0optim: adamw_torchoptim_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: 8prediction_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: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: 42use_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: Nonedataloader_multiprocessing_context: Nonedataloader_in_order: Trueremove_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: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}warmup_ratio: None
Training Logs
| Epoch | Step | Training Loss |
|---|---|---|
| 0.0848 | 500 | 0.6006 |
| 0.1696 | 1000 | 0.5788 |
| 0.2544 | 1500 | 0.5660 |
| 0.3392 | 2000 | 0.5644 |
| 0.4239 | 2500 | 0.5573 |
| 0.5087 | 3000 | 0.5497 |
| 0.5935 | 3500 | 0.5466 |
| 0.6783 | 4000 | 0.5390 |
| 0.7631 | 4500 | 0.5345 |
| 0.8479 | 5000 | 0.5333 |
| 0.9327 | 5500 | 0.5338 |
Training Time
- Training: 25.1 minutes
Framework Versions
- Python: 3.12.3
- Sentence Transformers: 6.1.0
- Transformers: 5.17.0
- PyTorch: 2.14.0+cu130
- Accelerate: 1.15.0
- Datasets: 5.0.1
- Tokenizers: 0.23.2
Additional Resources
- Training and Finetuning Reranker Models with Sentence Transformers: the end-to-end guide for training or finetuning Cross Encoder (reranker) models.
- Multimodal Embedding & Reranker Models with Sentence Transformers: use text, image, audio, and video reranker models through the same API.
- Training and Finetuning Multimodal Embedding & Reranker Models with Sentence Transformers: training multimodal Cross Encoders.
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",
}