回答抽出

Snowflake による Generative AI 入門

James Cha-Earley

Senior Developer Advocate, Snowflake

回答抽出を使う理由

$$

  • 苦情の特定
  • アメニティに関する意見抽出
  • 長文からの質問応答

各レビュー内容が不明で、笑顔や悲しい顔の絵文字に囲まれた疑問符付きの文書

Snowflake による Generative AI 入門

一般的なビジネス課題

review = """
The property needs updating and management needs to hire more staff. 
The staff does everything they can but it is not enough for the number of guests. 
The rooms look old as well as everything in the bathrooms. 
Definitely better options in the hotel zone.
"""
  • Snowflake Cortex が解決します
Snowflake による Generative AI 入門

回答の抽出

from snowflake.cortex import extract_answer

response = extract_answer( from_text=review, question="What did the guest complain about?" )
Snowflake による Generative AI 入門

出力

print(response)
[
    {
    "answer": "Management needs to hire more staff.",
    "score": 0.8013839254
    }
]
  • スコアは 0〜1
Snowflake による Generative AI 入門

ワークフローの構築

SELECT DESCRIPTION
FROM HOTELS.REVIEWS
WHERE RATING < 6
    AND DATE = '2023-08-23';
Snowflake による Generative AI 入門

SQL の出力

I will never book a vacation through Expedia not only did I pay over 5;000 dollars
but they false advertise the resort; in my reservation It clearly stated that
breakfast and dinner was included. When I got to the resort they informed me that 
these issues have happed before with Expedia because the resort does not offer an
all exclusive. After flighting practically all day I called Expedia and they had me
on hold for 45min and nothing got resolved. I ended up spending over 1000.00 more
just on food. I am beyond me they are not only false advertising but refused to
take any responsibility on their part for the issues they caused me and my family.  Again I will never chose Expedia to plan a vacation!!!
Snowflake による Generative AI 入門

質問する

negative_review = cell1.to_pandas()['DESCRIPTION'].iloc[0]

response = extract_answer( from_text=negative_review, question="What was the primary issue that the guest mentioned?" ) print(response)
Snowflake による Generative AI 入門

応答の確認

[
    {
    "answer" : "Expedia falsely advertised that meals were included, but the
                resort did not offer an all-inclusive package.",
    "score": 0.75829312442
    }
]
Snowflake による Generative AI 入門

制約事項

$$

  • 部分的・曖昧な語句になることがある
  • 複数テーマ文書より段落で有効
  • 重要な出力は必ず確認

注意標識

Snowflake による Generative AI 入門

演習に進みましょう!

Snowflake による Generative AI 入門

Preparing Video For Download...