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
metadata
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 model finetuned from doctolib-lab/doctobert-fr-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: doctolib-lab/doctobert-fr-base
- Maximum Sequence Length: 64 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': 'RobertaForSequenceClassification'})
)
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("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': ...}, ...]
Evaluation
Metrics
Cross Encoder Classification
- Dataset:
validation - Evaluated with
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 |
Training Details
Training Dataset
Unnamed Dataset
- Size: 11,426 training samples
- Columns:
sentence1,sentence2, andlabel - Approximate statistics based on the first 100 samples:
sentence1 sentence2 label type string string float modality text text details - min: 6 tokens
- mean: 16.49 tokens
- max: 27 tokens
- min: 5 tokens
- mean: 16.99 tokens
- max: 28 tokens
- min: 0.0
- mean: 0.51
- max: 1.0
- Samples:
sentence1 sentence2 label SÉROLOGIE ARBOVIRUSSÉROLOGIE WRIGHT0.0SOND FOL H 15ML AA14 16CH /1SOND FOL H 15ML AA14 16CH 11.0FARLINE CAPRI D +1.5 MARON BLANC HOMFARLINE MONZA CAREY +3.0 MARON/NOIR0.0 - Loss:
BinaryCrossEntropyLosswith these parameters:{ "activation_fn": "torch.nn.modules.linear.Identity", "pos_weight": null }
Evaluation Dataset
Unnamed Dataset
- Size: 2,016 evaluation samples
- Columns:
sentence1,sentence2, andlabel - Approximate statistics based on the first 100 samples:
sentence1 sentence2 label type string string float modality text text details - min: 5 tokens
- mean: 16.54 tokens
- max: 35 tokens
- min: 5 tokens
- mean: 16.98 tokens
- max: 33 tokens
- min: 0.0
- mean: 0.51
- max: 1.0
- Samples:
sentence1 sentence2 label KLIPAL CODEINE 300/25 MG CP /16ANTHELIOS 30+ ULT YX SENS 50ML0.0BIOTIC PLUS 100MG ENF 60MLBIOTIC PLUS 500MG SACH B/140.0FALCIART 80/480 MG COMP B/6FALCIART CPR 80/480MG BT61.0 - Loss:
BinaryCrossEntropyLosswith these parameters:{ "activation_fn": "torch.nn.modules.linear.Identity", "pos_weight": null }
Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size: 32per_device_eval_batch_size: 32learning_rate: 2e-05num_train_epochs: 6warmup_ratio: 0.1load_best_model_at_end: True
All Hyperparameters
Click to expand
overwrite_output_dir: Falsedo_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 32per_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: 6max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_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: 42data_seed: Nonejit_mode_eval: Falsebf16: Falsefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_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}fsdp_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}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_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: Falsehub_revision: Nonegradient_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: noneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Trueprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}
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: 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",
}