GCP – AlloyDB accelerates AI with automated vector indexing and embedding
Modern applications store their most valuable data such as product catalogs or user profiles in operational databases. These data stores are excellent for applications that need to handle real-time transactions — and with their support for vector operations, they’ve also become an excellent foundation for modern search or gen AI application serving.
AlloyDB AI provides powerful, high-performance vector capabilities enabling you to generate embeddings inline and manually tune powerful vector indexes. While you can generate embeddings out of the box for in line search use cases, we also wanted AlloyDB to address the complexity of creating and maintaining huge numbers of vector embeddings.
To make this possible, we’re introducing two new features for AlloyDB AI, available in preview, that will empower you to transform your existing operational database into a powerful, AI-native database with just a few lines of SQL:
-
Auto vector embeddings
-
Auto vector index
Auto vector embeddings transform operational data into vector search ready data by vectorizing data stored inside of AlloyDB at scale. The auto vector index self-configures vector indexes optimized for customer’s workloads, ensuring high quality and performance.
Compare this to the traditional approach of creating the vectors and loading them into your database. The basic steps are familiar to any AI developer: generate vector embeddings using specialized AI models, import the vectors into the database alongside the underlying text, and tune vector indexes. In other words, build an ETL (Extract, Transform, Load) pipeline, extract the data from your database, apply transformations, run it through the AI model, reload and reformat it, then reinsert it into your database and then tune the vector indexes. This approach not only involves significant engineering complexity but also introduces latency, making it difficult to keep your application in sync with your live data despite it being stored alongside it.
An additional challenge is to keep the vector index up to date, which is hard to do manually. While manually tuned indexes are performant and provide excellent results, they can be sensitive to updates in the underlying data and require performance and quality testing before they’re ready to hit the road.
Let’s walk through an example journey of an operational workload and see how AlloyDB AI’s new features remove friction from building enterprise-grade AI, and enable users to modernize applications from their database.
AlloyDB as a vector database
Imagine you run a large e-commerce platform with a products table in AlloyDB, containing structured data like product_id, color, price, and inventory_count, alongside unstructured data such as product_description.
You want to build a gen AI search feature to improve the quality of search in your application and make it more dynamic and personalized for users. You want to evolve from solely supporting simple lexical searches such as “jacket”, which perform exact matches, to searches such as “warm coat for winter” that can find semantically similar items like jackets, coats or vests. To refine the quality, you also want to combine this semantic matching with structured filters such as color = 'maroon' or price < 100. Some of these filters may even live in a different table, such as an orders table which stores information about the user’s order history.
- aside_block
- <ListValue: [StructValue([(‘title’, ‘Get started with a 30-day AlloyDB free trial instance’), (‘body’, <wagtail.rich_text.RichText object at 0x7f0420dea850>), (‘btn_text’, ”), (‘href’, ”), (‘image’, None)])]>
From operational to AI-native
Before you can get started on application logic, you need to generate embeddings on your data so you can perform a vector search. For this you would typically need to:
-
Build an ETL pipeline to extract
productsdata from AlloyDB -
Write custom code to batch the data and send it to an embedding model API on Vertex AI
-
Carefully manage rate limits, token limits, and failures
-
Write the resulting vectors back into your database
-
Build another process to watch for
UPDATEcommands so you can do it again and again, just to keep your data fresh
AlloyDB AI’s new feature, auto vector embeddings, eliminates this entire workflow.
It provides a fully managed, scalable solution to create and maintain embeddings directly from the database. The system batches API calls to Vertex AI, maximizing throughput, and can operate as a background process to ensure that your critical transactions aren’t blocked.
To generate vector embeddings from your product_description column, you just run one SQL command:
- code_block
- <ListValue: [StructValue([(‘code’, “CALL ai.initialize_embeddings(rn model_id => ‘gemini-embedding-001’,rn table_name => ‘products’,rn content_column => ‘product_description’,rn embedding_column => ‘product_embedding’,rn incremental_refresh_mode => ‘transactional’ — Automatically updates on data changesrn);”), (‘language’, ”), (‘caption’, <wagtail.rich_text.RichText object at 0x7f0420dea550>)])]>
Now AlloyDB can handle embedding generation for you. Your products table is AI-enabled and embeddings are automatically updated as your data changes.
If you prefer to manually refresh embeddings, you can run the following SQL command:
- code_block
- <ListValue: [StructValue([(‘code’, “CALL ai.refresh_embeddings(rn table_name => ‘products’,rn embedding_column => ‘product_embedding’, — embedding vector columnrn batch_size => 50 — optional overridern);”), (‘language’, ”), (‘caption’, <wagtail.rich_text.RichText object at 0x7f0420dea3d0>)])]>
Turbocharging search with AlloyDB AI
Now that you have embeddings, you face the second hurdle: performance and quality of search. Say a user searches for “warm winter coat.” Your query may look like this:
- code_block
- <ListValue: [StructValue([(‘code’, “SELECT * FROM productsrnWHERE color = ‘maroon’rnORDER BY product_embedding <-> google_ml.embedding(‘gemini-embedding-001’, ‘warm coat for winter’)rnLIMIT 10;”), (‘language’, ”), (‘caption’, <wagtail.rich_text.RichText object at 0x7f0420dea940>)])]>
To make this vector search query performant, you need a vector index. But traditional vector indexes require deep expertise: you have to manually configure parameters, rebuild the index periodically as data changes, and hope your tuning is correct. This complexity slows development and adds operational complexity.
- code_block
- <ListValue: [StructValue([(‘code’, ‘– Optimal `num_leaves` and `max_num_levels` are based on number of vectors in thern– products table, which means the user will have to figure that out beforehand torn– properly tune the index.rnrnCREATE INDEX idx_products_embedding ON productsrnUSING scann (product_embedding)rnWITH (num_leaves=100000, max_num_levels=2);’), (‘language’, ”), (‘caption’, <wagtail.rich_text.RichText object at 0x7f0420deaa00>)])]>
The new auto vector index feature abstracts all this away and delivers a fully automated and integrated vector search experience that is self-configuring, self-maintaining, and self-tuning. To create a fully optimized index, you just run:
- code_block
- <ListValue: [StructValue([(‘code’, “– AlloyDB will automatically figure out index configuration underneath the hood.rnCREATE INDEX idx_products_embedding ON productsrnUSING scann (product_embedding)rnWITH (mode = ‘AUTO’);”), (‘language’, ”), (‘caption’, <wagtail.rich_text.RichText object at 0x7f0420deaa90>)])]>
With mode=’AUTO’, AlloyDB handles everything:
-
Automatic configuration: It analyzes your data and automatically configures the index parameters at creation time to meet your performance and quality goals.
-
Automatic maintenance: The index updates incrementally and automatically as your data changes, ensuring it remains optimized without any manual intervention. It automatically splits as the index grows in size and automatically updates centroids when data distribution drifts.
-
Automatic query plan optimization: This is where the real magic happens. The ScaNN index leverages real-time workload statistics to self-tune and optimize te execution plan. For a deeper dive, read our previous blog, A deep dive into AlloyDB’s vector search enhancements.
Two new ways to become AI-native
With AlloyDB’s new capabilities, making your operational workload AI-native no longer requires complex ETL pipelines and infrastructure code.
-
Auto vector embeddings transforms your data by handling the entire embedding generation and management lifecycle inside the database.
-
Auto vector index simplifies retrieval by providing a self-tuning, self-maintaining index that automatically optimizes complex filtered vector searches.
By removing this complexity, AlloyDB empowers you to use your existing SQL skills to build and scale world-class AI experiences with speed and confidence, moving projects from proof-of-concept to production faster than ever before. Get started with auto vector embeddings and the auto vector index today.
To get started, try our 30-day AlloyDB free trial. New Google Cloud customers also get $300 in free credits.
Read More for the details.
