Dremio Cloud Classic
Categories: AI
AI_CLASSIFY
Specialized form of AI_GENERATE for sentiment analysis and document categorization. Classification list provided to LLM as an array of VARCHAR, INT, FLOAT or BOOLEAN and the return is of the same type.
Syntax
AI_CLASSIFY( [model_name VARCHAR,] prompt VARCHAR | (prompt VARCHAR, file_reference), categories ARRAY<VARCHAR|INT|FLOAT|BOOLEAN> ) → VARCHAR|INT|FLOAT|BOOLEAN
- model_name (optional): Model specification in format
'modelProvider.modelName'(e.g.,'gpt.4o').modelProvideris the user-defined name for model provider configuration added in the preferences section.modelNameis one of the models supported and provided by that provider. If not provided, uses the default model for the organization. - prompt: Classification instructions for the LLM. Use
(prompt, file_reference)to process files fromLIST_FILES. - categories: Array of possible classifications. The LLM will choose one of these values as the result.
Examples
AI_CLASSIFY exampleSELECT recipe_name,
AI_CLASSIFY( 'Determine the difficulty level based on these ingredients and steps',
ingredients || ' - Steps: ' || cooking_instructions,
ARRAY['Beginner', 'Easy', 'Intermediate', 'Advanced', 'Expert']) AS difficulty_level, prep_time, number_of_ingredients
FROM recipe_database;
-- recipe_name | difficulty_level | prep_time | number_of_ingredients
-- Chocolate Chip Cookies | Easy | 15 | 8
-- Beef Wellington | Expert | 180 | 12
-- Caesar Salad | Beginner | 10 | 6
SELECT file['path'] as image,
AI_CLASSIFY( 'gpt.4o',
('Determine the type of food in the pictures', file),
ARRAY['Savory', 'Sweet', 'Tart', 'Unknown']) AS food_type
FROM TABLE(LIST_FILES('@image_source/path/to/images'));
-- image | food_type
-- desserts/chocolate_cake.jpg | Sweet
-- appetizers/bruschetta.jpg | Savory
-- fruits/lemon_tart.jpg | Tart
SELECT file['path'] as image,
AI_CLASSIFY( ('Determine the type of food in the pictures', file),
ARRAY['Savory', 'Sweet', 'Tart', 'Unknown']) AS food_type
FROM TABLE(LIST_FILES('@image_source/path/to/images'));
-- image | food_type
-- desserts/chocolate_cake.jpg | Sweet
-- appetizers/bruschetta.jpg | Savory
-- fruits/lemon_tart.jpg | Tart
Usage Notes
• Use (prompt VARCHAR, file_reference) to process files from LIST_FILES.
• Optimized for sentiment analysis and document categorization tasks.
• Returns the same data type as the provided categories array (VARCHAR, INT, FLOAT, or BOOLEAN).
• Categories can be of type VARCHAR, INT, FLOAT, or BOOLEAN.
• If no model is specified, uses the default model set for the organization.
• Model specification format: 'modelProvider.modelName' (e.g., 'gpt.4o').