Text Ranking
sentence-transformers
Safetensors
roberta
cross-encoder
reranker
Generated from Trainer
dataset_size:11426
loss:BinaryCrossEntropyLoss
Eval Results (legacy)
text-embeddings-inference
Instructions to use Fallovski/CrossencoderPharma with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Fallovski/CrossencoderPharma with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("Fallovski/CrossencoderPharma") 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:11426 | |
| - loss:BinaryCrossEntropyLoss | |
| base_model: doctolib-lab/doctobert-fr-base | |
| pipeline_tag: text-ranking | |
| library_name: sentence-transformers | |
| metrics: | |
| - accuracy | |
| - accuracy_threshold | |
| - f1 | |
| - f1_threshold | |
| - precision | |
| - recall | |
| - average_precision | |
| model-index: | |
| - name: CrossEncoder based on doctolib-lab/doctobert-fr-base | |
| results: | |
| - task: | |
| type: cross-encoder-classification | |
| name: Cross Encoder Classification | |
| dataset: | |
| name: validation | |
| type: validation | |
| metrics: | |
| - type: accuracy | |
| value: 0.9871031746031746 | |
| name: Accuracy | |
| - type: accuracy_threshold | |
| value: 0.5494990944862366 | |
| name: Accuracy Threshold | |
| - type: f1 | |
| value: 0.9868819374369323 | |
| name: F1 | |
| - type: f1_threshold | |
| value: 0.5494990944862366 | |
| name: F1 Threshold | |
| - type: precision | |
| value: 0.9848942598187311 | |
| name: Precision | |
| - type: recall | |
| value: 0.9888776541961577 | |
| name: Recall | |
| - type: average_precision | |
| value: 0.9981127842050731 | |
| name: Average Precision | |
| # CrossEncoder based on doctolib-lab/doctobert-fr-base | |
| This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model finetuned from [doctolib-lab/doctobert-fr-base](https://huggingface.co/doctolib-lab/doctobert-fr-base) 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:** [doctolib-lab/doctobert-fr-base](https://huggingface.co/doctolib-lab/doctobert-fr-base) <!-- at revision 314480d545f154e3758a1ce741ffe1ac4ac7b4d0 --> | |
| - **Maximum Sequence Length:** 64 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': 'RobertaForSequenceClassification'}) | |
| ) | |
| ``` | |
| ## 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("Fallovski/CrossencoderPharma") | |
| # Get scores for pairs of inputs | |
| pairs = [ | |
| ['KLIPAL CODEINE 300/25 MG CP /16', 'ANTHELIOS 30+ ULT YX SENS 50ML'], | |
| ['BIOTIC PLUS 100MG ENF 60ML', 'BIOTIC PLUS 500MG SACH B/14'], | |
| ['FALCIART 80/480 MG COMP B/6', 'FALCIART CPR 80/480MG BT6'], | |
| ['KLACIN CPR 625MG BT15', 'Klacin Cpr 625Mg Bt15'], | |
| ['INDOCOLLYRE 0.1% ETO F/5ML B/1', 'Indocollyre 0.1% Eto F/5Ml B/1'], | |
| ] | |
| scores = model.predict(pairs) | |
| print(scores) | |
| # [9.7995e-04 1.1121e-03 9.9875e-01 9.9884e-01 9.9885e-01] | |
| # Or rank different texts based on similarity to a single text | |
| ranks = model.rank( | |
| 'KLIPAL CODEINE 300/25 MG CP /16', | |
| [ | |
| 'ANTHELIOS 30+ ULT YX SENS 50ML', | |
| 'BIOTIC PLUS 500MG SACH B/14', | |
| 'FALCIART CPR 80/480MG BT6', | |
| 'Klacin Cpr 625Mg Bt15', | |
| 'Indocollyre 0.1% Eto F/5Ml B/1', | |
| ] | |
| ) | |
| # [{'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.* | |
| --> | |
| ## Evaluation | |
| ### Metrics | |
| #### Cross Encoder Classification | |
| * Dataset: `validation` | |
| * Evaluated with [<code>CrossEncoderClassificationEvaluator</code>](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CrossEncoderClassificationEvaluator) | |
| | Metric | Value | | |
| |:----------------------|:-----------| | |
| | accuracy | 0.9871 | | |
| | accuracy_threshold | 0.5495 | | |
| | f1 | 0.9869 | | |
| | f1_threshold | 0.5495 | | |
| | precision | 0.9849 | | |
| | recall | 0.9889 | | |
| | **average_precision** | **0.9981** | | |
| <!-- | |
| ## 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,426 training samples | |
| * Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>label</code> | |
| * Approximate statistics based on the first 100 samples: | |
| | | sentence1 | sentence2 | label | | |
| |:---------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------| | |
| | type | string | string | float | | |
| | modality | text | text | | | |
| | details | <ul><li>min: 6 tokens</li><li>mean: 16.49 tokens</li><li>max: 27 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 16.99 tokens</li><li>max: 28 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.51</li><li>max: 1.0</li></ul> | | |
| * Samples: | |
| | sentence1 | sentence2 | label | | |
| |:--------------------------------------------------|:-------------------------------------------------|:-----------------| | |
| | <code>SÉROLOGIE ARBOVIRUS</code> | <code>SÉROLOGIE WRIGHT</code> | <code>0.0</code> | | |
| | <code>SOND FOL H 15ML AA14 16CH /1</code> | <code>SOND FOL H 15ML AA14 16CH 1</code> | <code>1.0</code> | | |
| | <code>FARLINE CAPRI D +1.5 MARON BLANC HOM</code> | <code>FARLINE MONZA CAREY +3.0 MARON/NOIR</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 | |
| } | |
| ``` | |
| ### Evaluation Dataset | |
| #### Unnamed Dataset | |
| * Size: 2,016 evaluation samples | |
| * Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>label</code> | |
| * Approximate statistics based on the first 100 samples: | |
| | | sentence1 | sentence2 | label | | |
| |:---------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------| | |
| | type | string | string | float | | |
| | modality | text | text | | | |
| | details | <ul><li>min: 5 tokens</li><li>mean: 16.54 tokens</li><li>max: 35 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 16.98 tokens</li><li>max: 33 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.51</li><li>max: 1.0</li></ul> | | |
| * Samples: | |
| | sentence1 | sentence2 | label | | |
| |:---------------------------------------------|:--------------------------------------------|:-----------------| | |
| | <code>KLIPAL CODEINE 300/25 MG CP /16</code> | <code>ANTHELIOS 30+ ULT YX SENS 50ML</code> | <code>0.0</code> | | |
| | <code>BIOTIC PLUS 100MG ENF 60ML</code> | <code>BIOTIC PLUS 500MG SACH B/14</code> | <code>0.0</code> | | |
| | <code>FALCIART 80/480 MG COMP B/6</code> | <code>FALCIART CPR 80/480MG BT6</code> | <code>1.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`: 32 | |
| - `per_device_eval_batch_size`: 32 | |
| - `learning_rate`: 2e-05 | |
| - `num_train_epochs`: 6 | |
| - `warmup_ratio`: 0.1 | |
| - `load_best_model_at_end`: True | |
| #### All Hyperparameters | |
| <details><summary>Click to expand</summary> | |
| - `overwrite_output_dir`: False | |
| - `do_predict`: False | |
| - `prediction_loss_only`: True | |
| - `per_device_train_batch_size`: 32 | |
| - `per_device_eval_batch_size`: 32 | |
| - `per_gpu_train_batch_size`: None | |
| - `per_gpu_eval_batch_size`: None | |
| - `gradient_accumulation_steps`: 1 | |
| - `eval_accumulation_steps`: None | |
| - `torch_empty_cache_steps`: None | |
| - `learning_rate`: 2e-05 | |
| - `weight_decay`: 0.0 | |
| - `adam_beta1`: 0.9 | |
| - `adam_beta2`: 0.999 | |
| - `adam_epsilon`: 1e-08 | |
| - `max_grad_norm`: 1.0 | |
| - `num_train_epochs`: 6 | |
| - `max_steps`: -1 | |
| - `lr_scheduler_type`: linear | |
| - `lr_scheduler_kwargs`: None | |
| - `warmup_ratio`: 0.1 | |
| - `warmup_steps`: 0 | |
| - `log_level`: passive | |
| - `log_level_replica`: warning | |
| - `log_on_each_node`: True | |
| - `logging_nan_inf_filter`: True | |
| - `save_safetensors`: True | |
| - `save_on_each_node`: False | |
| - `save_only_model`: False | |
| - `restore_callback_states_from_checkpoint`: False | |
| - `no_cuda`: False | |
| - `use_cpu`: False | |
| - `use_mps_device`: False | |
| - `seed`: 42 | |
| - `data_seed`: None | |
| - `jit_mode_eval`: False | |
| - `bf16`: False | |
| - `fp16`: False | |
| - `fp16_opt_level`: O1 | |
| - `half_precision_backend`: auto | |
| - `bf16_full_eval`: False | |
| - `fp16_full_eval`: False | |
| - `tf32`: None | |
| - `local_rank`: 0 | |
| - `ddp_backend`: None | |
| - `tpu_num_cores`: None | |
| - `tpu_metrics_debug`: False | |
| - `debug`: [] | |
| - `dataloader_drop_last`: False | |
| - `dataloader_num_workers`: 0 | |
| - `dataloader_prefetch_factor`: None | |
| - `past_index`: -1 | |
| - `disable_tqdm`: False | |
| - `remove_unused_columns`: True | |
| - `label_names`: None | |
| - `load_best_model_at_end`: True | |
| - `ignore_data_skip`: False | |
| - `fsdp`: [] | |
| - `fsdp_min_num_params`: 0 | |
| - `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False} | |
| - `fsdp_transformer_layer_cls_to_wrap`: None | |
| - `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 | |
| - `deepspeed`: None | |
| - `label_smoothing_factor`: 0.0 | |
| - `optim`: adamw_torch_fused | |
| - `optim_args`: None | |
| - `adafactor`: False | |
| - `group_by_length`: False | |
| - `length_column_name`: length | |
| - `project`: huggingface | |
| - `trackio_space_id`: trackio | |
| - `ddp_find_unused_parameters`: None | |
| - `ddp_bucket_cap_mb`: None | |
| - `ddp_broadcast_buffers`: False | |
| - `dataloader_pin_memory`: True | |
| - `dataloader_persistent_workers`: False | |
| - `skip_memory_metrics`: True | |
| - `use_legacy_prediction_loop`: False | |
| - `push_to_hub`: False | |
| - `resume_from_checkpoint`: None | |
| - `hub_model_id`: None | |
| - `hub_strategy`: every_save | |
| - `hub_private_repo`: None | |
| - `hub_always_push`: False | |
| - `hub_revision`: None | |
| - `gradient_checkpointing`: False | |
| - `gradient_checkpointing_kwargs`: None | |
| - `include_inputs_for_metrics`: False | |
| - `include_for_metrics`: [] | |
| - `eval_do_concat_batches`: True | |
| - `fp16_backend`: auto | |
| - `push_to_hub_model_id`: None | |
| - `push_to_hub_organization`: None | |
| - `mp_parameters`: | |
| - `auto_find_batch_size`: False | |
| - `full_determinism`: False | |
| - `torchdynamo`: None | |
| - `ray_scope`: last | |
| - `ddp_timeout`: 1800 | |
| - `torch_compile`: False | |
| - `torch_compile_backend`: None | |
| - `torch_compile_mode`: None | |
| - `include_tokens_per_second`: False | |
| - `include_num_input_tokens_seen`: no | |
| - `neftune_noise_alpha`: None | |
| - `optim_target_modules`: None | |
| - `batch_eval_metrics`: False | |
| - `eval_on_start`: False | |
| - `use_liger_kernel`: False | |
| - `liger_kernel_config`: None | |
| - `eval_use_gather_object`: False | |
| - `average_tokens_across_devices`: True | |
| - `prompts`: None | |
| - `batch_sampler`: batch_sampler | |
| - `multi_dataset_batch_sampler`: proportional | |
| - `router_mapping`: {} | |
| - `learning_rate_mapping`: {} | |
| </details> | |
| ### Training Logs | |
| | Epoch | Step | Training Loss | Validation Loss | validation_average_precision | | |
| |:-------:|:-------:|:-------------:|:---------------:|:----------------------------:| | |
| | 0.1397 | 50 | 0.6869 | - | - | | |
| | 0.2793 | 100 | 0.3572 | - | - | | |
| | 0.4190 | 150 | 0.1483 | - | - | | |
| | 0.5587 | 200 | 0.13 | - | - | | |
| | 0.6983 | 250 | 0.1394 | - | - | | |
| | 0.8380 | 300 | 0.106 | - | - | | |
| | 0.9777 | 350 | 0.0999 | - | - | | |
| | 1.0 | 358 | - | 0.1673 | 0.9963 | | |
| | 1.1173 | 400 | 0.084 | - | - | | |
| | 1.2570 | 450 | 0.0731 | - | - | | |
| | 1.3966 | 500 | 0.0716 | - | - | | |
| | 1.5363 | 550 | 0.0699 | - | - | | |
| | 1.6760 | 600 | 0.0647 | - | - | | |
| | 1.8156 | 650 | 0.0691 | - | - | | |
| | 1.9553 | 700 | 0.0942 | - | - | | |
| | **2.0** | **716** | **-** | **0.0571** | **0.9981** | | |
| | 2.0950 | 750 | 0.0399 | - | - | | |
| | 2.2346 | 800 | 0.0503 | - | - | | |
| | 2.3743 | 850 | 0.0219 | - | - | | |
| | 2.5140 | 900 | 0.0456 | - | - | | |
| | 2.6536 | 950 | 0.0536 | - | - | | |
| | 2.7933 | 1000 | 0.0349 | - | - | | |
| | 2.9330 | 1050 | 0.052 | - | - | | |
| | 3.0 | 1074 | - | 0.0602 | 0.9983 | | |
| | 3.0726 | 1100 | 0.0398 | - | - | | |
| | 3.2123 | 1150 | 0.0128 | - | - | | |
| | 3.3520 | 1200 | 0.022 | - | - | | |
| | 3.4916 | 1250 | 0.0122 | - | - | | |
| | 3.6313 | 1300 | 0.0265 | - | - | | |
| | 3.7709 | 1350 | 0.04 | - | - | | |
| | 3.9106 | 1400 | 0.0242 | - | - | | |
| | 4.0 | 1432 | - | 0.0684 | 0.9987 | | |
| | 4.0503 | 1450 | 0.0186 | - | - | | |
| | 4.1899 | 1500 | 0.0185 | - | - | | |
| | 4.3296 | 1550 | 0.0129 | - | - | | |
| | 4.4693 | 1600 | 0.0113 | - | - | | |
| | 4.6089 | 1650 | 0.0103 | - | - | | |
| | 4.7486 | 1700 | 0.003 | - | - | | |
| | 4.8883 | 1750 | 0.0207 | - | - | | |
| | 5.0 | 1790 | - | 0.0744 | 0.9987 | | |
| | 5.0279 | 1800 | 0.0181 | - | - | | |
| | 5.1676 | 1850 | 0.0158 | - | - | | |
| | 5.3073 | 1900 | 0.0156 | - | - | | |
| | 5.4469 | 1950 | 0.0123 | - | - | | |
| | 5.5866 | 2000 | 0.0094 | - | - | | |
| | 5.7263 | 2050 | 0.0159 | - | - | | |
| | 5.8659 | 2100 | 0.0033 | - | - | | |
| | 6.0 | 2148 | - | 0.0649 | 0.9988 | | |
| | -1 | -1 | - | - | 0.9981 | | |
| * The bold row denotes the saved checkpoint. | |
| ### Training Time | |
| - **Training**: 10.8 minutes | |
| - **Evaluation**: 1.1 minutes | |
| - **Total**: 11.9 minutes | |
| ### Framework Versions | |
| - Python: 3.13.11 | |
| - Sentence Transformers: 5.6.1 | |
| - Transformers: 4.57.6 | |
| - PyTorch: 2.13.0+cu130 | |
| - Accelerate: 1.14.0 | |
| - Datasets: 5.0.1 | |
| - 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.* | |
| --> |