How to implement #RAG Architecture with Azure #OpenAI in Microsoft #Fabric

In the previous posts we were starting our journey with Azure OpenAI and Microsoft Fabric for Data Engineering and Business Intelligence use cases. In this video we are kicking things up a notch or two as we are going to cover how to implement RAG (retrieval augmented architecture) in Microsoft Fabric. This video is inspired by the following tutorial provided by Microsoft however, I had to modify a few things to make sure that the code could actually run in my Fabric environment. The modified notebook can be found below.

Our blog with working code: https://www.obvience.com/blog/how-to-implement-rag-in-microsoft-fabric

Original MS Tutorial link: https://microsoft.github.io/SynapseML/docs/Explore%20Algorithms/AI%20Services/Quickstart%20-%20Document%20Question%20and%20Answering%20with%20PDFs/

The high level flow goes like this, first we need to read our documents from the Lakehouse folder. Then we need to process these documents so we can extract text from the binary PDFs. Then we chunk the text into smaller pieces and we create embeddings (or numeric representation of our words in our documents).. These embeddings can now be stored in a special database – Vector database – and in our example we are using Azure AI Search service. That’s the hard part. Then we can take a user question, convert that into embeddings as well, and now we can use questions’ embeddings to run a query in our vector database to bring relevant information back, share it with our OpenAI model (in our case it’s GPT-3.5-turbo) and then let Azure OpenAI generate an answer based on the information that was retrieved from our Vector database document repository.

Sounds pretty simple but dealing with library incompatibilities in Fabric was somewhat painful.. Take a look at the link above to our blog where I posted all of the Python code to get this going.

Leave a comment