การตอบคำถาม

การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python

Fouad Trad

Machine Learning Engineer

Extractive QA

  • คำตอบคัดลอกมาจากข้อความโดยตรง

  รูปภาพแสดงบริบท "The library closes at 6 PM on weekdays"

รูปภาพแสดงคำตอบแบบ Extractive: "6 PM"

Abstractive QA

  • โมเดลสร้างคำตอบที่ฟังดูเป็นธรรมชาติ

  รูปภาพแสดงคำถาม: "When does the library close on weekdays?"

รูปภาพแสดงคำตอบแบบ Abstractive: "Closure is at 6 PM"

การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python

Extractive QA

  • เหมาะสำหรับ:
    • เครื่องมือค้นหา
    • ระบบดึงข้อมูลจากเอกสาร
    • แอปทดสอบความเข้าใจในการอ่าน
  • แม่นยำสูง โอกาสเกิดข้อผิดพลาดน้อย

extractive_photo.png

Abstractive QA

  • เหมาะสำหรับ:
    • Conversational agent
    • ผู้ช่วยเสมือน
    • บอตสนับสนุนลูกค้า
  • อาจเกิดข้อผิดพลาดได้

abstractive_image.png

การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python

Extractive 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'}
การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python

Abstractive 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.'}]
การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python

มาฝึกกันเถอะ!

การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python

Preparing Video For Download...