You need to agree to share your Hugging Face information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

PharmAfiyahProducts โ€” doctobert fine-tunรฉ pour le matching de produits pharmaceutiques

But du modรจle

Ce modรจle est un bi-encoder de similaritรฉ textuelle, fine-tunรฉ ร  partir de doctolib-lab/doctobert-fr-base pour la recherche de produits pharmaceutiques et parapharmaceutiques par similaritรฉ : ร  partir d'une dรฉsignation de produit (souvent abrรฉgรฉe, รฉcrite de faรงon incohรฉrente d'un systรจme ร  l'autre), il permet de retrouver dans un rรฉfรฉrentiel les produits qui dรฉsignent le mรชme produit et la mรชme prรฉsentation (mรชme marque, principe actif, dosage, forme galรฉnique, volume, conditionnement), avec un score de similaritรฉ cosinus.

Il est conรงu pour une รฉtape de retrieval rapide (embeddings + recherche par similaritรฉ, ex. via un index FAISS) : ร  partir d'un produit donnรฉ, le modรจle retrouve les candidats les plus proches dans un rรฉfรฉrentiel de produits, ร  utiliser ensuite pour une dรฉduplication de catalogue, un matching produit, ou une recherche assistรฉe.

Ce n'est pas un modรจle de similaritรฉ sรฉmantique gรฉnรฉrale โ€” il est spรฉcialisรฉ sur des noms de produits courts, trรจs abrรฉgรฉs, avec un fort enjeu ร  distinguer des textes presque identiques qui ne diffรจrent que par un dosage, un volume ou une marque (ex. "AMCARD CPR 10MG BT14" vs "AMCARD CPR 5MG BT14" doivent รชtre รฉcartรฉs, pas rapprochรฉs).

Mรฉtriques (classification binaire par similaritรฉ cosinus, jeu de validation)

Mรฉtrique Valeur
Cosine AP (Average Precision) 0.9685
Cosine F1 0.8976
Cosine Precision 0.9195
Cosine Recall 0.8752
Cosine Accuracy 0.8976
Cosine MCC 0.7963

Donnรฉes d'entraรฎnement

  • Base : doctolib-lab/doctobert-fr-base
  • Paires labellisรฉes (1 = mรชme produit/prรฉsentation, 0 = diffรฉrent), issues de comparaisons de dรฉsignations de produits pharmaceutiques, labellisรฉes par un LLM puis vรฉrifiรฉes
  • 8481 paires d'entraรฎnement / 1387 de validation, labels globalement รฉquilibrรฉs (train : 4252 nรฉgatifs / 4229 positifs)
  • Loss : OnlineContrastiveLoss (similaritรฉ cosinus)

This is a sentence-transformers model finetuned from doctolib-lab/doctobert-fr-base. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.

Model Details

Model Description

  • Model Type: Sentence Transformer
  • Base model: doctolib-lab/doctobert-fr-base
  • Maximum Sequence Length: 64 tokens
  • Output Dimensionality: 768 dimensions
  • Similarity Function: Cosine Similarity

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 64, 'do_lower_case': False, 'architecture': 'RobertaModel'})
  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)

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 SentenceTransformer

# Download from the ๐Ÿค— Hub
model = SentenceTransformer("sentence_transformers_model_id")
# Run inference
sentences = [
    'ACILOC 25MG/ML AMP/2ML BT5 AZANTAC',
    'AZANTAC ACILOC 25MG/ML AMP/2ML B/5',
    'NATURALIA CR SPF20 DEPIG 50 ML',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.9727, 0.3115],
#         [0.9727, 1.0000, 0.2771],
#         [0.3115, 0.2771, 1.0000]])

Evaluation

Metrics

Binary Classification

Metric Value
cosine_accuracy 0.8976
cosine_accuracy_threshold 0.8936
cosine_f1 0.8968
cosine_f1_threshold 0.8881
cosine_precision 0.9195
cosine_recall 0.8752
cosine_ap 0.9685
cosine_mcc 0.7963

Training Details

Training Dataset

Unnamed Dataset

  • Size: 8,481 training samples
  • Columns: name_left, name_right, and label
  • Approximate statistics based on the first 1000 samples:
    name_left name_right label
    type string string float
    details
    • min: 3 tokens
    • mean: 16.28 tokens
    • max: 34 tokens
    • min: 4 tokens
    • mean: 16.81 tokens
    • max: 32 tokens
    • min: 0.0
    • mean: 0.49
    • max: 1.0
  • Samples:
    name_left name_right label
    EFFACLAR DUO+ 40ML M6940501 EFFACLAR DUO+ 40 ML M6940501 1.0
    AVENE CLEAN SPOT SOIN LOCALIS AVENE CLEAN SPOT SOIN LOCALISE 1.0
    Canpol Tรฉtine Biberon Standart Croix 2pcs 6M+ Canpol Tรฉtine Biberon Standart Slow 3M+ 2pcs 0.0
  • Loss: OnlineContrastiveLoss

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • gradient_accumulation_steps: 4
  • learning_rate: 2e-05
  • num_train_epochs: 8
  • warmup_ratio: 0.1
  • data_seed: 42
  • fp16: True
  • load_best_model_at_end: True
  • auto_find_batch_size: True

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 8
  • per_device_eval_batch_size: 8
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 4
  • 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: 8
  • 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: 42
  • jit_mode_eval: False
  • bf16: False
  • fp16: True
  • 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: True
  • 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: {}

Training Logs

Epoch Step Training Loss validation_cosine_ap
0.5014 133 0.3404 0.8725
1.0 266 0.1281 0.9267
1.5014 399 0.0943 0.9419
2.0 532 0.077 0.9508
2.5014 665 0.0488 0.9504
3.0 798 0.0544 0.9544
3.5014 931 0.033 0.9566
4.0 1064 0.0394 0.9571
4.5014 1197 0.0308 0.9590
5.0 1330 0.0282 0.9662
5.5014 1463 0.0252 0.9654
6.0 1596 0.0255 0.9656
6.5014 1729 0.0192 0.9685
7.0 1862 0.0149 0.9685
7.5014 1995 0.0185 0.9686
8.0 2128 0.0152 0.9685
  • The bold row denotes the saved checkpoint.

Framework Versions

  • Python: 3.13.11
  • Sentence Transformers: 5.2.2
  • Transformers: 4.57.6
  • PyTorch: 2.10.0+cu128
  • Accelerate: 1.12.0
  • Datasets: 4.5.0
  • Tokenizers: 0.22.2

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",
}
Downloads last month
2
Safetensors
Model size
0.1B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Fallovski/PharmAfiyahProducts

Finetuned
(2)
this model

Paper for Fallovski/PharmAfiyahProducts

Evaluation results