Edit model card

You need to agree to share your contact 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.

Model Card for Model ID

Model Details

Model Description

This cross-encoder is designed for the French RAG system to detect the relevance between questions and their context. Its evaluation is done using CEBinaryClassificationEvaluator. The model is based on the distilroberta-base architecture and fine-tuned on the LeviatanAIResearch/cross-encoder-binary-context-quesion-v1 French dataset. After 4 training epochs, the model achieved a average precision of 0.993 on the test set.
This cross-encoder hasn't been trained on similarity datasets similar to STSB. Consequently, the evaluation Spearman correlation on the STS-B development set through CECorrelationEvaluator is 0.612, and on the test set, it is 0.467. The evaluation Pearson correlation on the development set is 0.471, and on the test set, it is 0.349.

Uses

! pip install sentencepiece
! pip install sentence-transformers
from sentence_transformers.cross_encoder import CrossEncoder
from huggingface_hub import login
login(os.getenv('HF_TOKEN'))
model_path = 'LeviatanAIResearch/cross-encoder-context-question-fr-v1'
model =  CrossEncoder(model_path, max_length=512)

scores = model.predict([
    ('Un avion est en train de décoller.', "Un homme joue d'une grande flûte."), 
    ('Un homme coupe une poisson.', 'Un homme coupe une poisson en tranche.'),
    ("Un homme étale du fromage râpé sur une pizza.", "Une personne jette un chat au plafond"),
    (
        "Quelle eau pour la préparation du biberon ?", 
        "Les meilleurs aliments pour nourrir votre bébé sont le lait maternel ou le lait maternisé, les purées de légumes et de fruits, les céréales pour bébés enrichies en fer, les viandes maigres, les poissons riches en oméga-3, etc. Il est important de proposer une variété d'aliments sains pour assurer un bon développement et une nutrition optimale de votre bébé."
    ),
    (
        "Quelle eau pour la préparation du biberon ?",
        "L'image montre une publicité pour un coffret naissance gratuit contenant divers produits destinés aux bébés, comme des couches, un biberon et des soins, accompagnée d'un appel à l'action pour s'inscrire et découvrir où récupérer le cadeau."
    ),
    (
        "Quelle eau pour la préparation du biberon ?",
        "La publicité montre un adulte et un bébé, le bébé tenant un biberon, avec un fond partagé entre une image et un message marketing qui questionne sur le choix de l'eau pour les nourrissons, mettant en avant la marque Mont Roucous comme un accompagnement dans la maternité."
    )
])
print(scores)

Training Details

Training Data

The dataset LeviatanAIResearch/cross-encoder-binary-context-quesion-v1 was developed by the Leviatan AI team to train the cross-encoder of our RAG system. It is a combination of the PIAF, FQuAD, and SQuAD-French datasets, with additional negative samples created from irrelevant questions selected arbitrarily.

Training Hyperparameters

  • evaluator=CEBinaryClassificationEvaluator
  • epochs=4
  • batch_size=16
  • evaluation_steps=5000
  • warmup_steps=5388 (10% of train data for warm-up)
  • save_best_model=True
  • Furthermore, all other hyperparameters are set to their default values.

Evaluation

  • LeviatanAIResearch/cross-encoder-context-question-fr-v1 Test set:
    • Metric : CEBinaryClassificationEvaluator
    • Accuracy: 97.65 (Threshold: 0.9848)
    • F1: 97.65 (Threshold: 0.9848)
    • Precision: 97.85
    • Recall: 97.45
    • Average Precision: 99.31
  • STSD Dev set:
    • Metric : CECorrelationEvaluator
    • Correlation :
      • Spearman: 0.612
      • Pearson: 0.471
  • STSD Test set:
    • Metric : CECorrelationEvaluator
    • Correlation
      • Spearman: 0.467
      • Pearson: 0.349
Downloads last month
6
Safetensors
Model size
82.1M params
Tensor type
F32
·