Introduction à l’IA générative dans Snowflake
James Cha-Earley
Senior Developer Advocate, Snowflake
$$
$$
$$
$$
classify_text()# Définir les catégories
categories = ["overall_experience", "location", "staff", "food_beverages",
"facilities"]
from snowflake.cortex import classify_textcategory = classify_text( str_input="The check-in was smooth and the staff were very friendly.", categories=categories )print(category)
{
"label": "staff"
}
print(type(category))
<class 'str'>
import json
category_dict = json.loads(category)
print(type(category_dict))
<class 'dict'>
# Code Python
month = 5
-- Requête SQL
SELECT *
FROM HOTELS.REVIEWS
WHERE EXTRACT(month FROM date) = '{{month}}'
df = cell2.to_pandas()def classification(text): result = classify_text( str_input=text, categories=labels ) result_dict = json.loads(result) return result_dict["label"]
# Appliquer la classification au DataFrame df["category"] = reviews["DESCRIPTION"].apply(classification)# Imprimer la catégorie prédite de la première ligne print(df["category"].head(1))
0 overall_experience
Name: category, dtype: object


$$
positive, negative, neutral, mixed, et unknownIntroduction à l’IA générative dans Snowflake