MindsDB integrates with numerous AI frameworks. Learn more here.
What are Generative AI Tables?
Generative AI is a subfield of artificial intelligence that trains AI models to create new content, such as realistic text, forecasts, images, and more, by learning patterns from existing data. MindsDB revolutionizes machine learning within enterprise databases by introducing the concept of Generative AI tables. These essentially abstract AI models as virtual AI tables, capable of producing output when given certain input.How to Use Generative AI Tables
AI tables, introduced by MindsDB, abstract AI models as virtual tables so you can simply query AI models for predictions. With MinsdDB, you can join multiple AI tables (that abstract AI models) with multiple data tables (that provide input to the models) to get all predictions at once. Let’s look at some examples.Deploy AI Models as AI Tables
You can deploy an AI model as a virtual AI table using theCREATE MODEL
statement.
Here we create a model that classifies sentiment of customer reviews as instructed in the prompt template message. The required input is the review and output is the sentiment predicted by the model.
Follow this doc page to configure the OpenAI engine in MindsDB.
Prepare Input Data
Theamazon_reviews
table stores the following columns:
sentiment_classifier_model
, but not for the response_generator_model
.
The products_sold
table stores the following columns:
reponse_generator_model
requires the two tables to be joined to provide it with sufficient input data.
Make Predictions
You can query the AI tables directly or join AI tables with data tables to get the predictions. There are two ways you can provide input to the models:-
If you query the AI table directly, you can provide input data in the
WHERE
clause, like this: -
You can provide input data to AI tables from the joined data tables, like this:
The
sentiment_classifier_model
requires a parameter namedreview
, so the data table should contain a column namedreview
, which is picked up by the model. Note that, when joining data tables, you must provide theON
clause condition, which is implemented implicitly when joining the AI tables.
WHERE
clause, like this:
sentiment_classifier_model
takes input data from the amazon_review
table, while the response_generator_model
takes input data from the amazon_reviews
table and from the WHERE
clause.
Furthermore, you can make use of subqueries to provide input data to the models via the WHERE
clause, like this:
Difference between AI Tables and Standard Tables
To understand the difference, let’s go over a simpler example. Here we will see how traditional database tables are designed to give you a deterministic response given some input, and how Generative AI Tables are designed to generate an approximate response given some input. Let’s consider the followingincome_table
table that stores the income
and debt
values.
income_table
table is as follows:

debt
value for a particular income
value results in the following:

income
value that is not
present there?
WHERE
clause condition is not fulfilled for any of the rows, no value is returned.

debt_model
model that allows us to approximate the debt
value for any income
value. We train the debt_model
model using the data from the income_table
table.
CREATE MODEL
statement. On execution of this statement, the predictive model works in the background, automatically creating a vector representation of the data that can be visualized as follows:

debt
value of some random income
value. To get the approximated debt
value, we query the mindsdb.debt_model
model instead of the income_table
table.
