This topic describes the AI application workflow with OceanBase Vector Search.
Core steps
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 Database stores all data, including traditional relational tables for business data, raw unstructured data, and vector data generated through vector embedding. For more information, see Store vector data.
To enable efficient vector search, OceanBase Database internally builds vector indexes for the vector data. A vector index is a specialized data structure that significantly accelerates nearest-neighbor search in high-dimensional vector spaces. Due to the high computational cost of vector similarity calculations, exact search (which calculates the distance for every vector) ensures accuracy but results in a sharp decline in query performance. By using vector indexes, the system can quickly locate candidate vectors and significantly reduce the number of vectors that need to have their distances calculated, thereby improving query efficiency while maintaining high accuracy. For more information, see Vector indexes.
3. Perform nearest-neighbor search and hybrid search using SQL/SDK
Users interact with the AI application through clients or programming languages, submitting queries that may involve text, images, or other data types.
OceanBase Database uses SQL statements to query and manage relational data, enabling hybrid search for scalar and vector data. When a user initiates a query, if it is unstructured, the system first converts it into a vector using the vector embedding model. Then, the system leverages vector indexes and scalar indexes to quickly search for vectors that are most similar to the query vector and meet the scalar filtering conditions, thereby finding the most relevant unstructured data. For more information about nearest-neighbor search, see Nearest-neighbor search.
4. Generate optimized prompts and submit them to the LLM for inference
In the final stage, the system generates optimized prompts based on the results of the hybrid search and submits them to the large language model (LLM) for inference. The LLM generates natural language responses based on the context provided. There is a feedback loop between the LLM and the vector embedding model, meaning that the LLM's outputs or user feedback can be used to optimize the vector embedding model, forming a continuous learning and optimization cycle.
