질문 응답

Python으로 배우는 Natural Language Processing (NLP)

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"

Python으로 배우는 Natural Language Processing (NLP)

추출형 QA

  • 활용 사례:
    • 검색 엔진
    • 문서 검색 시스템
    • 독해 앱
  • 더 정확하고 오류가 적음

extractive_photo.png

생성형 QA

  • 활용 사례:
    • 대화형 에이전트
    • 가상 비서
    • 고객 지원 봇
  • 오류가 발생할 수 있음

abstractive_image.png

Python으로 배우는 Natural Language Processing (NLP)

추출형 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'}
Python으로 배우는 Natural Language Processing (NLP)

생성형 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.'}]
Python으로 배우는 Natural Language Processing (NLP)

연습해 봅시다!

Python으로 배우는 Natural Language Processing (NLP)

Preparing Video For Download...