Get startedGet started for free

Additional Cortex AI Functions: Overview

1. Additional Cortex AI Functions: Overview

By now you've been working with Cortex AI functions for a few lessons. You're getting comfortable with AI_COMPLETE, AI_SENTIMENT, AI_CLASSIFY, AI_TRANSLATE, AI_EXTRACT, and AI_COUNT_TOKENS. You should know how to call them, you can estimate roughly what they cost, and you've gotten your hands on with some fictional data. In this lesson, we'll discuss the broader family those functions belong to and learn a few additional ones. These will open up workflows that would have been genuinely difficult to build without them, so let's dive in and unleash this new power. There are six functions we'll cover in this lesson. I'll give you a quick description of each, and in the next lesson, we'll do a hands-on demo that will go deeper on the most useful ones. Our first function is AI_TRANSCRIBE, which converts audio or video files into text. This is a fantastic function to use when using text analytics to look for insights in customer service calls or when you want to summarize your latest meeting for co-workers who couldn't attend. Your source files live in Snowflake Stage, which is the same internal or external storage location you use for file-based workflows. You point AI_TRANSCRIBE at the file and it returns a transcript. You can specify a language or let the model detect it automatically if it is one of the supported languages. You can find the latest supported languages in the Snowflake documentation. This is especially useful if your organization records calls, meetings, or customer interactions and stores them in cloud storage. You can load those files directly into Stage, transcribe them in bulk with a single query, and then run all the other Cortex AI functions on a resulting text. The pipeline from audio to structured insights stays entirely in your Snowflake workspace. The next function is AI_PARSE_DOCUMENT, which extracts structured content from unstructured documents like PDFs, images of documents, or scanned forms. You'll find this function especially useful if you're trying to extract pieces of data from forms automatically. Instead of manually transferring data from each field in your form, the Parse Document function handles the data gathering for you. Think of a landlord working with a new tenant. Tenants fill out the application in the leasing office. The landlord scans it to his computer, and the Parse Document function takes all the info and prepares it for storage in a database. Again, the source file sits in a stage. You pass the file reference to AI_PARSE_DOCUMENT, and it returns content as structured data. You can also use Parse Document optional arguments to specify the mode to use, whether it's OCR or layout, or whether or not to extract images. This function is useful for documents like invoices, contracts, medical forms, shipping documents, and any other documents where text is laid out in a non-strictly paragraph-based format. In short, use AI_PARSE_DOCUMENT in any situation where you have semi-structured or unstructured documents and need to get structured data out of them. For your top-secret work, our next function, AI_REDACT, removes sensitive information from the text. When you're on a top-secret spy mission or working at the front desk at a medical office, it is critical you keep certain pieces of information private so you adhere to HIPAA or international spy code, and Redact function does just that. You pass it a text column and tell it what to redact, names, phone numbers, email addresses, credit card numbers, and so on. It finds those patterns in text and replaces them with a placeholder based on the redacted object type. Names will be replaced by the word name in square brackets, addresses by the word address in square brackets, and so on. This is useful for data sharing, compliance workflows, or any situation you want to run analysis on customer data but want to strip PII before data moves to a less secure context. It runs on the text that's already in a column, so it works naturally with call transcripts, email bodies, support notes, or whatever other text you have to feed into it. Our fourth function, AI_FILTER, is a function that filters rows using natural language conditions. You may use this to create specific filters to drill into your data. Think beyond dissatisfied customer into a specific case of the customer is unhappy that their delivery took too long. This second case is hardly even possible with regular filtering because the reason for unhappiness may be not standardized in your data tables. How does AI_FILTER function differ technically from a regular filter though? Well, you know how a standard SQL WHERE clause filters based on exact column values? AI_FILTER does the same thing but with a natural language description of what you're looking for. You can use something like the customer express frustration or the call involves product defects. and AI_FILTER will evaluate each row against the condition and return a boolean, which you can use in a WHERE clause or as your column to filter your results on. This lets you do qualitative filtering that would have been nearly impossible with traditional SQL. You can't write a WHERE clause that detects frustration, but you can write this with AI_FILTER by saying WHERE AI_FILTER and the passing in the transcript and the filter condition. The customer expressed frustration. The last two new functions are AI_AGG and AI_SUMMARIZE_AGG. These are aggregated functions, meaning they operate across multiple rows, the way that LISTAGG does, but with natural language query being the basis of aggregation rather than a raw query string concatenation. Now, let's build on these basic descriptions and learn how these functions are designed to work together. Each one does a focused job, but they chain naturally in SQL and the composability is the real value. Let's take a look at the conceptual example. Say you have a table of call transcripts and want to know what the issues are driving customer frustration. You could write something like this. The innermost WHERE clause uses AI_FILTER to keep only the relevant calls. The SELECT inside the subquery uses AI_EXTRACT to pull structured fields and AI_CLASSIFY to tag each call. The outer query uses AI_AGG to summarize across the filtered tag set. No Python, no orchestration code, no chunking logic, one SQL query. That's the design philosophy behind the function family. You're building a pipeline, but you're building it in the same way that you write any other analytic SQL. The functions compose. The following lesson will walk through the most commonly used of these functions with actual queries against our Ski Gear call transcript dataset. You'll see AI_FILTER and AI_AGG do real work, see AI_REDACT strip PII from transcript text, and see how a composed pipeline comes together in a short query chain. For now, keep the composability pattern in mind. It's what makes these functions more than just a list of capabilities. Let's recap. There were six new functions in this lesson. AI_TRANSCRIBE to get text from audio and video files. AI_PARSE_DOCUMENT to get text from scanned documents or tables. AI_REDACT to redact sensitive information. AI_FILTER to filter on natural language queries. And AI_AGG and AI_SUMMARIZE_AGG to summarize sets of text with or without specific instructions, respectively. These functions are designed to compose so you chain them in a SQL the same way that you chain any other analytic logic. Now let's get a Snowflake notebook open and see them in action. See you in the next lesson.

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.