This topic describes the basic concepts, features, use cases, and limitations of the AI function service.
Basic concepts
The AI function service integrates AI model and document-processing capabilities into database workflows. You can call these capabilities through SQL expressions to simplify RAG workflows.
Function overview
Requires large model |
Function |
Description |
Use case |
|---|---|---|---|
| No, pure local processing | AI_SPLIT_DOCUMENT |
Splits text into multiple segments for subsequent processing.
NoticeUsing this function does not require registering a model and endpoint, nor does it require granting AI model permissions. |
Document splitting |
| Yes | AI_EMBED |
Converts text or images into vectors, laying the foundation for vector search and matching. Image embedding is supported starting from V4.6.0 Hotfix1. | Text/image embedding |
| Yes | AI_RERANK |
Further sorts search results based on similarity or relevance to improve result accuracy. | Result reranking |
| Yes | AI_COMPLETE |
Calls a large model to perform advanced reasoning tasks such as generation, summarization, and Q&A on text or images, and outputs the final results. Image processing is supported starting from V4.6.0 Hotfix1. | Model inference |
| Yes | AI_PROMPT
NoticeThis function must be used in conjunction with the |
Dynamically constructs formatted prompts based on a prompt template, supporting text placeholders and image placeholders such as {img_0}. |
Prompt construction |
Use cases
The AI function service is suitable for the following scenarios:
- Text splitting: The
AI_SPLIT_DOCUMENTfunction splits text into multiple segments for subsequent processing. - Text/image embedding: The
AI_EMBEDfunction converts text or images into vectors, laying the foundation for vector search and image search scenarios. - Result reranking: The
AI_RERANKfunction further sorts search results based on similarity or relevance to improve result accuracy. - Model inference: The
AI_COMPLETEandAI_PROMPTfunctions call a large model to perform advanced reasoning tasks such as generation, summarization, and Q&A on text or images, and output the final results.
Usage notes and limitations
- When using functions with pure local processing (for example,
AI_SPLIT_DOCUMENT), you do not need to register a model and endpoint, nor do you need to grant AI model permissions. - You can view AI model configuration information through views. For more information, see Syntax and examples of AI functions.
- External text reading is implemented through the SQL function LOAD_FILE. You do not need to grant AI model permissions or register an AI model and endpoint. The
LOAD_FILEfunction reads external storage files into the database using the external table interface created by CREATE LOCATION and returns the file content inBLOBformat. - Image embedding instructions and limitations are as follows:
- Image input is supported only by the
AI_EMBED,AI_COMPLETE, andAI_PROMPTfunctions. - Supported image sources include HTTPS image URLs (images are generally limited to 5 MB) and binary image data (passed in by using
FROM_BASE64(...); the system automatically recognizes the format). - Supported image formats: common formats such as JPEG, PNG, WebP, BMP, and TIFF.
- Image input is supported only by the
