AI_AGG
functiondeferredAI & MLReduces a column of text data using a natural language instruction. For example, AI_AGG(reviews, 'Describe the most common complaints mentioned in the book reviews') will return a summary of user feedback. Unlike COMPLETE (SNOWFLAKE.CORTEX) and AI_SUMMARIZE, this function supports datasets larger than the maximum language model context window. See also: AI_SUMMARIZE_AGG
Syntax
AI_AGG( <expr>, <instruction> )
Parameters
| Name | Required | Description |
|---|---|---|
expr | required | This is an expression that contains text on which an aggregation operation is to be performed, such as restaurant reviews or phone transcripts. |
instruction | required | A string containing a natural language specification of the aggregation to perform, for example “Summarize the reviews” or “Identify all people mentioned and write a short biography for each of them”. |
Returns
Returns a string containing the result of the aggregation. The function may indicate that the data you’ve provided doesn’t contain the answer if: - You don’t provide a clear instruction specifying how to aggregate the data - The data doesn’t have the information necessary to complete your instruction
Usage notes
- For optimal performance, follow these guidelines:
- Use plain English text for the instruction.
- Provide a declarative instruction instead of asking a question. For example, instead of a question like “Can you summarize this?”, use “Summarize the phone call transcripts”.
- Describe the text provided in the instruction. For example, instead of an instruction like “summarize”, use “Summarize the phone call transcripts”.
- Describe the intended use case. For example, instead of “find the best review”, use “Find the most positive and well-written restaurant review to highlight on the restaurant website”.
- Multiple columns can be used in the string expression using CONCAT or the || operator. See the example below.
- Consider breaking the instruction into multiple steps. For example, instead of “Summarize the new articles”, use “You will be provided with news articles from various publishers presenting events from different points of view. Please create a concise and elaborative summary of source texts without missing any crucial information.”.
Legal notices
Refer to Snowflake AI and ML for legal notices.
Known gaps
- The emulator does not run language, embedding, document or speech models, so Cortex AI functions have no model to answer with.