
Using Snowflake Cortex & Omni together
Transcript
This transcript is auto-generated. Names and product terms may be wrong.
Hello everyone. My name is Peter and I'm a solutions engineer here at Omni. And today I'm going to show you how you can integrate Snowflake Cortex and Omni giving your users AI powered insights into their Snowflake data data. With Omni and Cortex, we're going to be able to enrich and augment our existing data by giving your users more information provided by AI.
We're also going to be able to ask chat GBT style questions of the data getting more insights into the underlying data from AI generated answers. We're also going to be able to summarize our data with AI generated uh summarizations on trends or even questions for our next analysis. Then finally, we'll touch on a few taskbased um functions where we can look at sentiment analysis and categorization as well.
So what is cortex AI? So Snowflake's cortex allows users to have inst in instant access to large language models that are going to be hosted and managed by Snowflake. It requires no setup from the end users and is really going to allow them to leverage that performance and scalability that we all know and love with Snowflake. How we can interact with Cortex in Omni is through um some SQL functions.
Here we are going to be using mostly the Snowfllex Cortex complete function. This is a general purpose function that can perform a wide range of user specific tasks. We're also going to touch on a couple of these taskbased functions like this sentiment analysis where we can get a users or public sentiment on um some input text as well as we're going to look at uh classification uh function as well.
So let's jump right into this NBA enrichment dashboard here. Now I've created this dashboard to learn a little bit more about my favorite NBA players. I have some NBA statistics in my underlying data warehouse. So, I can look at, you know, this NBA player Kevin Durant. I can see his, you know, offensive and defensive stats over his uh career.
Um, but, you know, I might want to know more about this player. And this is where Snowflake Cortex is going to come in. I can dynamically pass in a player's name to that Cortex complete function and ask them with a prompt to say, "Hey, can you give me a biography on Kevin Durant?" That's going to generate this AI response right here, as well as this complete function where I'm asking for a list of awards from his career.
We can also show how we can dynamically switch between different players. So, if I wanted to look at one of Kevin Durant's former teammates, Stephen Curry, I can add that into the filter and then that's going to give me all of that snowflake data that I have in my warehouse, plus the AI generated responses as well from that cortex function.
Now how we're doing this underneath the hood is um we're setting these snowflake cortex complete functions in the SQL statement of our dimensions here. Now within the complete function we are going to define which LLM model we're going to use. I am using just the snowflake arctic uh default model. You can also set whichever you know model train model you want that's going to be tailor fit for your job.
You know we're thinking um llama's model. We're thinking um Claude 3, all of those good stuff. So our fair game, we're then going to pass in our prompt here and then I'm going to dynamically pass in that filtered value for the player name. And we're doing this with our mustache syntax. Now the other type of models you can use are going to be you know some taskbased model like this classification model classified text where these are actually trained specifically on you know efficient models snowflake has for these specific tasks here to classify this text.
We're going to pass in our player name and then we're going to define if he is an all-time great superstar allstar or world player. Other taskbased models you can use are something like a sentiment analysis. Here you can see we're passing in a player's name to to get a sentiment. This truly is not going to be that great because it's just a player's name we're trying to use.
Probably want to pass in, you know, um larger um textbased um columns, something like maybe a collection of game summaries that journalists are putting together on how the game went for specific players. So, let's see how we can use this um taskbased uh function here. So, let's go over to our workbook. I'm going to edit this and then add a brand new um tab.
Let's grab our NBA players topic. Let's grab our player name. Maybe let's sort on uh points per game. Perfect. And then let's grab that classification. So here you can see we get our results. We're going to have Kevin Durant as a superstar. He's probably leaning more towards an all-time great. LeBron, Michael Jordan, of course, all-time greats. So really what we've seen here is how we can leverage um Snowflake's um general purpose functions like complete and task based functions like classification or classify text to you know enrich this data and provide some insights into the data that we have in our warehouse with data that might not actually exist in our warehouse.
So now let's go over to use case we have here where I'm going to be looking at an account lookup dashboard. So, say I am a new account rep at a company based here locally in Portland where I'm from. Um, and I want to learn some about the about the locally based companies and how our company interacts with them.
So, here we have some Salesforce historical data on our contact with Nike here local to Portland. But what I can do is actually pass in Nike and a few chat GBT style questions for me to learn more about this company as the new sales rep uh representing this company. So here I might want to learn about some of the most recent news from this company.
Here we're going to pass that value into that chat GB or that Snowflake complete function and get some some recent news on Nike. I can also, you know, add some free form text here like who is the company's CEO and then pass that into there. that's going to then also pass that within that snowflake cortex complete function to return those results for that Nike CEO as well.
Now, another way we can interact with the data is through summarization. Um, here we have a dashboard where we're going to be able to look at orders history where we have total revenue and order count. Right now we're looking at daily data in the past seven days. Say I was a VP of sales and I wanted to look at maybe the holiday period and how we uh performed over that holiday period.
So let's get into weekly data and then I'm going to look at the past um complete month which was December. Um so let's look at that. We can update that. And that's also going to update this summary over here where we're going to be passing in this result set to learn how we did from a trend perspective on the holiday seasons of 2024.
And then we're also going to ask um Cortex to provide us with a couple key questions that we can start asking of the data based on this result set here. Now, how we did this is what we've done is basically just templatized and passed this SQL query that we have for this tile on the dashboard over to a SQLbased tile where we're going to use that and create it as a CTE here.
And then we're going to pass it in as a JSON and object construct right here into our Snowflake Cortex complete function where I'm going to give it a prompt of very specifically around I'm a VP of sales. give me a highle overview and how we're trending in sales and orders, but then also three follow-up questions of the data as well.
In conclusion, we've seen how AMI can interact with Cortex directly in our application through enriching your data, providing chat GP chat GPT style questions that you're going to ask for the data, but also thinking about how we can summarize the data that is present on our dashboard as well. If you want to learn more about how you can interact with Cortex and Omni, please reach out to us.