Схожість запитань і граматична коректність

Natural Language Processing (NLP) in Python

Fouad Trad

Machine Learning Engineer

Схожість запитань

  • Визначає, чи два запитання є перефразуваннями
  • Корисно для:
    • Дедуплікації
    • Кластеризації схожих запитань
    • Поліпшення точності пошуку
  • Виконується моделями, навченими на наборі Quora Question Pairs (QQP)

Зображення трьох людей, які ставлять запитання.

Natural Language Processing (NLP) in Python

Конвеєр 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) in Python

Конвеєр 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) in Python

Оцінювання граматичної коректності

  • Оцінює граматичну коректність тексту
  • Корисно для:

    • Освітніх інструментів
    • Граматичних перевірок
    • Помічників для письма
  • Виконується моделями, навченими на наборі Corpus of Linguistic Acceptability (CoLA)

Зображення людини, яка оцінює коректність написаного тексту.

Natural Language Processing (NLP) in Python

Конвеєр 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) in Python

Конвеєр 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) in Python

Давайте потренуємось!

Natural Language Processing (NLP) in Python

Preparing Video For Download...