Introduction to AI Functions and AI_COMPLETE
1. Introduction to AI Functions and AI_COMPLETE
Welcome back! In the next couple of videos, we are going to learn about what LLM-based AI functions are before we get to using them in our notebooks. It's always good to understand the tools before we use them. Let's start! Large language models are very powerful tools, and they can accomplish many tasks. These tools can be further specialized from their foundational form through the process of fine-tuning, which we will discuss later in this course. However, at their core, LLMs are just models. They don't do anything on their own. We create value and gain insights by invoking the LLM to generate response. This is where Snowflake Cortex comes in. Snowflake Cortex allows you to access some of the most capable enterprise-grade models such as Llama, Mistral, Reka, Claude, and families of other models. LLM-based AI functions are easy-to-use building blocks for GenAI apps where the functions can be called to enable actions within the Snowflake environment. There are three types of LLM functions, the AI_COMPLETE function, a set of task-specific functions, and some helper functions. Let's envision a situation where you would use these AI functions. Imagine that you're coming into work on a Monday and have thousands of customer feedback reports. Your task as a data scientist is to analyze the customer sentiments from the feedback. Now it's Tuesday and you have millions of customer service requests that are received in different languages. You want to automate the analysis of the service requests in a way that simple low-severity requests are sent to a chatbot to respond. More complex high-severity issues are sent to a customer support team to be handled. Wednesday comes and you have millions of PDFs that you need to extract data from. Busy week, I know, but that is exactly where Snowflake AI functions can help. Let's dive in so you can see how easy using these functions can be. Like many operations in Snowflake, you can easily invoke Snowflake AI functions using either SQL or Python. When using SQL, you interact directly with Cortex functions via standard query syntax, which is well-suited for high-volume batch processing workloads. When using Python, the Snowflake SDK provides an interface to execute these functions within your code which simplifies development and integration into your application logic, but ultimately relies on the same underlying SQL-based execution engine, ensuring that your AI workflows benefit from Snowflake's consistent security, governance, and performance. Over the next few videos, we're going to look at all three types of functions, and we'll discuss the relevant role-based access controls. Before we see these functions in action, let's set up our Snowflake environment and download the necessary Snowflake notebooks. This is the time to pause the video and log into your Snowflake account if you haven't already. Once you're logged into the Snowflake account, navigate to the companion Git repo for this course. You can find the link to the repo in the reading section prior to this video. In the Git repo under Module 2, you'll find two Python notebooks. Download both notebooks. Now switch to your Snowflake account. Navigate to Projects on the left panel. Select Workspaces. In the top left, click on the Add New button. Select Upload Files and upload the intro to LLM Functions notebook. Select Ski Gear Support Database and Ski Gear Support Schema for the notebook location. Next, let's load the Using LLM Functions notebook following the same steps. Import the Python notebook file through the Add New button. Fantastic! Now we have everything we need to run through the rest of the module. Click on the notebook titled Intro to LLM Functions and click Connect button on the top to start the notebook session. This will take a few minutes. Now, we import the active Snowpark session. Then set the context for the rest of the notebook cells to use the Ski Gear Support DB in the Ski Gear Support Schema. Let's start by looking at AI_COMPLETE. Snowflake's AI_COMPLETE function returns the completion from one of the supported models given a prompt and the options that we pass to it. We use Llama 3.1 70 billion parameter model on this function with the sample question to invoke complete. The results are great, but before we get too far ahead of ourselves, let's talk about all the different LLMs available on the Snowflake environment. AI_COMPLETE in Snowflake can use a variety of pre-trained models of different sizes which are tailored to meet diverse business needs. These models range from single digit billions of parameters to large models such as Mistral Large, Llama 3.1, the 405 billion parameter model, and Anthropic's Claude Sonnet 4.6. The larger ones can be more accurate for more complex tasks, often come with larger context windows, and are great for content generation and answering questions with large sets of context. Alternatively, the smaller ones typically offer faster speeds, lower inference costs, which is great for time-sensitive tasks such as external-facing chat apps or constrained simpler tasks like LLM routing. These models are constantly updating, so always check the Snowflake documentation for the latest models. These models are pretty impressive. Nice work. Next, we'll learn about the other half of the AI function family, task-specific functions, as well as helper function. Bye-bye complete. We'll see you later when we put you to use. Hello, translation, sentiment analysis, summarization, and text classification, and hello, helper functions. We didn't forget you. See you soon.2. Let's practice!
Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.