시작하기무료로 시작하기

추출형을 넘어, 자연스러운 답 만들기: 추상적 QA

고객 지원 챗봇은 정확히 일치하는 문구를 그대로 보여 주는 대신, 도움이 되고 대화체에 가까운 답변을 제공해야 합니다. 이를 위해 문맥을 바탕으로 간결하고 유창한 응답을 생성하는 추상적 질문 응답(abstractive question answering)을 사용합니다. 이번 과제에서는 Hugging Face의 "text2text-generation" 파이프라인과 추상적 QA로 학습된 모델을 사용해, 제품 정보를 바탕으로 자연스러운 답변을 생성해 보세요.

이 연습은 강의의 일부입니다

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

강의 보기

연습 안내

  • "text2text-generation" 작업과 "fangyuan/hotpotqa_abstractive" 모델을 사용해 qa_pipeline을 생성하세요.
  • 제공된 contextquestion으로 추상적 answer를 생성하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

from transformers import pipeline

# Create the abstractive question-answering pipeline
qa_pipeline = pipeline(
    task="____",
    model="____"
)

context = """This smartphone features a 6.5-inch OLED display, 128GB of storage, and a 48MP camera with night mode. It supports 5G connectivity and has a battery life of up to 24 hours."""

question = "What is the size of the smartphone's display?"

# Generate abstractive answer
result = qa_pipeline(f"____: {____} ____: {____}")
print(result)
코드 편집 및 실행