Set up and manage an AI/BI Genie space
This article explains how to set up and manage a Genie space, a chat interface for business users to ask natural-language questions about their data.
Technical requirements and limits
The following requirements and limits apply when using Genie spaces:
Unity Catalog: The data for the Genie space must be registered to Unity Catalog.
Compute: You must use a pro or serverless SQL warehouse.
Throughput: Each workspace can handle up to 20 questions per minute across all Genie spaces.
Required permissions
The following permissions are required to create, edit, and use Genie spaces:
Compute permissions: Genie space creators, editors, and users require CAN USE access to the default SQL warehouse designated for the space. Creators select the default SQL warehouse when they create a space. They can choose any SQL warehouse for which they have CAN RUN permissions.
Data access permissions: Any user who interacts with the space needs at least
SELECT
privileges on the data used in a space.Genie space permissions: Users need CAN RUN permissions on the Genie space to interact with Genie and the data used in the space. See Genie space ACLs for a complete mapping of privileges and abilities for a Genie space.
Note
Configuring data and compute access requires elevated permissions generally restricted to an administrator. See Create a SQL warehouse and Manage privileges in Unity Catalog.
Manage Genie access
Genie uses Partner-powered assistive features that must be enabled at the account level. To learn how to manage these features for your account, see Use Databricks Assistant.
Note
You must be an account administrator to manage access to this feature. If you disable Partner-powered features, users with the SQL entitlement can still click the Genie icon in the sidebar, but they are not able to access any Genie spaces.
Create a new Genie space
Genie spaces allow data analysts to create a domain-specific Genie space experience for business users by taking the following steps:
Click Genie in the sidebar.
Click New in the upper-right corner of the screen.
In the New dialog, choose your initial settings. The options are described as follows:
Title: The title appears in the workspace browser with other workspace objects. Choose a title that will help end users discover your Genie space.
Description: Users see the description when they open the Genie space. Use this text area to describe the spaces’s purpose. The description field supports Markdown formatting so that you can style your text and supply links to helpful context and references. For more information on markdown syntax, see this guide.
Default warehouse: This compute resource powers the SQL statements generated in the Genie spaces. End users need access to this warehouse to interact with the space. A Genie space can use a pro or serverless SQL warehouse. For optimal performance, Databricks recommends using a serverless SQL warehouse.
Tables: Genie spaces can be based on one or more tables. The Add tables button opens a new dialog where you can select the Unity Catalog tables you want to include.
Sample questions: Sample questions are optional. They appear in chats to provide examples of the types of questions users can ask. They can be added during creation or later from the space’s Settings.
Provide instructions
Instructions help to guide Genie’s responses so that it can process the unique jargon, logic, and concepts in a given domain. Comprehensive instructions are critical to a seamless, intuitive Genie space experience. To enter instructions, click Instructions in the Genie space sidebar to open the instructions pane. Use this pane to add General instructions, Example SQL Queries, and SQL Functions.
You can add up to 100 instructions in total for a Genie space. The following contribute to the count:
The entire block of text in General instructions counts as one.
Each example SQL query counts as one.
Each SQL function counts as one.
General instructions
Provide plain text instructions that convey your business or response preferences for Genie to follow. You can format the instructions as a single comprehensive note or categorize them by topic for better organization.
The following shows an example of information you could include in general instructions:
Company-specific business information:
“Our fiscal year starts in February”
Values, aliases, or common filters:
“Always convert to lowercase and use a like operator when applying filters.”
“Use abbreviations for states in filter values.”
Specify functions to answer questions and provide instructions for return values:
“For quarters use the
adventureworks.oneb.get_quarter(date)
UDF. The output ofget_quarter()
is the quarter and is either 1,2,3, or 4. Use this to filter the data as needed.
Example SQL queries
Example SQL queries are SQL queries that you prepare to help train Genie. Genie intelligently selects relevant queries to help generate the response when responding to questions. When you add example queries, you show Genie how to use your data to answer questions. You can also add example questions to teach Genie about the kinds of questions you would expect the example query to answer. If Genie receives a matching question, it can use the example query directly to provide an answer. If it gets a similar question, it can use clues from the example query to help structure the SQL provided in the response. Focus on providing samples that highlight logic that is unique to your organization and data, as in the following example:
-- Return our current total open pipeline by region.
-- Opportunities are only considered pipelines if they are tagged as such.
SELECT
a.region__c AS `Region`,
sum(o.amount) AS `Open Pipeline`
FROM
sales.crm.opportunity o
JOIN sales.crm.accounts a ON o.accountid = a.id
WHERE
o.forecastcategory = 'Pipeline' AND
o.stagename NOT ILIKE '%closed%'
GROUP BY ALL;
Add parameters in SQL queries
Parameters let you write example queries with placeholders for specific values to be substituted at runtime. With parameters, Genie can take specific inputs from user questions and reuse the structure of an example query to provide verified answers as trusted assets. For example, you could adjust the previous SQL query to include a parameter that filters by the o.forecastcategory
value, enabling the query to address questions about opportunities tagged in different forecast categories. For more information about how to use parameterized queries to generate responses labeled as trusted assets, see Use trusted assets in AI/BI Genie spaces.
The following code snippet shows the previous example, modified by adding a parameter for the o.forecastcategory
value. Parameters use the same syntax as named parameter markers. See Named parameter markers.
-- Return our current pipeline at a stage by region.
-- Opportunities are only considered pipelines if they are tagged as such.
SELECT
a.region__c AS `Region`,
sum(o.amount) AS `Open Pipeline`
FROM
sales.crm.opportunity o
JOIN sales.crm.accounts a ON o.accountid = a.id
WHERE
o.forecastcategory = :forecast_category AND
o.stagename NOT ILIKE '%closed%'
GROUP BY ALL;
To add a parameter to a query:
Place your cursor where you want to place the parameter in your query.
Click Add parameter to insert a new parameter.
This creates a new parameter with the default name
parameter
. To change the default name, replace it in the query editor. You can also add parameters by typing a colon followed by a parameter name (:parameter_name
) into the editor.
Edit a query parameter
To edit a parameter, do the following:
Click next to the parameter name. A Parameter details dialog appears and includes the following configuration options:
Keyword: The keyword that represents the parameter in the query. The keyword can only be changed by directly updating the text in the query.
Display name: The human-readable name that Genie uses in the chat experience. When Genie generates a response using a parameterized query, it includes the display name and associated value in the response.
Type: Supported types include String, Date, Date and Time, and Numeric.
The default type is String.
The Numeric datatype allows you to specify between Decimal and Integer. The default numeric type is Decimal.
Note
If the actual input value does not match the selected parameter type, Genie treats the input value as the incorrect type, which can lead to inaccurate results.
Click another part of the UI to close the dialog.
SQL functions
SQL functions are custom functions that are stored in Unity Catalog and used by Genie to answer specific questions. Genie can call these functions and insert any user-specified parameters but cannot access the underlying SQL content. That means that SQL functions are ideal for answering common specific questions that include complex arguments or calculations that Genie should not be able to access or edit. For guidance on registering a function in Unity Catalog, see Create a SQL table function and User-defined functions (UDFs) in Unity Catalog.
Test your Genie space
Most user interactions take place in the chat window. The best way to learn if your space is working as you want it to is to test it with realistic questions that you expect your business users to ask.
Any sample questions you entered in settings appear in the chat window. These sample questions help users understand what questions they can ask their Genie space. The text field, where users input questions, is near the bottom of the screen.
Responses appear above the text field. After a user enters a question, it is saved to a chat history thread in the left pane.
To start a new chat:
Click the chat icon to open the chat window.
Type your question into the Ask your question… text entry field. To start a new conversation thread, click New chat.
Review responses
Responses are typically delivered as a natural language answer to the questions and a table showing the relevant result set. The precise response structure varies based on the question. All responses include the SQL query that was generated to answer the question. Click Show generated code to view the generated query.
The lower-right side of the response includes optional actions. You can copy the response CSV to your clipboard, download it as a CSV file, add it as an instruction for the Genie space, and upvote or downvote the answer.
A set of Quick actions tiles follow responses that include tabular data. You can use them to generate visualizations.
You can also generate a visualization by describing it in words after getting a query result. See Generate visualzations.
Format results
To format a column in a table within a response, click the kebab menu in the column header, then click Format to view the available options. Formatting options depend on the column’s data type.
Download the result set
Space users can download up to approximately 1GB of results data as a CSV. The final file download size might be slightly more or less than 1GB, as the 1GB limit is applied to an earlier step than the final file download. To download results, click the download icon in the response.
Generate visualzations
Users can explicitly request a visualization using the chat window, or by using one of the suggested visualizations provided in the Quick actions section that follows a response. Sometimes, Genie offers a visualization as part of a response. You can edit visualizations in the chat window.
The following chart types are supported:
Area
Bar
Line
Pie
Scatter
To edit a visualization:
In the upper-right corner of the visualization, click the edit icon. An editing pane opens on the right side of the page.
Use the Visualization drop-down menu to choose a different chart type.
For most chart types, use the X axis and Y axis drop-down menus to choose the values represented on each axis. For Pie charts, use the Angle drop-down menu to choose the column you want to represent.
(Optional) To customize the color scheme, click the + in the Color category.
(Optional) To select data to show in the tooltip when you hover over the visualization, click the + in the Tooltip section.
Provide response feedback
Each AI/BI Genie response includes a thumbs-up or thumbs-down feedback button. Databricks recommends encouraging users to provide feedback on the space using this mechanism.
For a response that includes query results, users can request that it be reviewed by a Genie space editor by clicking the . If a user has questions about the quality or accuracy of a generated response, they can mark it for review and, optionally, add their comment or question.
Business users can view updates to the questions they’ve marked for review on their History page. Users with at least CAN MANAGE permission on the Genie space can review the specific exchange, comment on the request, and confirm or correct the response. They can access feedback and review requests on the monitoring page. Then you can use that feedback to tune responses and iterate on your space. See Review history and feedback.
Review history and feedback
A Genie space is meant to be a continuous collaboration tool for data teams and business users to accumulate knowledge, not a one-time deployment. Understanding the new questions that business users need answers to is essential for knowledge building. On the history page, you can view individual questions and responses, thumbs-up or thumbs-down feedback provided by users, and questions marked for review. To open the history page, click History in the Genie space sidebar.
The history page shows all of the questions and answers that have been asked in the space. You can filter questions by time, rating, user, or status. By monitoring the space, Genie space editors can proactively understand the queries raised by business users and how the Genie space responded.
By identifying the questions that Genie struggles with, you can update the Genie space with specific instructions to improve its responses. Click a question to open the question and response text. You can also access the complete chat thread from this view.
Edit generated SQL
You can review and edit the generated SQL in any response. Genie space authors typically know the domain and data that allows them to recognize when Genie is generating an incorrect answer. Often, errors can be fixed with a small amount of manual tuning to the generated SQL query. To view the generated SQL for any response, click Show generated code to inspect the query.
You can edit the generated SQL statement to correct it if you have CAN EDIT or greater privileges on the Genie space. After you’ve made your corrections, run the query. Then, you can save it as an instruction to teach Genie how to answer in the future. To save your edited query, click Save as instruction.
Clone a Genie space
Cloning a Genie space creates a copy, including all setup context and instructions. This is helpful if you have a well-developed space and want to create a new space for additional testing or reuse the context from the original space. After a space is cloned, the new space is independent of the original, allowing you to make edits and adjustments without impacting the original.
The following elements are copied to a cloned Genie space:
Tables and settings
General instructions
Example SQL queries
SQL functions
Existing chat threads and History data are not copied to the new space.
To clone a Genie space, do the following:
Open the Genie space you want to clone.
Click the kebab menu in the upper-right corner of the space.
Click Clone.
(Optional) In the Clone dialog, specify a new name and workspace folder location for the cloned Genie space.
Click Clone to create the new space.
Best practices for space preparation
For guidance about best practices and help with troubleshooting issues, see Curate an effective Genie space.
Monitor usage
You can use audit logs to monitor usage of your Genie space. See AI/BI Genie events