Einführung in Generative KI in Snowflake
James Cha-Earley
Senior Developer Advocate, Snowflake
$$
$$
$$
$$
classify_text()# Kategorien definieren
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'>
# Python-Code
month = 5
-- SQL-Abfrage
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"]
# Klassifikation auf DataFrame anwenden df["category"] = reviews["DESCRIPTION"].apply(classification)# Erste Zeile der vorhergesagten Kategorie ausgeben print(df["category"].head(1))
0 overall_experience
Name: category, dtype: object


$$
positive, negative, neutral, mixed und unknownEinführung in Generative KI in Snowflake