This topic describes the basic concepts, features, use cases, and limitations of the AI function service.
Basic concepts
The AI function service is an innovative feature provided by OceanBase Database. It seamlessly integrates AI model capabilities and document processing capabilities into the internal data processing workflow of the database. Users can directly call these capabilities using SQL expressions, significantly simplifying the RAG process.
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 into vectors, laying the foundation for vector search and matching. | Text 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 the retrieved content or text, and outputs the final results. | Model inference |
| Yes | AI_PROMPT
NoticeThis function must be used in conjunction with the |
Dynamically constructs formatted prompts based on a prompt template, supporting dynamic data insertion. | 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 embedding: The
AI_EMBEDfunction converts the retrieved or split text into vectors, laying the foundation for vector search and matching. - 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 the retrieved content or text, and output the final results.
Usage notes and limitations
- When using functions with pure local processing (e.g.,
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.
