snowflake.snowpark.functions.ai_classify¶
- snowflake.snowpark.functions.ai_classify(expr: Union[Column, str], list_of_categories: Union[Column, List[str]], **kwargs) Column[source]¶
Classifies text or images into categories that you specify.
- Parameters:
expr – The string, image, or a SQL object from
prompt()that you’re classifying. If you’re classifying text, the input string is case sensitive. You might get different results if you use different capitalization.list_of_categories – An array of strings that represents the different categories. Categories are case-sensitive. The array must contain at least 2 and no more than 100 categories. If the requirements aren’t met, the function returns an error.
**kwargs –
Configuration settings specified as key/value pairs. Supported keys:
- task_description: A explanation of the classification task that is 50 words or fewer.
This can help the model understand the context of the classification task and improve accuracy.
output_mode: Set to
multifor multi-label classification. Defaults to single for single-label classification.examples: A list of example objects for few-shot learning. Each example must include:
input: Example text to classify.
labels: List of correct categories for the input.
explanation: Explanation of why the input maps to those categories.
- Returns:
A serialized object. The object’s
labelfield is a string that specifies the category to which the input belongs. If you specify invalid values for the arguments, an error is returned.
Examples: