cancel
Showing results for 
Search instead for 
Did you mean: 
Technical Blog
Explore in-depth articles, tutorials, and insights on data analytics and machine learning in the Databricks Technical Blog. Stay updated on industry trends, best practices, and advanced techniques.
cancel
Showing results for 
Search instead for 
Did you mean: 
RahulNabera
Databricks Employee
Databricks Employee

Enhancing Databricks Genie with Advanced AI Capabilities

Databricks AI/BI Genie provides an intuitive way to interact with your data. It allows you to ask questions in natural language and receive intelligent responses from your Lakehouse. Genie makes data exploration and business intelligence readily accessible.

This post explains how you can tap into Genie's deeper AI potential. While Genie handles the complexity of query generation, understanding the concepts behind Databricks AI Functions—specialized SQL Functions that Genie can utilize—helps you guide Genie to perform more sophisticated AI-driven analyses and interpret its advanced responses. We will explore how you can configure and interact with Genie to leverage these underlying AI capabilities effectively.

How Genie Delivers Advanced AI Insights

Genie works by translating your natural language questions into SQL queries that run on your data. When your questions imply a need for tasks like sentiment analysis, forecasting, or complex text interpretation, Genie can be guided to generate SQL that incorporates the functionality of specific AI Functions. Your role is to provide Genie with the right context and examples so it can effectively use these powerful tools on your behalf.

Guiding Genie for Sophisticated AI Tasks

To help Genie perform advanced AI tasks effectively and in alignment with your data, it’s essential to provide clear, structured configuration guidance:

  1. The Importance of Clear Natural Language:
    While Genie is adept at interpreting natural language, the clarity and specificity of your questions help it accurately pinpoint the data and the analytical approach you intend. For complex AI-driven analysis, combine clear questions with explicit guidance in Genie's configuration settings.
  2. Optimizing Genie Space Configuration:
    The setup of your Genie space is crucial for teaching Genie how to apply AI capabilities to your data:
  • "Instructions" for Business Context: Use the "Instructions" section in your Genie space to provide business definitions, data nuances, and preferred analytical approaches. This helps Genie understand how to interpret your data and questions, including when AI-driven analysis might be appropriate.
  • "Example SQL Queries" – Teaching Genie AI Techniques: This is a primary method for guiding Genie to use AI functionality. By adding SQL examples that incorporate AI Functions, you provide Genie with patterns it can adapt. When Genie receives a relevant natural language prompt, it can refer to your examples to construct an appropriate AI-enhanced SQL query.
  • Custom SQL Functions: You can create your own custom SQL Functions that might internally use AI Functions for specific, reusable AI logic. By including these custom SQL Functions in your "Example SQL Queries" for Genie, you further tailor its ability to respond to your business-specific AI needs.

Refer to this link for guidance on effectively using instructions, Example SQL, and SQL Functions within Genie.

Overview of AI Capabilities Available to Genie

Let's explore some core AI capabilities that Genie can provide, powered by concepts from AI Functions. Understanding these helps you craft better "Example SQL Queries" and "Instructions" for your Genie spaces.

Prerequisites for Genie to leverage these capabilities:

  • Your Databricks workspace must be in a supported region.
  • Foundation Model APIs need to be enabled or model serving endpoints configured if ai_query functionality is expected.
  • A Pro or Serverless SQL warehouse is typically needed for forecasting capabilities.

1. Sentiment Analysis using Genie

Capability: Genie can analyze and report on customer sentiment.

Example Natural Language Prompt to Genie: "What's the overall customer sentiment for Product P101 based on recent reviews?"

Guiding Genie: To ensure Genie accurately performs sentiment analysis on your customer_reviews table, you can provide an "Example SQL Query" in its space configuration that demonstrates the use of ai_analyze_sentiment()

To configure Genie for sentiment analysis by adding your datasets for analysis as below.

1.png

The below screenshot demonstrates the response from the Genie without the use of any AI functions. When a customer asks a question to provide the sentiment of customer reviews, the response from Genie is quite generic.

2.png

With the use of an example query, we can prompt Genie to use the query for answering questions related to analyzing sentiment on customer reviews.

3.png

The query below helps Genie respond better to the user's question, as in the screenshots below. This example teaches Genie the pattern for sentiment analysis, which it can then apply more broadly. The example query helps Genie analyse the dataset and provides the actual sentiment analysis of the data, with sentiments of positive, negative, and neutral for each product mentioned in the dataset.

4.png

-- Prompt: Example SQL Query for Genie Space: How do customer reviews trend in terms of snetiment?
-- Instructs Genie on how to perform sentiment analysis on review_text.
SELECT
  product_id,
  review_text,
  ai_analyze_sentiment(review_text) AS sentiment
FROM
  your_catalog.your_schema.customer_reviews;

5.png

When a user extends the query to inquire about the overall sentiment of a specific `product_id`, Genie will leverage the provided example to comprehend the request and formulate an appropriate response.

6.png

2. Advanced Text Analysis with Genie using ai_query Concepts

Capability: Genie can perform various advanced text analysis, like theme extraction or specific information retrieval.

Example Natural Language Prompt to Genie: "What are the main issues mentioned in negative reviews for Product P202?"

7.png

Guiding Genie: Provide an "Example SQL Query" to enable Genie to extract themes using the functionality of ai_query (which connects to Foundation Models).

SELECT
  review_id,
  review_text,
  ai_query(
   -- Specify preferred Foundation Model endpoint
     "databricks-llama-4-maverick",
CONCAT(
      "Identify the primary issue theme from this negative review (e.g., 'Quality', 'Service', 'Price'). Review: ",
review_text
    )
  ) AS issue_theme
FROM
  your_catalog.your_schema.customer_reviews
WHERE
  product_id = 'P202' AND
  ai_analyze_sentiment(review_text) IN ('negative', 'mixed');

This gives Genie a template for how to leverage powerful language models for your specific text analysis tasks.

8.png

9.png

Best Practices for Optimizing Genie's AI Performance

To get the most out of Genie's AI capabilities:

  • Clear Instructions and Examples: Provide precise "Instructions" and well-structured "Example SQL Queries" (that demonstrate AI Function usage) in your Genie space configuration. This is the most direct way to teach Genie.
  • Understand Model Capabilities: Be aware that different AI models (especially those accessible via ai_query concepts) have varying strengths. Your "Example SQL Queries" can guide Genie to use appropriate model endpoints if you specify them.
  • Data Quality is Foundational: Genie's AI-driven insights depend on the quality of your underlying data. Ensure it is clean and relevant.
  • Iterative Refinement: Getting Genie to perform highly specific AI tasks may require iterating on your "Instructions" and "Example SQL Queries." Test how Genie responds and refine your guidance.
  • Performance Considerations for Genie: Complex AI operations can be resource-intensive. If Genie is slow on certain AI-driven questions, consider if pre-materialized views (perhaps built using AI Functions directly in batch) could provide some of the needed information more quickly for Genie to consume.
  • Security and PII in Prompts/Examples: When crafting prompts or example queries that might be sent to language models (via ai_query functionality), be mindful of sensitive data.
  • Descriptive Metadata: Ensure your tables and columns have clear, descriptive comments. Genie uses this metadata to better understand your data and your questions.
  • Govern with Unity Catalog: Leverage Unity Catalog to manage and audit your data and how it's accessed, including by Genie.

Other AI Capabilities Available to Genie

Genie can potentially leverage the concepts behind other AI Functions like ai_classify(), ai_forecast(), ai_extract(), ai_fix_grammar(), ai_mask(), ai_summarize(), ai_translate() and many more which can be viewed on this page. You can teach Genie these patterns through "Example SQL Queries or SQL Functions" that utilize these functions.

Conclusion

Databricks AI/BI Genie provides an intuitive interface to your data. By understanding the concepts of AI Functions and strategically guiding Genie through clear "Instructions" and "Example SQL Queries" in its configuration, you unlock its ability to perform sophisticated AI-driven analyses. This approach allows you to leverage powerful AI capabilities through natural language, making advanced insights more accessible across your organization.

Experiment with configuring your Genie spaces with AI-powered examples to enhance their analytical depth and improve your data-driven decision-making.

3 Comments