टेक्स्ट क्लासिफिकेशन

Snowflake में Generative AI परिचय

James Cha-Earley

Senior Developer Advocate, Snowflake

टेक्स्ट को क्लासिफाई करने की चुनौतियाँ

समस्या

$$

  • रिव्यू में कुछ भी हो सकता है

$$

  • मैनुअल श्रेणीकरण धीमा और स्केलेबल नहीं है

समाधान

$$

  • Snowflake Cortex से ऑटोमेट करें!

$$

  • classify_text()
Snowflake में Generative AI परिचय

श्रेणियाँ परिभाषित करना

# Define categories
categories = ["overall_experience", "location", "staff", "food_beverages",
              "facilities"]
Snowflake में Generative AI परिचय

टेक्स्ट क्लासिफाई करना

from snowflake.cortex import classify_text

category = classify_text( str_input="The check-in was smooth and the staff were very friendly.", categories=categories )
print(category)
{  
  "label": "staff"  
}
Snowflake में Generative AI परिचय

आउटपुट को डिक्शनरी में बदलना

print(type(category))
<class 'str'>
import json

category_dict = json.loads(category)
print(type(category_dict))
<class 'dict'>
Snowflake में Generative AI परिचय

वर्कफ़्लो स्केल करना

  • दिए गए महीने के रिव्यू का क्लासिफिकेशन पाइपलाइन
# Python code
month = 5
-- SQL query
SELECT *
FROM HOTELS.REVIEWS
WHERE EXTRACT(month FROM date) = '{{month}}'
Snowflake में Generative AI परिचय

classify_text() लागू करना

df = cell2.to_pandas()

def classification(text): result = classify_text( str_input=text, categories=labels ) result_dict = json.loads(result) return result_dict["label"]
Snowflake में Generative AI परिचय

classify_text() लागू करना

# Apply classification to the DataFrame
df["category"] = reviews["DESCRIPTION"].apply(classification)

# Print the first row's predicted category print(df["category"].head(1))
0    overall_experience  
Name: category, dtype: object
Snowflake में Generative AI परिचय

सेंटिमेंट एनालिसिस

  • हमें सिर्फ रिव्यू के सेंटिमेंट चाहिए

SQL सेल में AI_SENTIMENT

Snowflake में Generative AI परिचय

सेंटिमेंट एनालिसिस

AI_SENTIMENT - सेंटिमेंट निकालना

$$

  • उपलब्ध सेंटिमेंट: positive, negative, neutral, mixed, और unknown
Snowflake में Generative AI परिचय

अभ्यास करते हैं!

Snowflake में Generative AI परिचय

Preparing Video For Download...