Introduction to LLM Functions and Cortex COMPLETE
1. Introduction to LLM Functions and Cortex COMPLETE
Welcome back. In the next couple of videos, we are going to learn about what LLM functions are before we get into using them in our notebooks. It is always good to understand the tools before we use them. Let's start. Large language models are very powerful tools that can accomplish many tasks. These tools can be further specialized from their foundational form through the process of fine tuning, which we will discuss in the next module. However, LLMs are just models. They do not do anything on their own. We create value and gain insight by invoking the LLM to generate a response. This is where the Snowflake Cortex comes in. Snowflake Cortex allows you to access some of the most capable enterprise-grade models, such as the Llama, Mistral, Reka, and Claude family of models. LLM functions are easy to use building blocks for Gen AI apps, where the functions can be called to enable actions within the Snowflake environment. There are three types of LLM functions, the complete function, a set of task-specific functions, and some helper functions. Let's envision a situation where you would use LLM functions. Imagine that it is Monday and you have thousands of customer feedback reports, and your task as a data scientist is to analyze the customer sentiments from the feedback. It's Tuesday, and you have millions of customer service requests that are received in different languages. You want to automate the analysis of service requests in a way that simple, low-severity requests are sent to the chatbot to respond. More complex, high-severity issues are sent to the customer support team to be handled. It's Wednesday, and you have millions of PDFs that you need to extract data from. Busy week, I know. This is where Cortex LLM functions can help. Let's dive in so you can see how easy using these functions can be. Like many operations in Snowflake, LLM functions can be called both in SQL and Python. It is worth noting that when called in SQL, the functions reach Cortex endpoint that is optimized for batch processing, as it may require some warmup time. When Cortex LLMs are called in Python, on the other hand, they will hit an endpoint specifically optimized for low latency. In this video and the next, we are going to look at all three types of functions, and we'll also discuss the relevant role-based access controls. Before we see these functions in action, let us 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 Snowflake account, navigate to the companion Git repo for this course. You can find the link to the Git repo in the reading section prior to this video. In the Git repo, under module two, you will find two IPython notebooks. Download both the notebooks. Now, switch to your Snowflake account, navigate to projects on the left panel, select notebooks, move to the top right and click on the down arrow. Select import IPython notebook file and upload intro to LLM functions notebook. Select SkiGear support database and SkiGear support schema for the notebook location and compute warehouse for the warehouse. Next, let's load the using LLM functions notebook following the same steps. Import the IPython notebook file, select the notebook in your local and select the SkiGear support DB and SkiGear support schema for notebook location, compute warehouse for the warehouse. Fantastic. Now we have everything we need to run through the rest of this module. Click on the notebook titled intro to LLM functions and select the start button at the top to start the notebook session. It takes a couple of seconds. Click on packages at the top right and search for Snowflake package to install. It takes a couple of seconds as well. We also need another package. Look for Snowflake ML Python and install that as well. First, we import the active Snowpark session and then set the context for the rest of the notebook cells to use the SkiGear support DB and SkiGear support schema. Let's start by looking at complete. Snowflake Cortex complete 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 405 million parameter model on this function with a 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 in the Snowflake environment. Cortex 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 the single digit billions of parameters to larger models such as Mistral Large, LLAMA 3.1, the 405 billion parameter model and Anthropic Claude 3.5 Sonnet. The larger ones can be more accurate for more complex tasks and 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 and lower inference cost, which is great for time sensitive tasks such as external facing chat apps or constrained simpler tasks like LLM routing. Pretty impressive. Nice work. Next, we will learn about the second half of the LLM function family, task specific and helper functions. Bye bye, complete. We will see you later when we put you to use. Hello, translation, sentiment analysis, summarization and 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.