OceanBase Cloud provides built-in AI models for AI function. Once enabled, you can use the AI function and hybrid search feature of OceanBase Database. This topic describes how to enable the AI function built-in AI models.
Background information
OceanBase Database V4.4.1 supports AI function and hybrid search. You can use these features in instances created on the OceanBase Cloud console or Alibaba Cloud Marketplace.
AI function: AI function allows you to directly integrate the capabilities of AI models into data processing within the database using SQL expressions. This greatly simplifies operations such as data extraction, analysis, summarization, and storage using large AI models. It is a significant new feature in the database and data warehouse fields. In the MySQL compatible mode, OceanBase Database provides AI model and endpoint management through the DBMS_AI_SERVICE package, introduces several built-in AI function expressions, and supports monitoring AI model calls through views. For more information, see AI function syntax and examples.
Hybrid search: Hybrid search combines vector-based semantic search with keyword search based on full-text indexes. It provides more accurate and comprehensive search results through integrated sorting. Vector search is good at semantic approximate matching but is weak in exact matching for keywords, numbers, and proper nouns. Full-text search effectively compensates for this weakness. Therefore, hybrid search has become a key feature of vector databases and is widely used in various products. OceanBase Database efficiently implements hybrid queries by integrating its full-text and vector index capabilities. For more information, see Full-text and vector hybrid search.
Prerequisites
You have created an instance on the OceanBase Cloud console or Alibaba Cloud Marketplace. The feature is currently available only to allowlisted users. If you need to use it, please contact technical support.
Your OceanBase database version is V4.4.1 or later.
Your storage architecture is Shared Nothing.
You have the permissions of a project owner, project admin, or instance admin.
Grant the
ACCESS AI MODELpermission to your user. For more information, see Create and manage accounts.Log in to the OceanBase Cloud console.
On the Instances page, click the expand icon to the left of the instance name and then click the target tenant name.
Click Manage Access in the left-side navigation pane to go to the account management page.
Click the icon in the Actions column of the target account and select Update Privilege. In the dropdown list under Global Permissions, select
ACCESS AI MODEL.Modify the permissions in the dialog box and click Update.
Procedure
Log in to the OceanBase Cloud console.
In the left-side navigation pane, click Instances.
In the instance list, click the name of the target instance to go to the Overview page of the instance.
In the left-side navigation pane, click Tenants.
In the tenant list, click the name of the target tenant to go to the Overview page of the Tenant.
Click Enable under AI Function Built-in Models.
Note
The built-in models and their token limits are as follows:
- OB_Complete (qwen-plus): 70 million per month
- OB_Embed (text-embedding-v3): 60 million per month
- OB_Rerank (gte-rerank-v2): 60 million per month
You can also click Disable under AI Function Built-in Models to disable the AI Function.
How to use the embedded AI models
After enabling the AI Function built-in models, you can directly call the built-in AI models using SQL statements. Here are the methods for using the three models:
Text completion
Use the
AI_COMPLETEfunction to call the OB_Complete model for text completion and conversation. This function accepts the model name and prompt text as parameters.SELECT AI_COMPLETE("ob_complete","Who are you") AS ans;For more usage examples and parameter details, see AI function syntax and examples.
Text vectorization
Use the
AI_EMBEDfunction to call the OB_Embed model to convert text into a vector representation. This function accepts the model name and the text to be vectorized as parameters, returning the vector embedding of the text.SELECT AI_EMBEDDING("ob_embed","Artificial intelligence technology development") AS embedding;Vector embeddings can be used in scenarios such as semantic search and similarity calculation. For more usage examples and parameter details, see AI function syntax and examples.
Result re-ranking
Use the
AI_RERANKfunction to call the OB_Rerank model to re-rank search results. This function accepts the model name, query text, and candidate document list as parameters, returning the results sorted by relevance.SELECT AI_RERANK("ob_rerank","Apple",['"apple","banana","fruit","vegetable"']) AS rerank_result;This function is commonly used in hybrid search scenarios, optimizing the sorting of results by combining vector retrieval and full-text retrieval. For more usage examples and parameter details, see AI function syntax and examples and Full-text and vector hybrid search.
