始める無料で始める

商品説明から質問に答える

あるオンライン小売業者は、商品説明をもとに、よくある質問に自動で回答してカスタマーサポートを改善したいと考えています。あなたの課題は、Hugging Face のパイプラインを使って、顧客からの問い合わせに対し、商品説明から正確な回答を抽出することです。

この演習はコースの一部です

Pythonで学ぶ自然言語処理(NLP)

コースを見る

演習の手順

  • 質問応答のために、"distilbert/distilbert-base-cased-distilled-squad" モデルを使って qa_pipeline を作成します。
  • 提供された context(商品説明)と question を使って、回答を取得します。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

from transformers import pipeline

# Create the 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?"

# Get the answer
result = ____
print(result)
コードを編集して実行