AI Functions: Query LLMs With SQL

Demo Type

Product Tutorial




What You’ll Learn

This walkthrough shows how to use Databricks AI Functions, leveraging LLMs directly within your SQL queries. This lets you process unstructured data, identify topics, analyze sentiment, generate responses and much more.

AI Functions simplify deriving meaning from unstructured data and make it easy for analysts to interact with LLMs using SQL.

In this demo, we’ll show you how to extract insights from your text.

  • Leveraging built-in AI functions to perform tasks such as classification, text generation, classification
  • Create your own AI function 
  • Leverage different kind of LLMs based on your requirements: Databricks Foundation Models, your own fine tuned LLMs or external providers

We will see how to analyze customer reviews, asking Databricks Foundation Models OpenAI’s LLM to detect negative reviews and prepare an answer.

We’ll also explore how LLMs can be used to generate fake data.


To install the demo, get a free Databricks workspace and execute the following two commands in a Python notebook

%pip install dbdemos
import dbdemos
dbdemos.install('sql-ai-functions', catalog='main', schema='dbdemos_ai_query')

Dbdemos is a Python library that installs complete Databricks demos in your workspaces. Dbdemos will load and start notebooks, Delta Live Tables pipelines, clusters, Databricks SQL dashboards, warehouse models … See how to use dbdemos


Dbdemos is distributed as a GitHub project.

For more details, please view the GitHub file and follow the documentation.
Dbdemos is provided as is. See the 
License and Notice for more information.
Databricks does not offer official support for dbdemos and the associated assets.
For any issue, please open a ticket and the demo team will have a look on a best-effort ba


demo thumb


Build Your Chatbot With Dolly

demo thumb


Data Warehousing With Identity, Primary Key and Foreign Key

demo thumb


Feature Store and Online Inference