Similarité des questions et correction grammaticale

Natural Language Processing (NLP) en Python

Fouad Trad

Machine Learning Engineer

Similarité de questions

  • Détecte si deux questions sont des reformulations
  • Utile pour :
    • Déduplication
    • Regrouper les questions similaires
    • Améliorer la précision de recherche
  • Réalisé avec des modèles entraînés sur l'ensemble de données Quora Question Pairs (QQP)

Image montrant trois personnes qui posent des questions.

Natural Language Processing (NLP) en Python

Canal QQP

from transformers import pipeline

qqp_pipeline = pipeline( task="text-classification", model="textattack/bert-base-uncased-QQP" )
question1 = "How can I learn Python?" question2 = "What is the best way to study Python?"
result = qqp_pipeline({"text": question1, "text_pair": question2})
print(result)
{'label': 'LABEL_1', 'score': 0.6853412985801697}
Natural Language Processing (NLP) en Python

Canal QQP

from transformers import pipeline
qqp_pipeline = pipeline(
    task="text-classification", 
    model="textattack/bert-base-uncased-QQP"
    )
question1 = "How can I learn Python?"
question2 = "What is the capital of France?"
result = qqp_pipeline({"text": question1, "text_pair": question2})
print(result)
{'label': 'LABEL_0', 'score': 0.9999338388442993}
Natural Language Processing (NLP) en Python

Évaluer la correction grammaticale

  • Évalue le degré de correction grammaticale d'un texte
  • Utile pour :

    • Outils éducatifs
    • Correcteurs grammaticaux
    • Assistants d'écriture
  • Réalisé avec des modèles entraînés sur l'ensemble de données Corpus of Linguistic Acceptability (CoLA)

Image montrant une personne qui évalue la correction d'un texte écrit.

Natural Language Processing (NLP) en Python

Canal CoLA

from transformers import pipeline
cola_classifier = pipeline(
  task="text-classification", 
  model="textattack/distilbert-base-uncased-CoLA"
)

result = cola_classifier("The cat sat on the mat.")
print(result)
[{'label': 'LABEL_1', 'score': 0.9918296933174133}]
Natural Language Processing (NLP) en Python

Canal CoLA

from transformers import pipeline
cola_classifier = pipeline(
  task="text-classification", 
  model="textattack/distilbert-base-uncased-CoLA"
)
result = cola_classifier("The cat on sat mat the.")
print(result)
[{'label': 'LABEL_0', 'score': 0.9628171324729919}]
Natural Language Processing (NLP) en Python

Passons à la pratique !

Natural Language Processing (NLP) en Python

Preparing Video For Download...