AlloyDB AI Benifits
Google introduced AlloyDB AI at Next ‘23, a set of built-in features for creating generative AI applications. You may call a Vertex AI model from the database using SQL.
AlloyDB is a managed PostgreSQL-compatible database with high performance, availability, and scalability. In performance studies, AlloyDB AI conducts vector queries 10x quicker than PostgreSQL using the IVFFlat index and analytical queries 100X faster. Improved vector search and predictive ML are also included.
Google’s end-to-end AI platform, Vertex AI, lets you upload, label, train, and deploy ML models. Model Garden on Vertex AI supports Google, third-party, and open-source AI models.
You may use the google_ml_integration extension to connect AlloyDB to Vertex AI and execute predictions with your data using custom models or Model Garden models. AlloyDB AI uses open-source technologies like pgvector and LangChain to store embeddings and link to LangChain apps.
AlloyDB AI creates unique user experiences with real data leveraging Google Cloud products and open-source AI technologies. Therefore, you may design dynamic AI experiences that update in real time with database changes.
This article will show five ways to use SQL to use Vertex AI or custom models for similarity search, sentiment analysis, bot identification, healthcare forecasts, and risk prediction.
Vector embedding similarity search
Say you run South Bay Furnishers and maintain your inventory in a relational database. You might record product descriptions, inventory data, and more in a products table.
This is how you would produce product description embeddings traditionally.
First, extract data from a database or data warehouse, construct embeddings, then upsert the vector into a vector database. At each stage, batching and API restrictions may slow performance. Building your own ETL process that uses various third-party services is typical of conventional processes. A vector database must be kept alongside your application’s transaction database.
AlloyDB AI simplifies this three-step procedure into one SQL query, letting you produce embeddings from your data and save them in your existing database.
To automatically produce table embeddings, add a generated column to your table using the following command:
Vertex AI’s model textembedding-gecko now generates product text embeddings when you put rows into your database. Using pgvector and AlloyDB AI’s improved vector search, you can do similarity search and improve product suggestions.
Analysis of sentiment
AlloyDB can use more data using Model Garden pretrained models. You may utilize Vertex AI’s sentiment analysis model to assess user sentiment without training your own.
Think of a video streaming service where users subscribe to live-streaming channels from various content developers. AlloyDB stores live viewer comments. Let’s imagine you want to measure viewer sentiment, save it in a database, and show it as an emoji in channel comments. A creator and watchers may see a 😐 emoji if comments are 50% positive and 50% negative, or a 😀 if comments are predominantly favorable.
Vertex AI’s pretrained sentiment analysis model can determine a score and magnitude for AlloyDB comments. A score between -1 and 1 (negative, neutral, or positive) is produced by the model. It also estimates negative vs. positive content magnitude. For example, the model might rate “You are a terrible streamer!” -.868 and.977.
To compute negative stream comments, shift the score distribution to 0–1 (instead of -1–1) and multiply by magnitude.
Use f(x) =.5(x +1) to transfer [-1,1] to [0,1] to shift the distribution.
Sum the results for each comment and divide by the total comments. Multiplying your distribution by 100 gives you a percentage: 0% means most streamers have unfavorable remarks, 50% means a fair mix of negative and positive comments, and 100% means almost entirely positive comments. Example: The stream scored.306, or 31% positivity. A 😠 emoji would be shown in the stream as the score is below 50%.
The pretrained model lets you instantly assess audience response to live broadcasts, creating dynamic user experiences and giving producers real-time feedback to course correct. Track the general mood for each contributor and put it on their profile to give them further feedback to enhance their material.
Custom models
The google_ml_integration extension lets you execute predictions using your own Vertex AI models with an endpoint id. For real-time forecasts on time-sensitive transactions, use live data from your database.
Online game bot detection
Imagine you design a real-time multiplayer sports game. Due to bot cheating, daily active users have dropped, and some players have claimed that the game is unfair. Your data science team developed a cheating detection model to address this problem. You may ban a cheating gamer after flagging them.
Developers play cat-and-mouse to catch cheats. Hackers will discover new methods to beat the model as it adds signals to detect bot-like activity. With Vertex AI and AlloyDB, updating models is simple and downtime-free. Simply switch your deployed endpoint to your new model, and your application will utilize it without any code modifications.
Healthcare forecasts
As a health-tech startup, you want to help primary care doctors understand their patients’ heart health. Patient cardiac risk scores may be generated using updated vitals like BMI and blood pressure. You may automatically create a new heart risk score with fresh vitals in AlloyDB using a generated column. Return an updated record to your application and show it in a patient’s chart to let the doctor decide on treatment.
Risk models for insurance
Any insurance firm has to appropriately predict risk. Consider a car insurance provider that provides online quotes. Every time a client applies for an insurance, you must analyze their risk based on their data (e.g., driving record) and run a risk model to quote.
AlloyDB AI may access customer input and other data in AlloyDB to run a Vertex AI risk model. A model determines claim validity in claims processing and other insurance and financial fraud detection.
Conclusion
A data science team and many steps are needed to use machine learning models with database data from your firm. You can utilize machine learning models to produce embeddings, categorize data, forecast outcomes, and more using AlloyDB AI in one step. AlloyDB also lets users use Vertex AI’s pretrained models without data science help.