CrossEncoder based on cross-encoder/ms-marco-TinyBERT-L2
This is a Cross Encoder model finetuned from cross-encoder/ms-marco-TinyBERT-L2 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: cross-encoder/ms-marco-TinyBERT-L2
- 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': 'BertForSequenceClassification'})
)
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("SumedhJoshi/convmix-tinybert-baseline-followup-skip-3")
# Get scores for pairs of inputs
pairs = [
["Who is the hero in Man of Steel's story?", 'In telling the story, Byrne drew from available media depictions of Superman for inspiration, including the Fleischer Studios cartoons and George Reeves\' portrayal in the 1950s television series, "Adventures of Superman". Issue One. The cover to the first issue touted the story as where "The Legend Begins." It chronicles the origin of Superman, beginning with his flight from Krypton to his arrival on Earth where he is discovered by his adoptive parents, Jonathan and Martha Kent. As a teenager, Clark Kent wins a high school football game almost by himself. He has developed many of his powers: Durability, great strength, X-ray vision, and flight.'],
['Initial book of the novel series The Chronicles of Narnia?', 'On 5 December 2013, it was announced that David Magee would write the screenplay. In July 2014, the official Narnia website allowed the opportunity for fans to suggest names for the Lady of the Green Kirtle, the main antagonist. The winning name was to be selected by Mark Gordon and David Magee for use in the final script of "The Silver Chair". The film\'s producers have called the film a reboot in reference to the fact that the film has a new creative team not associated with those who worked on the previous three films. On 9 August 2016, it was announced that Sony\'s TriStar Productions and Entertainment One Films will finance and distribute the fourth film with The Mark Gordon Company (which eOne owns) and The C. S. Lewis Company. In April 2017, it was announced that Joe Johnston had been hired to direct "The Silver Chair".'],
['which network released the series Daredevil?', 'Petrie, Ramirez, Alison Engel, and Mark Verheiden became executive producers for the second season, while Friedlander left the show. The series was renewed for a third season in July 2016, with Petrie and Ramirez intended to return as showrunners, but Erik Oleson was announced in October 2017 to be taking over as showrunner. Writing. Goddard was always a fan of Daredevil after being raised Catholic, and identifying with the character\'s story of a "Catholic superhero struggling with the notions of right and wrong". He did not want to be "a guy that just takes the comics and then shoots them onscreen. I think it\'s our job to treat it as if it\'s our run.'],
['Which boy band had Justin Timberlake and Lance Bass as members?', '2005–2007: "It\'s About Time". In 2005, Joe, Kevin and Nick recorded "Please Be Mine", their first song recorded. Upon hearing the song, the Columbia Records president Steve Greenberg decided to sign the brothers as a group. They considered naming their group "Sons of Jonas" before settling on the name Jonas Brothers. While working on their debut studio album, the band toured throughout 2005 with artists such as Jump5, Kelly Clarkson, Jesse McCartney, the Backstreet Boys, and The Click Five among others. They spent the latter portion of the year on a tour with Aly & AJ and The Cheetah Girls.'],
['What is the issuing date of the novel Revolution 2020?', 'Plot. This book follows the story of two friends separated by their ambitions and passions yet connected by their love for the same girl. While Gopal, who has experienced the harsh realities of life due to poverty aspires to become rich, his friend Raghav is a boy from a well-off family who desires to "revolutionize" India by fighting corruption. Aarti and Gopal have been childhoeep but platonic relationship. As teenagers, Gopal pushes Aarti for more, but she later reveals that she was not ready for anything. Gopal gets a low ranking in the AIEEE exams while Raghav is among the toppers.'],
]
scores = model.predict(pairs)
print(scores)
# [0.1055 0.174 0.1723 0.1237 0.1286]
# Or rank different texts based on similarity to a single text
ranks = model.rank(
"Who is the hero in Man of Steel's story?",
[
'In telling the story, Byrne drew from available media depictions of Superman for inspiration, including the Fleischer Studios cartoons and George Reeves\' portrayal in the 1950s television series, "Adventures of Superman". Issue One. The cover to the first issue touted the story as where "The Legend Begins." It chronicles the origin of Superman, beginning with his flight from Krypton to his arrival on Earth where he is discovered by his adoptive parents, Jonathan and Martha Kent. As a teenager, Clark Kent wins a high school football game almost by himself. He has developed many of his powers: Durability, great strength, X-ray vision, and flight.',
'On 5 December 2013, it was announced that David Magee would write the screenplay. In July 2014, the official Narnia website allowed the opportunity for fans to suggest names for the Lady of the Green Kirtle, the main antagonist. The winning name was to be selected by Mark Gordon and David Magee for use in the final script of "The Silver Chair". The film\'s producers have called the film a reboot in reference to the fact that the film has a new creative team not associated with those who worked on the previous three films. On 9 August 2016, it was announced that Sony\'s TriStar Productions and Entertainment One Films will finance and distribute the fourth film with The Mark Gordon Company (which eOne owns) and The C. S. Lewis Company. In April 2017, it was announced that Joe Johnston had been hired to direct "The Silver Chair".',
'Petrie, Ramirez, Alison Engel, and Mark Verheiden became executive producers for the second season, while Friedlander left the show. The series was renewed for a third season in July 2016, with Petrie and Ramirez intended to return as showrunners, but Erik Oleson was announced in October 2017 to be taking over as showrunner. Writing. Goddard was always a fan of Daredevil after being raised Catholic, and identifying with the character\'s story of a "Catholic superhero struggling with the notions of right and wrong". He did not want to be "a guy that just takes the comics and then shoots them onscreen. I think it\'s our job to treat it as if it\'s our run.',
'2005–2007: "It\'s About Time". In 2005, Joe, Kevin and Nick recorded "Please Be Mine", their first song recorded. Upon hearing the song, the Columbia Records president Steve Greenberg decided to sign the brothers as a group. They considered naming their group "Sons of Jonas" before settling on the name Jonas Brothers. While working on their debut studio album, the band toured throughout 2005 with artists such as Jump5, Kelly Clarkson, Jesse McCartney, the Backstreet Boys, and The Click Five among others. They spent the latter portion of the year on a tour with Aly & AJ and The Cheetah Girls.',
'Plot. This book follows the story of two friends separated by their ambitions and passions yet connected by their love for the same girl. While Gopal, who has experienced the harsh realities of life due to poverty aspires to become rich, his friend Raghav is a boy from a well-off family who desires to "revolutionize" India by fighting corruption. Aarti and Gopal have been childhoeep but platonic relationship. As teenagers, Gopal pushes Aarti for more, but she later reveals that she was not ready for anything. Gopal gets a low ranking in the AIEEE exams while Raghav is among the toppers.',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
Training Details
Training Dataset
Unnamed Dataset
- Size: 4,594 training samples
- Columns: sentence_0, sentence_1, and label
- Approximate statistics based on the first 100 samples:
sentence_0 sentence_1 label type string string float modality text text details min: 7 tokensmean: 13.25 tokensmax: 24 tokens min: 42 tokensmean: 153.66 tokensmax: 277 tokens min: 0.0mean: 0.14max: 1.0 - Samples:
sentence_0 sentence_1 label Who is the hero in Man of Steel's story? In telling the story, Byrne drew from available media depictions of Superman for inspiration, including the Fleischer Studios cartoons and George Reeves' portrayal in the 1950s television series, "Adventures of Superman". Issue One. The cover to the first issue touted the story as where "The Legend Begins." It chronicles the origin of Superman, beginning with his flight from Krypton to his arrival on Earth where he is discovered by his adoptive parents, Jonathan and Martha Kent. As a teenager, Clark Kent wins a high school football game almost by himself. He has developed many of his powers: Durability, great strength, X-ray vision, and flight. 0.0 Initial book of the novel series The Chronicles of Narnia? On 5 December 2013, it was announced that David Magee would write the screenplay. In July 2014, the official Narnia website allowed the opportunity for fans to suggest names for the Lady of the Green Kirtle, the main antagonist. The winning name was to be selected by Mark Gordon and David Magee for use in the final script of "The Silver Chair". The film's producers have called the film a reboot in reference to the fact that the film has a new creative team not associated with those who worked on the previous three films. On 9 August 2016, it was announced that Sony's TriStar Productions and Entertainment One Films will finance and distribute the fourth film with The Mark Gordon Company (which eOne owns) and The C. S. Lewis Company. In April 2017, it was announced that Joe Johnston had been hired to direct "The Silver Chair". 1.0 which network released the series Daredevil? Petrie, Ramirez, Alison Engel, and Mark Verheiden became executive producers for the second season, while Friedlander left the show. The series was renewed for a third season in July 2016, with Petrie and Ramirez intended to return as showrunners, but Erik Oleson was announced in October 2017 to be taking over as showrunner. Writing. Goddard was always a fan of Daredevil after being raised Catholic, and identifying with the character's story of a "Catholic superhero struggling with the notions of right and wrong". He did not want to be "a guy that just takes the comics and then shoots them onscreen. I think it's our job to treat it as if it's our run. 0.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: 16num_train_epochs: 5per_device_eval_batch_size: 16
All Hyperparameters
per_device_train_batch_size: 16num_train_epochs: 5max_steps: -1learning_rate: 5e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0optim: adamw_torch_fusedoptim_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: 1label_smoothing_factor: 0.0bf16: Falsefp16: 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: 16prediction_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: Noneuse_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 |
|---|---|---|
| 1.7361 | 500 | 0.5662 |
| 3.4722 | 1000 | 0.4197 |
Training Time
- Training: 23.7 minutes
Framework Versions
- Python: 3.13.16
- Sentence Transformers: 6.2.0
- Transformers: 5.20.2
- PyTorch: 2.11.0+cu130
- Accelerate: 1.15.0
- Datasets: 5.1.0
- Tokenizers: 0.23.3
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",
}