MindsDB is an open-source platform designed to enable machine learning, time series analysis, and the integration of large language models directly into traditional database workflows. The platform makes AI functionality accessible through simple SQL queries without requiring a separate machine learning infrastructure.
In this post we introduce one of the many features of MindsDB: calling a large language model (GPT-4) via a predefined template that is dynamically populated with database values. The goal is to automatically assess the emotional impact of songs from an existing Spotify dataset. Only a portion of MindsDB’s full feature set is used to demonstrate the basic workflow and the interaction between the database and the LLM.
Getting started with MindsDB is straightforward. The platform can be launched locally via Docker in a matter of seconds. The following command starts MindsDB in the background, opens the necessary ports for the API and Studio interface, and creates a volume to persist data and configurations:
After startup, the web interface is accessible at http://localhost:47335. There, files can be uploaded, models or templates can be defined, and SQL queries can be executed. For the following use case, the “200k Spotify Songs Light” dataset is used, which is available at kaggle.com. The dataset contains over 200,000 Spotify songs with features such as song title, emotion, tempo, variability, and other music parameters.

The goal is to have a large language model like GPT-4 assess the emotional impact of a song – based on numerical parameters such as emotion, tempo, and variance. To achieve this, a model is defined in MindsDB that invokes GPT-4 via a prompt template. The database values are automatically inserted into the prompt:

This instruction does not create an AI model in the traditional sense, but rather creates a reusable (local) template for communication with GPT-4. Only when a concrete SQL query is executed, where real values are inserted into the prompt, is the request sent to GPT-4.
An example of such a query looks as follows:

The response returned by GPT-4 is:
This workflow demonstrates, as an example, how numerical data from traditional tables can be combined with semantic evaluation. Without separate prompt management, API scripting, or external tools, GPT-4 is accessed directly through SQL and integrated into analytical workflows.
Additional features of MindsDB
MindsDB offers far more than just the integration of LLMs. In many use cases, the platform is used to apply traditional machine learning models to structured data, make predictions, or automate complex analyses.
Traditional predictive models can be created directly from SQL. Examples include predicting customer churn (churn prediction), estimating rental or real estate prices, or forecasting sales figures and weather data. This is done entirely within the database environment and without separate ML infrastructures.
Another major area is time series analysis. MindsDB enables forecasting time-dependent values such as energy consumption, product demand, or machine conditions. This allows trends to be identified early and capacities to be better planned.
Additionally, MindsDB supports the integration of large language models such as GPT-4, Claude, or Mistral. These can be used for tasks such as text summarization, sentiment analysis, classification, or translation. Emotional impact analyses, like the example described here, can also be performed.
MindsDB is also capable of detecting anomalies in large datasets. The system is thus suitable for fraud detection, quality assurance in production processes, or monitoring IT systems.
Recommendation systems can also be built with MindsDB. Based on usage or purchase histories, models can be created that generate personalized product recommendations.
Finally, MindsDB offers the ability to integrate custom machine learning models. With the function „Bring Your Own Model“ self-trained models (for example from PyTorch or TensorFlow) can be incorporated and used through the same SQL interface.
