Hỏi đáp (QA)

Natural Language Processing (NLP) bằng Python

Fouad Trad

Machine Learning Engineer

QA trích xuất

  • Câu trả lời được chép nguyên từ đoạn văn

  Hình ảnh hiển thị ngữ cảnh "Thư viện đóng cửa lúc 6 giờ tối các ngày trong tuần"

Hình ảnh hiển thị câu trả lời trích xuất: "6 giờ tối"

QA tóm lược

  • Mô hình tạo câu trả lời tự nhiên

  Hình ảnh hiển thị câu hỏi: "Thư viện đóng cửa lúc mấy giờ vào các ngày trong tuần?"

Hình ảnh hiển thị câu trả lời tóm lược: "Đóng cửa lúc 6 giờ tối"

Natural Language Processing (NLP) bằng Python

QA trích xuất

  • Hữu ích trong:
    • Công cụ tìm kiếm
    • Hệ thống truy xuất tài liệu
    • Ứng dụng đọc hiểu
  • Chính xác hơn, ít lỗi hơn

extractive_photo.png

QA tóm lược

  • Hữu ích trong:
    • Tác nhân hội thoại
    • Trợ lý ảo
    • Bot hỗ trợ khách hàng
  • Có thể gây lỗi

abstractive_image.png

Natural Language Processing (NLP) bằng Python

QA trích xuất

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) bằng Python

QA tóm lược

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) bằng Python

Hãy luyện tập!

Natural Language Processing (NLP) bằng Python

Preparing Video For Download...