Benchmark a Genie agent against trusted answers
Curate inputs and instructions, verify trusted assets, grant access and evaluate answer quality.
Benchmark a Genie agent against trusted answers
Work through the decision
A Genie agent answers “net ticket sales” using gross receipts. The generated SQL is valid and runs successfully. A product manager suggests rating it correct because it returned an answer quickly. What test would detect the business error?
Check your reasoning
Ask the finance owner to define net sales, the accounting period, refunds and excluded records. Add curated governed tables or views, source descriptions and vetted query logic to the agent. Benchmark against expected results for refund, no-refund and boundary-date cases. Record question, expected answer and observed differences before and after the change.
Compare the choices
- Curated source set
- Limit inputs to documented, relevant governed assets at a known grain. Exclude ambiguous obsolete definitions and configure appropriate compute.
- Business instructions
- Define vocabulary, time conventions, join rules and exclusions. Ask the owner to resolve contradictory definitions.
- Trusted SQL asset
- Vet a parameterized query or supported expression for an important question and maintain it with its business owner.
- Known-answer benchmark
- Evaluate actual answers against reference outputs across representative and difficult cases. Re-run after changing sources, instructions or metadata.
- Distribution and access settings
- Grant only required space, data and compute privileges and test the destination interface as an authorized viewer.
Test the decision
Look at question history and feedback to prioritize misunderstandings, then test on cases beyond the exact training examples. Refresh metadata after data contracts change. Test the actual audience permissions and warehouse access before embedding or distributing the agent.
Run a known-answer test in Genie
In the agent’s monitoring and benchmark workflow, enter a representative business question and its reviewed SQL answer. Run the benchmark and inspect the generated SQL and result for mismatches. Edit the business instructions or trusted asset, then rerun the same questions on comparable data. Use the feedback queue to identify new questions for the suite.
Databricks · Test and monitor a Genie agent
Practice the guide skills
- Explain what an AI/BI Genie agent can answer for the finance team. Watch 1:53:01 · Continue at 1:54:22
Check your answer
Define a bounded domain, curated tables and measures, business instructions and a warehouse. Users ask questions in natural language and should be able to inspect the generated query and supporting data.
- Build a trusted answer for daily net sales. Watch 1:55:13 · Continue at 1:56:24 · Continue at 1:56:47
Check your answer
State how returns affect the measure, select governed inputs, supply representative questions, vet the parameterized query and test known totals before promoting it as a trusted asset.
- Distribute a Genie agent to another team or channel. Watch 1:58:59 · Continue at 2:00:18 · Continue at 2:00:35
Check your answer
Grant access to the agent, compute and required data with the appropriate execution identity. Test the actual published entry point with a representative least-privileged user.
- Track regressions when column definitions change. Watch 2:01:02 · Continue at 2:02:08 · Continue at 2:02:35
Check your answer
Review question history and feedback, update metadata and trusted definitions, then rerun benchmark questions with approved answers. Record which cases changed and whether the business owner accepts the result.
Official objectives for this lesson
Lab · Test a Genie answer against trusted SQL
Use Python 3 and SQLite to model the result comparison in a Genie benchmark. The candidate queries are supplied examples of possible answers. No warehouse, Genie service or network connection is required. Finance defines net revenue as paid cents less refunds for completed sales. Predict which case fails for each query version.
import sqlite3
cases = [("north", 1200), ("south", 0), ("west", 800)]
gross = """
SELECT COALESCE(SUM(paid), 0) FROM tickets
WHERE depot = ? AND state = 'complete'
"""
net = """
SELECT COALESCE(SUM(paid - refunded), 0) FROM tickets
WHERE depot = ? AND state = 'complete'
"""
with sqlite3.connect(":memory:") as db:
db.executescript("""
CREATE TABLE tickets(depot TEXT, state TEXT, paid INTEGER, refunded INTEGER);
INSERT INTO tickets VALUES
('north', 'complete', 1000, 200), ('north', 'complete', 400, 0),
('south', 'canceled', 900, 0), ('west', 'complete', 800, 0);
""")
for version, query in [("gross", gross), ("net", net)]:
passed = 0
for depot, expected in cases:
actual, = db.execute(query, (depot,)).fetchone()
passed += actual == expected
if actual != expected:
print(version, depot, "expected", expected, "observed", actual)
print(version, "passed", passed, "of", len(cases))
Check the result
gross north expected 1200 observed 1400 gross passed 2 of 3 net passed 3 of 3
The canceled-only and no-refund cases pass even when the candidate ignores refunds. Including north exposes the error. Add a fully refunded completed sale in a fourth depot with expected net zero. In a real Genie agent, curate the definition and trusted SQL, run the questions against governed data, inspect failed answers and retain the accepted benchmark for later revisions.
Related lesson · Unity Catalog
Benchmark a Genie agent against trusted answers quiz
Answer 3 questions. Check each answer for an explanation.
Worked example · Benchmark a Genie agent against trusted answers