Skip to content

Spotting batch inference workloads and applying ai_query() to them

Batch inference means scoring large sets of records offline (e.g., in a Delta table) rather than serving real-time requests one at a time. Databricks lets you run this directly in SQL or Spark using the ai_query() function, which invokes a model serving endpoint against each row of a table. This avoids building custom pipelines for calling LLMs or ML models over large datasets.

1 · Learn the must-know

  • ai_query() is a built-in SQL function that sends each row of a query as input to a specified model serving endpoint and returns the model's response as a column, making it ideal for batch scoring within Databricks SQL, notebooks, or jobs.
  • It works with both foundation model endpoints (e.g., for embeddings, chat/completions) and custom or fine-tuned model serving endpoints, as long as the endpoint accepts the request format ai_query() sends.
  • Because it runs at scale over Spark/SQL, ai_query() is well suited for batch inference workloads like classifying large tables, generating embeddings for RAG pipelines, or summarizing many documents at once—not for low-latency, single-record real-time serving.
  • You should be mindful of endpoint throughput/concurrency limits and cost, since applying ai_query() over millions of rows can generate a very large number of endpoint calls.
  • ai_query() can be embedded directly in a Delta Live Tables or Lakeflow pipeline, or scheduled as part of a Databricks job, enabling repeatable batch inference workflows.
  • Unlike real-time model serving (used for interactive apps needing millisecond responses), batch inference via ai_query() is appropriate when latency is not critical and throughput over large datasets matters more.

2 · Check your understanding

Check this objectiveFree · always available

A data platform team is reviewing four proposed GenAI workloads to decide which one should be scheduled as a nightly Databricks job using ai_query() against a Delta table, instead of being served through a real-time Model Serving endpoint. Which workload fits this batch pattern?

Your objective map0 tried · 0 answered correctly · 56 untouched

What you have tried across Databricks GenAI Engineer's objectives, not a readiness score.

Design Applications10.71% of the exam*0 of 6 tried
Data Preparation14.29% of the exam*0 of 8 tried
Application Development23.21% of the exam*0 of 13 tried
Assembling and Deploying Applications26.79% of the exam*0 of 15 tried
Governance7.14% of the exam*0 of 4 tried
Evaluation and Monitoring17.86% of the exam*0 of 10 tried

* Our estimate. Databricks publishes no section weights.

3 · Keep going