Generative AI powered by your SQL data

Mechanics Team
4 min readAug 2, 2024

--

See how you can use your SQL data as a robust backend for AI applications with semantic search and retrieval augmented generation. Azure SQL Database along with any SQL servers you connect to Azure integrate seamlessly with Azure AI Search and the Azure OpenAI Service, enabling natural language search capabilities within your SQL data.

Use this approach to enhance e-commerce platforms, financial data analysis, or CRM systems while using SQL’s granular access management controls to ensure that data searches and generated responses are limited to specific user permissions.

Personalized, conversationally-toned, and accurate responses.

Combine your SQL data with Azure AI Search and Azure OpenAI Service for intelligent natural language search.

Secure and controlled data access.

SQL Server’s granular access management ensures data is searched and responses are generated based on user permissions.

Build and maintain a managed search index.

Enable natural language search with vectors using Azure AI Search and Azure OpenAI Service.

Watch our video here:

QUICK LINKS:

00:00 — Generative AI for your SQL workloads
00:33 — Retrieval Augmented Generation
01:00 — Granular access management
01:15 — Enable natural language search
01:54 — Connect vectorized SQL data
02:20 — Test generative AI responses
02:41 — Wrap up

Unfamiliar with Microsoft Mechanics?

As Microsoft’s official video series for IT, you can watch and share valuable content and demos of current and upcoming tech from the people who build it at Microsoft.

Keep getting this insider knowledge, join us on social:

Video Transcript:

-Whether on-prem or in the cloud, beyond keyword search or T-SQL similarity searches, you can combine your SQL data with Azure AI Search and the Azure OpenAI Service in Azure to light up intelligent natural language search for your SQL workloads while using generative AI to modernize the experience with personalized, conversationally-toned, and accurate responses, whether that’s for your e-commerce engine, natural language querying in your financial app, your CRM system, and more. This leverages an approach called Retrieval Augmented Generation, where you can define your SQL data as a trusted source.

-Then, when a user submits a prompt, additional information can be retrieved and used to augment it, providing a large language model with additional context for it to reason over and generate more relevant and accurate responses; a process known as grounding. Any data you present to the language model sits to the side of it and is not absorbed by it. Additionally, SQL Server’s granular access management controls are inherited. Also, depending on who is querying the data, information can only be searched and responses generated and presented based on the user’s access permissions for data.

-That said, during retrieval, we need to go beyond keyword search or T-SQL similarity search. Here, enabling natural language search with vectors is the key to get everything working. This is made possible by using Azure AI Search as your managed search index alongside Azure OpenAI Service to generate vector embeddings based on defined fields in your database to build and maintain the index.

-User prompts are also vectorized in real time, and the query engine then uses the vectorized data with its GPS-like coordinates to find the closest similarities between what was queried in your prompt and the data in the database. Connecting your vectorized SQL data so that it can be retrieved to ground generative AI responses is then simple.

-Here, you’ll use Azure OpenAI Studio with your large language model deployed for generative AI. Select Get data and choose Azure AI Search as your data source and pick vector search for your index.

-You also have a choice of search options, where with hybrid you can combine keyword search with vector search. From there, you can test generative AI responses. In the Azure OpenAI Studio playground to generate AI responses working with your data, you can also instruct the AI assistant on how it should behave with a system message.

-Then try out sample prompts to test the responses generated are relevant and accurate based on the vectorized data in your index. This is how the combined power of your SQL data and AI in Azure brings your SQL workloads into the era of GenAI.

--

--