Пошук відповідей

Natural Language Processing (NLP) in Python

Fouad Trad

Machine Learning Engineer

Екстрактивне QA

  • Відповідь напряму скопійована з уривка

  Зображення з контекстом «The library closes at 6 PM on weekdays»

Зображення з екстрактивною відповіддю: «6 PM»

Абстрактивне QA

  • Модель генерує природну відповідь

  Зображення з питанням: «When does the library close on weekdays?»

Зображення з абстрактивною відповіддю: «Closure is at 6 PM»

Natural Language Processing (NLP) in Python

Екстрактивне QA

  • Корисне для:
    • Пошукових систем
    • Систем пошуку документів
    • Додатків для розуміння прочитаного
  • Точніше, менш схильне до помилок

extractive_photo.png

Абстрактивне QA

  • Корисне для:
    • Розмовних агентів
    • Віртуальних помічників
    • Чат-ботів підтримки клієнтів
  • Може спричиняти помилки

abstractive_image.png

Natural Language Processing (NLP) in Python

Екстрактивне QA

from transformers import pipeline

qa_pipeline = pipeline(task="question-answering", model="distilbert/distilbert-base-cased-distilled-squad")
context = """The Amazon rainforest is the largest tropical rainforest in the world, covering parts of Brazil, Peru, and Colombia."""
question = "Which countries does the Amazon rainforest cover?"
qa_answer = qa_pipeline(question=question, context=context) print(qa_answer)
{'score': 0.9242347478866577,

'start': 90, 'end': 116,
'answer': 'Brazil, Peru, and Colombia'}
Natural Language Processing (NLP) in Python

Абстрактивне QA

from transformers import pipeline
qa_pipeline = pipeline(task="text2text-generation",
                       model="fangyuan/hotpotqa_abstractive")

context = """The Amazon rainforest is the largest tropical rainforest in the world, covering parts of Brazil, Peru, and Colombia.""" question = "Which countries does the Amazon rainforest cover?"
input_text = f"question: {question} context: {context}"
result = qa_pipeline(input_text)
print(result)
[{'generated_text': 'The Amazon rainforest covers parts of Brazil, Peru, and Colombia.'}]
Natural Language Processing (NLP) in Python

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

Natural Language Processing (NLP) in Python

Preparing Video For Download...