Implementing Generative AI in Snowflake with Azure OpenAI using Streamlit

Generative AI has created a new Buzz, with OpenAI’s ChatGPT leading the innovation. However, customers are interested in how to tap this innovation with their data. The answer to that is Azure OpenAI. Azure OpenAI is an enterprise offering OpenAI models as part of Azure Cognitive Services from Microsoft that helps power your apps with large-scale customized AI models with labeled data for your specific scenario using a simple REST API. Azure OpenAI also enables Customers to fine-tune the deployed model’s hyperparameters to increase output accuracy and leverage few-shot learning capability to provide the API with data examples to achieve more relevant results.

Azure OpenAI provides a new way to interact with the data in Snowflake using OpenAI’s powerful language models, including the GPT-3, Codex, and Embeddings model series, as well as the new GPT-4 and ChatGPT (gpt-35-turbo) model series directly using the REST API. This Streamlit OpenAI Assistant demonstrates that by answering questions about data in Snowflake by performing advanced data analytic tasks on Snowflake. You can access the App from https://sf-openai-bot.streamlit.app/; the code is open source and available at https://github.com/sgsshankar/OpenAIWorkshop-Snowflaket

This App requires access to Azure Open AI. You can request Azure Open AI preview here and GPT-4 access here. This assistant does not need to move out from Snowflake. Instead, it relies on using column information to identify and find relationships in data to generate the SQL query. The App consists of the SQL Query Assistant and the Data Analysis Assistant.

SQL Query Assistant

SQL Query Writing Assistant is a simple application that translates business question into SQL query and then executes it in Snowflake to display the result. It helps business users ask questions about data and get instant results from it as well as Data Analysts also generate SQL code.

Data Analysis Assistant

Data Analysis Assistant is a more sophisticated application for advanced data analytics, such as statistical analysis and forecasting. It uses the Chain of Thought and React techniques to perform multi-step processing where the next step in the chain also depends on the observation/result from the previous step. It displays results in charts using the Plotly library and can also show the Python code for each step.

You can use the GPT-4 as an engine for advanced questions such as forecasting.

Configuring the App

You can configure the App using the Settings page at runtime or the secrets.env file.

This App is just an example of how easy it is to leverage Generate AI to get instant insights from Data using Azure OpenAI. OpenAI brings in many advanced use cases for various industries that can truly unlock the potential of data in Snowflake.

The blog was inspired by the great work done by Microsoft folks at the OpenAI Workshop. For more Azure OpenAI Workshop related content — https://github.com/microsoft/OpenAIWorkshop

--

--

Shankar Narayanan SGS
Snowflake Builders Blog: Data Engineers, App Developers, AI/ML, & Data Science

Principal CSA @ Microsoft supporting Snowflake as Partner ISV. Responsible for supporting Snowflake Customers and Microsoft integrations with Snowflake