Extração de respostas

Introdução à IA Generativa no Snowflake

James Cha-Earley

Senior Developer Advocate, Snowflake

Por que usar extração de respostas?

$$

  • Identificar reclamações
  • Extrair feedback sobre comodidades
  • Responder a perguntas em documentos longos

Um documento com um ponto de interrogação cercado por emojis felizes e tristes, indicando que não sabemos do que trata cada avaliação

Introdução à IA Generativa no Snowflake

Um problema comum de negócio

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 para ajudar!
Introdução à IA Generativa no Snowflake

Extraindo uma resposta

from snowflake.cortex import extract_answer

response = extract_answer( from_text=review, question="What did the guest complain about?" )
Introdução à IA Generativa no Snowflake

Saída

print(response)
[
    {
    "answer": "Management needs to hire more staff.",
    "score": 0.8013839254
    }
]
  • Escores de 0 a 1
Introdução à IA Generativa no Snowflake

Criando um fluxo de trabalho

SELECT DESCRIPTION
FROM HOTELS.REVIEWS
WHERE RATING < 6
    AND DATE = '2023-08-23';
Introdução à IA Generativa no Snowflake

Saída do 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!!!
Introdução à IA Generativa no Snowflake

Fazendo uma pergunta

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)
Introdução à IA Generativa no Snowflake

Revisando a resposta

[
    {
    "answer" : "Expedia divulgou falsamente que as refeições estavam incluídas, mas o
                resort não oferecia pacote all-inclusive.",
    "score": 0.75829312442
    }
]
Introdução à IA Generativa no Snowflake

Limitações

$$

  • Pode retornar frases parciais ou vagas
  • Melhor em parágrafos, não em documentos com vários temas
  • Sempre revise saídas críticas

Sinal de cautela

Introdução à IA Generativa no Snowflake

Vamos praticar!

Introdução à IA Generativa no Snowflake

Preparing Video For Download...