Project: YugabyteDB (App Definition and Development / Database)
File: gen-ai-apps.md

title: Building Gen-AI applications on top of YugabyteDB headerTitle: Gen-AI applications linkTitle: Gen-AI apps headcontent: Build a virtual assistant for YugabyteDB menu: preview: identifier: gen-ai-apps parent: going-beyond-sql weight: 700 rightNav: hideH3: true type: docs As technologies continue to advance, their potential applications are becoming increasingly widespread. Databases have long been the backbone of structured data storage and querying for organizations, and integrating them with Gen-AI capabilities can unlock new possibilities for data-driven decision making, automation, and user experiences. While databases are efficient for storing and querying data, it can be challenging for non-technical users to interact with them directly. This is where chatbots come into play, providing a natural language interface for users to access and manipulate data stored in databases. Because YugabyteDB is fully compatible with PostgreSQL, it can be quickly adapted to provide interaction using Retrieval Augmented Generation (RAG)-based technologies. This section uses the following terms: Natural Language Processing (NLP) enables computers to understand, interpret, and generate human language in a way that is both meaningful and beneficial. Large Language Models (LLM) are advanced NLP models that have been trained on massive amounts of text data. These models are capable of understanding and generating human-like text with remarkable fluency and coherence. One approach to building chatbots for database interaction is the Retrieval-Augmented Generation (RAG) framework. RAG combines two powerful components: a retrieval system that can fetch relevant information from a knowledge base (in this case, the database schema and data), and a language generation model that can produce natural language responses based on the retrieved information. The RAG approach is particularly well-suited for building chatbots that interact with YugabyteDB for several reasons. YugabyteDB stores data in a structured format, making it easier for the retrieval component to find relevant information based on the user's query. In addition to the data itself, the database schema (tables, columns, relationships) provides a rich knowledge base for the retrieval component to understand the context and semantics of the data. The primary purpose of the LLM is to convert a question in a natural language to a SQL statement. It does so as follows: The database schema is sent to a LLM. For better query creation, it is normal to send example questions and the respective query for fine-tuning the LLM. If the LLM is internally deployed, then data from the database could also be sent to the LLM. The chatbot takes in a user question or text in a natural language. The chatbot then sends the text to the LLM. The LLM responds with a SQL query. The chatbot executes the SQL query against the database. The chatbot returns the result as-is to the user or it may transform the result to a natural language using a NLP system and return that response. {{<warning>}}Typically the data stored in the database is not sent to external systems due to privacy concerns, but some information about the data could be sent.{{</warning>}} Several tutorials on the different ways of setting up Gen-AI-based interfaces for your database are available: There are to choose from. The following are a few that we have tried out. | Type | LLM | | -- | - | | External | from | | External | from | | External | from Google | | Local | | | Local | | {.sno-1}