Extraction de réponses

Introduction à l’IA générative dans Snowflake

James Cha-Earley

Senior Developer Advocate, Snowflake

Pourquoi utiliser l'extraction de réponses ?

$$

  • Identifier les plaintes
  • Extraire les retours sur les commodités
  • Répondre aux questions de longs documents

Un document avec un point d'interrogation entouré d'émojis souriants ou tristes, représentant que nous ne savons pas de quoi parle chaque avis

Introduction à l’IA générative dans Snowflake

Un problème commercial courant

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 à la rescousse !
Introduction à l’IA générative dans Snowflake

Extraire une réponse

from snowflake.cortex import extract_answer

response = extract_answer( from_text=review, question="What did the guest complain about?" )
Introduction à l’IA générative dans Snowflake

Sortie

print(response)
[
    {
    "answer": "La direction doit embaucher plus de personnel.",
    "score": 0.8013839254
    }
]
  • Scores allant de 0 à 1
Introduction à l’IA générative dans Snowflake

Créer un flux de travail

SELECT DESCRIPTION
FROM HOTELS.REVIEWS
WHERE RATING < 6
    AND DATE = '2023-08-23';
Introduction à l’IA générative dans Snowflake

Sortie 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!!!
Introduction à l’IA générative dans Snowflake

Poser une question

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)
Introduction à l’IA générative dans Snowflake

Réviser la réponse

[
    {
    "answer" : "Expedia a faussement annoncé que les repas étaient inclus, mais le
                complexe n'offrait pas de formule tout compris.",
    "score": 0.75829312442
    }
]
Introduction à l’IA générative dans Snowflake

Limitations

$$

  • Peut retourner des phrases partielles ou vagues
  • À utiliser de préférence sur des paragraphes, pas des documents multi-sujets
  • Toujours vérifier les résultats critiques

Panneau de précaution

Introduction à l’IA générative dans Snowflake

Passons à la pratique !

Introduction à l’IA générative dans Snowflake

Preparing Video For Download...