Introduction to Snowflake Cortex and Notebooks

Introduction to Generative AI in Snowflake

James Cha-Earley

Senior Developer Advocate, Snowflake

Meet your instructor!

 

$$

James Cha-Earley

  • Senior Developer Advocate at Snowflake

 

Instructor photo

Introduction to Generative AI in Snowflake

Snowflake Cortex

Snowflake Cortex AI

  • Production-ready AI at our fingertips
1 Image source: https://www.snowflake.com/en/product/features/cortex/
Introduction to Generative AI in Snowflake

Cortex AI

$$

  • Native integration across SQL, Python, and notebooks

$$

  • Experiment to production within Snowflake

$$

  • Built-in governance, policies, and observability

Snowflake Logo Icon

Introduction to Generative AI in Snowflake

Course data

Query of course data showing first 10 rows - date, rating, description, hotel_name, city, country, and language

Introduction to Generative AI in Snowflake

Template code

Notebook with template Python and SQL code

Introduction to Generative AI in Snowflake

Querying the data

Description of course data detailing columns - date, rating, description, hotel_name, city, country, and language - and data types

Introduction to Generative AI in Snowflake

Python variable injection

  • Create a Python variable for substitution in a SQL query

Creating a Python variable called target_location, assigning a value of Cancun

Introduction to Generative AI in Snowflake

Python variable injection

Injecting a Python variable into a SQL query

Introduction to Generative AI in Snowflake

Setting up Cortex

Setting up Cortex

Introduction to Generative AI in Snowflake

Summarizing text

from snowflake.cortex import summarize

review = """ I was very impressed with this hotel, especially the service. They make you feel special and you feel like everything is possible. Special shout out to the Kidz Club staff. Our daughter is very picky and for the first time, she begged to go back there. They have a great supervision and they let the kids do fun activities such as cooking classes and crafting. The food was really good (buffet offered a different choice everyday). The all-inclusive program is really worth the price, and the beach was beautiful! """
Introduction to Generative AI in Snowflake

Summarizing text

result = summarize(text=review)

print(result)

$$

The hotel delivered excellent service with outstanding Kidz Club staff who engaged 
even picky children through supervised activities. The daily buffet offered good
variety, and the all-inclusive program plus beautiful beach provided great value.
Introduction to Generative AI in Snowflake

Cortex in SQL cells

Running summarize in the SQL cell

$$

  • No imports needed when run in SQL cells

$$

  • Use Python cells for chaining multiple functions
Introduction to Generative AI in Snowflake

Let's practice!

Introduction to Generative AI in Snowflake

Preparing Video For Download...