Извлечение ответов

Введение в генеративный ИИ в Snowflake

James Cha-Earley

Senior Developer Advocate, Snowflake

Зачем использовать извлечение ответов?

$$

  • Определение жалоб
  • Извлечение отзывов об удобствах
  • Ответы на вопросы по длинным документам

Документ со знаком вопроса, окружённый эмодзи с улыбающимися и грустными лицами: мы не знаем, о чём каждый отзыв

Введение в генеративный ИИ в Snowflake

Распространённая бизнес-проблема

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

Извлечение ответа

from snowflake.cortex import extract_answer

response = extract_answer( from_text=review, question="What did the guest complain about?" )
Введение в генеративный ИИ в Snowflake

Вывод

print(response)
[
    {
    "answer": "Management needs to hire more staff.",
    "score": 0.8013839254
    }
]
  • Оценки в диапазоне от 0 до 1
Введение в генеративный ИИ в Snowflake

Построение рабочего процесса

SELECT DESCRIPTION
FROM HOTELS.REVIEWS
WHERE RATING < 6
    AND DATE = '2023-08-23';
Введение в генеративный ИИ в Snowflake

Вывод 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

Постановка вопроса

negative_review = dataframe_1.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

Анализ ответа

[
    {
    "answer" : "Expedia falsely advertised that meals were included, but the
                resort did not offer an all-inclusive package.",
    "score": 0.75829312442
    }
]
Введение в генеративный ИИ в Snowflake

Ограничения

$$

  • Может возвращать неполные или расплывчатые формулировки
  • Лучше работает с абзацами, а не с многотемными документами
  • Всегда проверяйте важные результаты

Предупреждающий знак

Введение в генеративный ИИ в Snowflake

Давайте потренируемся!

Введение в генеративный ИИ в Snowflake

Preparing Video For Download...