This repo hosts samples meant to help use the new Native Vector Support in Azure SQL DB feature. We illustrate key technical concepts and demonstrate how you can store and query embeddings in Azure SQL data to enhance your application with AI capabilities.
Important
Vector Functions are in Public Preview. Learn the details about vectors in Azure SQL here: https://aka.ms/azure-sql-vector-public-preview
To use the provided samples make sure you have the following pre-requisites:
-
An Azure subscription - Create one for free
-
Azure SQL Database - Create one for free
-
Make sure you have an Azure OpenAI resource created in your Azure subscription.
-
Make sure you have access to the Early Adopter Preview by filling out this form: https://aka.ms/azuresql-vector-eap
-
Azure Data Studio - Download for free to use the notebooks offline. SQL Server Management Studio is also an option if you don't want to use notebook offline.
-
If you are going to clone this repository in your machine, make sure to have installed the
git-lfs
extension: Git Large File Storage
A simple getting started to get familiar with common vector functions is available here: Getting-Started
Learn how to get embeddings from OpenAI directly from Azure SQL using the sample available the Embeddings/T-SQL folder.
The Vector-Search example illustrates the implementation of Vector Similarity Search within an SQL database, highlighting the capabilities of semantic search. By leveraging vector representations of text, the system can identify reviews that share contextual similarities with a given search query, transcending the limitations of keyword exact matches. Additionally, it demonstrates the integration of Keyword Search to guarantee the inclusion of specific terms within the search outcomes.
The Python sample in the Hybrid-Search folder shows how to combine Fulltext search in Azure SQL database with BM25 ranking and cosine similarity ranking to do hybrid search.
The RAG pattern is a powerful way to generate text using a pre-trained language model and a retrieval mechanism. The Retrieval Augmented Generation folder contains a sample that demonstrates how to use the RAG pattern with Azure SQL and Azure OpenAI, using Python notebooks.
If you are using .NET EF Core, you can use the EF-Core sample to see how to use the new vector functions in your application.
Semantic Kernel is an SDK that simplifies the creation of enterprise AI-enabled applications. Details on support for SQL Server and Azure SQL as vectors stores are available in the SemanticKernel folder.
- Create and deploy an Azure OpenAI Service resource
- Embeddings models
- SQL AI Samples and Examples
- Frequently asked questions about Copilot in Azure SQL Database (preview)
- Responsible AI FAQ for Microsoft Copilot for Azure (preview)
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.