Text Ranking
sentence-transformers
Safetensors
bert
cross-encoder
reranker
Generated from Trainer
dataset_size:11928
loss:BinaryCrossEntropyLoss
text-embeddings-inference
Instructions to use ChengyouXin/cacheverifier-quora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use ChengyouXin/cacheverifier-quora with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("ChengyouXin/cacheverifier-quora") query = "Which planet is known as the Red Planet?" passages = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", "Saturn, famous for its rings, is sometimes mistaken for the Red Planet." ] scores = model.predict([(query, passage) for passage in passages]) print(scores) - Notebooks
- Google Colab
- Kaggle
| tags: | |
| - sentence-transformers | |
| - cross-encoder | |
| - reranker | |
| - generated_from_trainer | |
| - dataset_size:11928 | |
| - loss:BinaryCrossEntropyLoss | |
| pipeline_tag: text-ranking | |
| library_name: sentence-transformers | |
| # CrossEncoder | |
| This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model trained using the [sentence-transformers](https://www.SBERT.net) 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:** [Unknown](https://huggingface.co/unknown) --> | |
| - **Maximum Sequence Length:** 512 tokens | |
| - **Number of Output Labels:** 1 label | |
| - **Supported Modality:** Text | |
| <!-- - **Training Dataset:** Unknown --> | |
| <!-- - **Language:** Unknown --> | |
| <!-- - **License:** Unknown --> | |
| ### Model Sources | |
| - **Documentation:** [Sentence Transformers Documentation](https://sbert.net) | |
| - **Documentation:** [Cross Encoder Documentation](https://www.sbert.net/docs/cross_encoder/usage/usage.html) | |
| - **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers) | |
| - **Hugging Face:** [Cross Encoders on Hugging Face](https://huggingface.co/models?library=sentence-transformers&other=cross-encoder) | |
| ### 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: | |
| ```bash | |
| pip install -U sentence-transformers | |
| ``` | |
| Then you can load this model and run inference. | |
| ```python | |
| from sentence_transformers import CrossEncoder | |
| # Download from the 🤗 Hub | |
| model = CrossEncoder("cross_encoder_model_id") | |
| # Get scores for pairs of inputs | |
| pairs = [ | |
| ['How do you control your horniness?', 'How do I control my horny emotions?'], | |
| ['What do i do after my MBBS ?', 'What can one do after MBBS?'], | |
| ['What is the county of Edgware and how does the lifestyle compare to the London Borough of Enfield?', 'What is the district of Edgware and how does the lifestyle compare to the London Borough of Islington?'], | |
| ['What is a qualified SAP ERP key user?', 'What is the responsibility of SAP ERP key user?'], | |
| ['Which is the best book for tensor calculus?', 'Which is the best book to study TENSOR for general relativity from basic?'], | |
| ] | |
| scores = model.predict(pairs) | |
| print(scores) | |
| # [ 0.0335 0.6294 -2.3788 -0.096 -0.4309] | |
| # Or rank different texts based on similarity to a single text | |
| ranks = model.rank( | |
| 'How do you control your horniness?', | |
| [ | |
| 'How do I control my horny emotions?', | |
| 'What can one do after MBBS?', | |
| 'What is the district of Edgware and how does the lifestyle compare to the London Borough of Islington?', | |
| 'What is the responsibility of SAP ERP key user?', | |
| 'Which is the best book to study TENSOR for general relativity from basic?', | |
| ] | |
| ) | |
| # [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...] | |
| ``` | |
| <!-- | |
| ### 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.* | |
| --> | |
| <!-- | |
| ## 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 | |
| #### Unnamed Dataset | |
| * Size: 11,928 training samples | |
| * Columns: <code>query</code>, <code>response</code>, and <code>label</code> | |
| * Approximate statistics based on the first 100 samples: | |
| | | query | response | label | | |
| |:---------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------| | |
| | type | string | string | float | | |
| | modality | text | text | | | |
| | details | <ul><li>min: 7 tokens</li><li>mean: 14.07 tokens</li><li>max: 24 tokens</li></ul> | <ul><li>min: 8 tokens</li><li>mean: 14.39 tokens</li><li>max: 31 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.62</li><li>max: 1.0</li></ul> | | |
| * Samples: | |
| | query | response | label | | |
| |:----------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------|:-----------------| | |
| | <code>How do you control your horniness?</code> | <code>How do I control my horny emotions?</code> | <code>1.0</code> | | |
| | <code>What do i do after my MBBS ?</code> | <code>What can one do after MBBS?</code> | <code>1.0</code> | | |
| | <code>What is the county of Edgware and how does the lifestyle compare to the London Borough of Enfield?</code> | <code>What is the district of Edgware and how does the lifestyle compare to the London Borough of Islington?</code> | <code>0.0</code> | | |
| * Loss: [<code>BinaryCrossEntropyLoss</code>](https://sbert.net/docs/package_reference/cross_encoder/losses.html#binarycrossentropyloss) with these parameters: | |
| ```json | |
| { | |
| "activation_fn": "torch.nn.modules.linear.Identity", | |
| "pos_weight": null | |
| } | |
| ``` | |
| ### Training Hyperparameters | |
| #### Non-Default Hyperparameters | |
| - `per_device_train_batch_size`: 16 | |
| - `num_train_epochs`: 1 | |
| - `disable_tqdm`: True | |
| #### All Hyperparameters | |
| <details><summary>Click to expand</summary> | |
| - `per_device_train_batch_size`: 16 | |
| - `num_train_epochs`: 1 | |
| - `max_steps`: -1 | |
| - `learning_rate`: 5e-05 | |
| - `lr_scheduler_type`: linear | |
| - `lr_scheduler_kwargs`: None | |
| - `warmup_steps`: 0 | |
| - `optim`: adamw_torch_fused | |
| - `optim_args`: None | |
| - `weight_decay`: 0.0 | |
| - `adam_beta1`: 0.9 | |
| - `adam_beta2`: 0.999 | |
| - `adam_epsilon`: 1e-08 | |
| - `optim_target_modules`: None | |
| - `gradient_accumulation_steps`: 1 | |
| - `average_tokens_across_devices`: True | |
| - `max_grad_norm`: 1.0 | |
| - `label_smoothing_factor`: 0.0 | |
| - `bf16`: False | |
| - `fp16`: False | |
| - `bf16_full_eval`: False | |
| - `fp16_full_eval`: False | |
| - `tf32`: None | |
| - `gradient_checkpointing`: False | |
| - `gradient_checkpointing_kwargs`: None | |
| - `torch_compile`: False | |
| - `torch_compile_backend`: None | |
| - `torch_compile_mode`: None | |
| - `use_liger_kernel`: False | |
| - `liger_kernel_config`: None | |
| - `use_cache`: False | |
| - `neftune_noise_alpha`: None | |
| - `torch_empty_cache_steps`: None | |
| - `auto_find_batch_size`: False | |
| - `log_on_each_node`: True | |
| - `logging_nan_inf_filter`: True | |
| - `include_num_input_tokens_seen`: no | |
| - `log_level`: passive | |
| - `log_level_replica`: warning | |
| - `disable_tqdm`: True | |
| - `project`: huggingface | |
| - `trackio_space_id`: None | |
| - `trackio_bucket_id`: None | |
| - `trackio_static_space_id`: None | |
| - `per_device_eval_batch_size`: 8 | |
| - `prediction_loss_only`: True | |
| - `eval_on_start`: False | |
| - `eval_do_concat_batches`: True | |
| - `eval_use_gather_object`: False | |
| - `eval_accumulation_steps`: None | |
| - `include_for_metrics`: [] | |
| - `batch_eval_metrics`: False | |
| - `save_only_model`: False | |
| - `save_on_each_node`: False | |
| - `enable_jit_checkpoint`: False | |
| - `push_to_hub`: False | |
| - `hub_private_repo`: None | |
| - `hub_model_id`: None | |
| - `hub_strategy`: every_save | |
| - `hub_always_push`: False | |
| - `hub_revision`: None | |
| - `load_best_model_at_end`: False | |
| - `ignore_data_skip`: False | |
| - `restore_callback_states_from_checkpoint`: False | |
| - `full_determinism`: False | |
| - `seed`: 42 | |
| - `data_seed`: None | |
| - `use_cpu`: False | |
| - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None} | |
| - `parallelism_config`: None | |
| - `dataloader_drop_last`: False | |
| - `dataloader_num_workers`: 0 | |
| - `dataloader_pin_memory`: True | |
| - `dataloader_persistent_workers`: False | |
| - `dataloader_prefetch_factor`: None | |
| - `remove_unused_columns`: True | |
| - `label_names`: None | |
| - `train_sampling_strategy`: random | |
| - `length_column_name`: length | |
| - `ddp_find_unused_parameters`: None | |
| - `ddp_bucket_cap_mb`: None | |
| - `ddp_broadcast_buffers`: False | |
| - `ddp_static_graph`: None | |
| - `ddp_backend`: None | |
| - `ddp_timeout`: 1800 | |
| - `fsdp`: None | |
| - `fsdp_config`: None | |
| - `deepspeed`: None | |
| - `debug`: [] | |
| - `skip_memory_metrics`: True | |
| - `do_predict`: False | |
| - `resume_from_checkpoint`: None | |
| - `warmup_ratio`: None | |
| - `local_rank`: -1 | |
| - `prompts`: None | |
| - `batch_sampler`: batch_sampler | |
| - `multi_dataset_batch_sampler`: proportional | |
| - `router_mapping`: {} | |
| - `learning_rate_mapping`: {} | |
| </details> | |
| ### Training Logs | |
| | Epoch | Step | Training Loss | | |
| |:------:|:----:|:-------------:| | |
| | 0.0013 | 1 | 2.9614 | | |
| | 0.0134 | 10 | 0.8912 | | |
| | 0.0268 | 20 | 0.8821 | | |
| | 0.0402 | 30 | 0.6854 | | |
| | 0.0536 | 40 | 0.7558 | | |
| | 0.0670 | 50 | 0.6960 | | |
| | 0.0804 | 60 | 0.6753 | | |
| | 0.0938 | 70 | 0.6979 | | |
| | 0.1072 | 80 | 0.6919 | | |
| | 0.1206 | 90 | 0.6373 | | |
| | 0.1340 | 100 | 0.6750 | | |
| | 0.1475 | 110 | 0.7235 | | |
| | 0.1609 | 120 | 0.6508 | | |
| | 0.1743 | 130 | 0.6698 | | |
| | 0.1877 | 140 | 0.6603 | | |
| | 0.2011 | 150 | 0.6601 | | |
| | 0.2145 | 160 | 0.6269 | | |
| | 0.2279 | 170 | 0.6568 | | |
| | 0.2413 | 180 | 0.5662 | | |
| | 0.2547 | 190 | 0.6341 | | |
| | 0.2681 | 200 | 0.6649 | | |
| | 0.2815 | 210 | 0.6582 | | |
| | 0.2949 | 220 | 0.6966 | | |
| | 0.3083 | 230 | 0.5850 | | |
| | 0.3217 | 240 | 0.5919 | | |
| | 0.3351 | 250 | 0.6952 | | |
| | 0.3485 | 260 | 0.6682 | | |
| | 0.3619 | 270 | 0.6402 | | |
| | 0.3753 | 280 | 0.6923 | | |
| | 0.3887 | 290 | 0.5896 | | |
| | 0.4021 | 300 | 0.6448 | | |
| | 0.4155 | 310 | 0.6208 | | |
| | 0.4290 | 320 | 0.6557 | | |
| | 0.4424 | 330 | 0.6780 | | |
| | 0.4558 | 340 | 0.6057 | | |
| | 0.4692 | 350 | 0.6660 | | |
| | 0.4826 | 360 | 0.6834 | | |
| | 0.4960 | 370 | 0.6351 | | |
| | 0.5094 | 380 | 0.6442 | | |
| | 0.5228 | 390 | 0.6002 | | |
| | 0.5362 | 400 | 0.6454 | | |
| | 0.5496 | 410 | 0.6431 | | |
| | 0.5630 | 420 | 0.6146 | | |
| | 0.5764 | 430 | 0.5826 | | |
| | 0.5898 | 440 | 0.6906 | | |
| | 0.6032 | 450 | 0.6260 | | |
| | 0.6166 | 460 | 0.6390 | | |
| | 0.6300 | 470 | 0.6107 | | |
| | 0.6434 | 480 | 0.6381 | | |
| | 0.6568 | 490 | 0.6296 | | |
| | 0.6702 | 500 | 0.6163 | | |
| | 0.6836 | 510 | 0.5750 | | |
| | 0.6971 | 520 | 0.6387 | | |
| | 0.7105 | 530 | 0.6353 | | |
| | 0.7239 | 540 | 0.5639 | | |
| | 0.7373 | 550 | 0.5501 | | |
| | 0.7507 | 560 | 0.6608 | | |
| | 0.7641 | 570 | 0.6868 | | |
| | 0.7775 | 580 | 0.5937 | | |
| | 0.7909 | 590 | 0.6198 | | |
| | 0.8043 | 600 | 0.6683 | | |
| | 0.8177 | 610 | 0.6228 | | |
| | 0.8311 | 620 | 0.5776 | | |
| | 0.8445 | 630 | 0.6115 | | |
| | 0.8579 | 640 | 0.6536 | | |
| | 0.8713 | 650 | 0.6366 | | |
| | 0.8847 | 660 | 0.6278 | | |
| | 0.8981 | 670 | 0.6331 | | |
| | 0.9115 | 680 | 0.5928 | | |
| | 0.9249 | 690 | 0.6246 | | |
| | 0.9383 | 700 | 0.6273 | | |
| | 0.9517 | 710 | 0.6254 | | |
| | 0.9651 | 720 | 0.5991 | | |
| | 0.9786 | 730 | 0.6309 | | |
| | 0.9920 | 740 | 0.5972 | | |
| ### Training Time | |
| - **Training**: 19.5 seconds | |
| ### Framework Versions | |
| - Python: 3.11.6 | |
| - Sentence Transformers: 5.6.1 | |
| - Transformers: 5.14.1 | |
| - PyTorch: 2.13.0+cu130 | |
| - Accelerate: 1.14.0 | |
| - Datasets: 5.0.0 | |
| - Tokenizers: 0.22.2 | |
| ## Additional Resources | |
| - [Training and Finetuning Reranker Models with Sentence Transformers](https://huggingface.co/blog/train-reranker): the end-to-end guide for training or finetuning Cross Encoder (reranker) models. | |
| - [Multimodal Embedding & Reranker Models with Sentence Transformers](https://huggingface.co/blog/multimodal-sentence-transformers): use text, image, audio, and video reranker models through the same API. | |
| - [Training and Finetuning Multimodal Embedding & Reranker Models with Sentence Transformers](https://huggingface.co/blog/train-multimodal-sentence-transformers): training multimodal Cross Encoders. | |
| ## 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", | |
| } | |
| ``` | |
| <!-- | |
| ## 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.* | |
| --> |