Introducción a la IA Generativa en Snowflake
James Cha-Earley
Senior Developer Advocate, Snowflake
$$
$$
$$
$$
classify_text()# Definir categorías
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'>
# Código Python
month = 5
-- Consulta 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"]
# Aplica clasificación al DataFrame df["category"] = reviews["DESCRIPTION"].apply(classification)# Imprime la categoría predicha de la primera fila print(df["category"].head(1))
0 overall_experience
Name: category, dtype: object


$$
positive, negative, neutral, mixed, y unknownIntroducción a la IA Generativa en Snowflake