Unlock the Power of AI Models with Generative AI Tables by MindsDB

The development of AI models is typically a time-consuming and resource-intensive endeavor, demanding the expertise of skilled professionals and significant financial investment. It entails various stages, such as data preparation, model development, and the construction of complex data pipelines that require ongoing maintenance.

MindsDB presents a streamlined solution by introducing Generative AI Tables that abstract AI models as virtual tables. In this article, we'll explore how you can create, train, and deploy AI models effortlessly with just a single command. Say goodbye to the complexities of traditional AI model development as we delve into the power of Generative AI Tables by MindsDB.

Streamlining AI Deployment with MindsDB

MindsDB is an AI Automation Platform that manages AI models and automates workflows connecting AI models with enterprise databases. We provide a comprehensive solution for deploying and managing AI models. From state-of-the-art LLMs and advanced vector operations to the forefront of time-series forecasting and classical ML techniques, MindsDB empowers businesses to harness the full potential of AI with ease and precision.

Bridging the gap between AI and data, MindsDB introduces the concept of Generative AI Tables that abstract AI models as virtual tables, enabling developers familiar with SQL to create AI-powered applications effortlessly. This unique approach ensures that any developer can leverage the power of AI without extensive knowledge of complex machine-learning algorithms.

With MindsDB, you have the flexibility to connect virtually any data source, including databases, data warehouses, applications, and more. Once connected, you can utilize this data to train models and query for predictions. Additionally, MindsDB supports various popular machine learning frameworks, including OpenAI, Hugging Face, LangChain, and more, allowing you to leverage existing frameworks and create models tailored to your specific needs.

Follow along to experience the simplicity and versatility of MindsDB as it empowers you to unlock the true potential of AI logic deployment.

The Power of Generative AI Tables

Generative AI, a prominent subfield of artificial intelligence, specializes in training AI models to generate novel content, including text, forecasts, images, and more. By learning patterns from existing data, these models can produce remarkably realistic outputs.

MindsDB presents an innovative approach to integrate AI with data through the introduction of Generative AI Tables. These virtual tables serve as an abstraction for AI models, capable of generating lifelike outputs based on specific inputs.

Here are the key features of Generative AI Tables:

  1. Abstraction: Generative AI Tables act as an abstraction for AI models, encapsulating all their capabilities.

  2. Queryability: Like any other table, Generative AI Tables can be queried, making them accessible and easy to work with. You can make predictions by joining a Generative AI Table with an input data table. Furthermore, you can save these predictions in your database.

  3. Data Generation: Generative AI Tables do not store data themselves. Instead, they generate data from the underlying model upon being queried.

  4. Simplicity: MindsDB's approach is based on the familiar and straightforward concept of database tables. By abstracting AI models as virtual tables, we provide a user-friendly and easily graspable interface for working with AI models.

Now, let's delve into some examples that illustrate the potential of Generative AI Tables by MindsDB.

Deploying AI Models with Generative AI Tables

With MindsDB, you can create, train, and deploy an AI model with just a single command. This command initiates a Generative AI Table, enabling seamless querying for accurate predictions.

Example 1: A Simple Regression Model

In this example, we'll use a database table that stores debt and income data.

SELECT income, debt
FROM financial_data;

Here are the available data points stored in the financial_data table:

If you query the financial_data table for a debt value associated with the income of 60000, you’ll get a straightforward response - 20000. But if you query it for a debt value associated with the income of 70000, you’ll get a null value because this data point does not exist in the financial_data table.

But you can use the financial_data table to train an AI model that leads to the creation of a Generative AI Table.

CREATE MODEL debt_predictor 
FROM financial_data
PREDICT debt;

The debt_predictor model is the so-called Generative AI Table, trained on data FROM the financial_data table and instructed to PREDICT debt values. This debt_predictor model approximates the debt values for any arbitrary income value.

Now, if you query this model for a debt value associated with an arbitrary income value, you’ll get an approximated answer.

SELECT income, debt
FROM debt_predictor
WHERE income = 70000;

The debt_predictor model, or a Generative AI Table, generates data upon being queried.

Example 2: A Large Language Model

In this example, we’ll use a database table that stores product names and customer reviews. The aim is to enrich this data with an additional column that defines sentiment for each review by utilizing the power of Generative AI Tables.

SELECT product_name, customer_review
FROM product_reviews;

Here are the available data:

product_namecustomer_review
Power AdapterIt is a great product.
Bluetooth and Wi-Fi SpeakerIt is ok.
Kindle eReaderIt doesn’t work.

Let’s create a model, or a Generative AI Table, and instruct it to assign sentiment to each customer review.

CREATE MODEL sentiment_classifier
PREDICT sentiment
USING
    engine = ‘openai’,
    prompt_template = 'describe sentiment of the reviews strictly as 
                                            "positive", "neutral", or "negative".
                                             "I love the product":positive
                                             "It is a scam":negative
                                             "{{customer_review}}":';

To create the sentiment_classifier model, or a Generative AI Table, and enable sentiment prediction, we follow a similar approach using the custom CREATE MODEL statement. Within the statement, we specify the ML engine that is the basis for the model. In this case, we opt for the powerful OpenAI engine.

Furthermore, we employ the prompt_template parameter to store the message that the model will complete. The {{customer_review}} variable will be replaced with the review value from the input data table. This prompt_template parameter plays a crucial role in shaping the behavior and output of the sentiment_classifier model.

Now the model is created and deployed as a virtual table. We join the model with the input data table to predict sentiment values for all customer reviews.

SELECT
    input.product_name,
    input.customer_review,
    output.sentiment
FROM product_reviews AS input
JOIN sentiment_classifier AS output;

The product_name and customer_review columns come from the product_reviews table. The customer_review values are fed to the sentiment_classifier model that follows the instructions from the prompt_template parameter, replacing the {{customer_review}} variable with the value for each data row.

Here is what we get upon joining the model with the data table:

product_namecustomer_reviewsentiment
Power AdapterIt is a great product.positive
Bluetooth and Wi-Fi SpeakerIt is ok.neutral
Kindle eReaderIt doesn’t work.negative

Enriching your data becomes effortlessly simple with the integration of Large Language Models and Generative AI Tables. By altering the prompt_template value, you have the power to generate diverse data tailored to your specific requirements.

Get Started with MindsDB

Take a hands-on approach to exploring MindsDB by creating a demo account on MindsDB Cloud. This option allows you to access and leverage all the features provided by MindsDB without the need for any installation, so you can experience the power of MindsDB with ease and simplicity.

For an enhanced level of control, you can install MindsDB locally (via pip or Docker). This enables you to have a more engaging experience with the back end, giving you the freedom to modify and debug the code according to your specific requirements. Keep in mind that the training speed will depend on your local environment.

If you plan to utilize MindsDB for production systems, we recommend considering MindsDB Starter. It is a paid version of MindsDB Cloud that offers managed instances, ensuring greater security and scalability for your projects.

Whichever option you choose, MindsDB provides flexibility and ensures a smooth experience for all your AI projects.

Check us out on GitHub to see how you can contribute. Love what we’re doing? Give us a high five and star our repo.

0
Subscribe to my newsletter

Read articles from Martyna Slawinska directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Martyna Slawinska
Martyna Slawinska