This topic describes the AI application workflow using OceanBase vector search.
Core steps
The core steps are described as follows:
1. Convert unstructured data into feature vectors through vector embedding
The workflow begins with unstructured data (such as videos, documents, and images). Various forms of unstructured data—including videos, text files (documents), and images—are transformed into vector representations through vector embedding models. These models convert raw, unstructured data into high-dimensional vectors that capture the semantic information and features of the data, allowing similarity to be measured by distances in the vector space. For more information, see Generate vector data.
2. Store vector embeddings and create vector indexes in OceanBase Database
As the core storage layer, OceanBase is responsible for storing all data. This includes traditional relational tables (used for business data), the original unstructured data, and the vector data generated after embedding. For more information, see Store vector data.
To enable efficient vector search, OceanBase creates vector indexes for the vector data. Vector indexes are specialized data structures that significantly accelerate nearest neighbor searches in high-dimensional vector spaces. Since calculating vector similarity is computationally expensive, exact searches (calculating distances for all vectors) ensure accuracy but can severely impact query performance. Vector indexes allow the system to quickly locate candidate vectors, greatly reducing the number of distance calculations required, thereby improving query efficiency while maintaining high accuracy. For more information, see Vector indexes.
3. Perform nearest neighbor search and hybrid search through SQL or SDK
Users interact with the AI application through clients or programming languages by submitting queries that may involve text, images, or other formats. For more information, see Supported clients and languages for vector search.
OceanBase uses SQL statements to query and manage relational data, enabling hybrid searches that combine scalar and vector data. When a user initiates a query—if it is unstructured—the system first converts it into a vector using the embedding model. Then, leveraging both vector and scalar indexes, the system quickly retrieves the most similar vectors that also meet scalar filter conditions, thus identifying the most relevant unstructured data. For more information, see Vector similarity search.
4. Generate prompts and send them to the LLM for inference
In the final stage, an optimized prompt is generated based on the hybrid search results and sent to the large language model to complete the inference process. The LLM generates a natural language response based on this contextual information. There is a feedback loop between the LLM and the vector embedding model, meaning that the output of the LLM or user feedback can be used to optimize the embedding model, creating a cycle of continuous learning and improvement.