Deployment

How do batch, streaming, and real-time inference differ?


  • Batch inference: Processes many records together on a schedule; typically high throughput but results arrive later. Useful for overnight classification, scoring, or document enrichment.
  • Streaming inference: Processes continuously arriving data, often in micro-batches; balances throughput with near-real-time updates. Useful for event processing.
  • Real-time inference: Responds to individual requests through an endpoint; prioritises low latency. Best for interactive chatbots, agents, and RAG applications.
  • Latency is the time one request takes; throughput is the number of requests processed per unit of time. Increasing concurrent requests may improve throughput until resource limits cause queuing and higher latency.
  • Choose the approach based on the application’s response-time requirements, traffic, cost, and whether results must be returned immediately.

What does Mosaic AI Model Serving provide?


  • Deploys models or agents behind an HTTPS endpoint callable from applications, notebooks, SQL, or jobs.
  • Supports custom registered models, Databricks-hosted foundation models, and connections to supported external models, although capabilities vary by endpoint type.
  • Provides a common serving interface with governance and operational features such as authentication, usage monitoring, and configurable scaling.
  • Depending on endpoint type and workspace features, options may include request/response logging, guardrails, rate limits, traffic splitting for A/B testing, and monitoring.
  • Use Unity Catalog and appropriate endpoint permissions to govern access to registered models and serving endpoints.

How do you deploy a registered RAG model?


  • First register the tested RAG chain or agent in the Unity Catalog Model Registry; registration versions the model but does not automatically make it callable over an endpoint.
  • In Catalog Explorer, locate the registered model and its version, then use the serving/deployment action; alternatively open Serving → Create serving endpoint and select the model version.
  • Choose an endpoint name, compute configuration, and available scaling options. For the course’s Databricks Free Edition, enable Scale to zero where supported to minimise resource use and comply with endpoint limits.
  • Create the endpoint and wait until its status is Ready before sending requests. Provisioning and model loading can take time.
  • Course note: The setup notebook already deployed the RAG endpoint. Inspect and use that endpoint rather than creating a duplicate, especially in Free Edition.
  • A deployed endpoint is a snapshot of the selected model version/configuration; registering a new model version does not automatically update an existing endpoint.

How do you query the deployed model from SQL?


  • Find the exact endpoint name under Serving and verify it is Ready.
  • Run ai_query() in a SQL notebook or SQL editor using an available SQL warehouse. For an endpoint that accepts a simple text input, the pattern is:
SELECT ai_query(
  'YOUR_SERVING_ENDPOINT_NAME',
  'Which products are suitable for a beginner?'
) AS response;
  • Important: Custom RAG/agent endpoints may require a structured JSON request matching their serving schema, rather than a plain string. Inspect Serving → endpoint → Query / Use → Example code for the exact payload format before adapting the query.
  • ai_query() allows SQL notebooks, dashboards, and jobs to call the same endpoint; it does not create a new endpoint for each request.
  • Callers require the necessary endpoint permissions and supported compute/runtime configuration. Handle errors, timeouts, and potentially sensitive prompts or outputs appropriately.

How do you collect feedback and improve a deployed RAG app?


  • Agent Framework deployments can include a Review App for subject-matter experts or testers to inspect answers and submit human feedback; availability depends on the deployment workflow.
  • Use feedback alongside MLflow traces and evaluation results to identify incorrect answers, poor retrieval, slow responses, and unexpected tool/model behaviour.
  • Monitor quality after launch, not only during development; changing documents, prompts, or model versions can alter results.
  • Re-evaluate candidate versions against representative questions before updating the serving endpoint.
  • For production, consider authentication, least-privilege data access, rate limits, cost monitoring, error handling, and logging policies.

What problems should you check when serving or querying fails?


  • Endpoint not ready: Wait for provisioning/model loading; inspect endpoint events and logs.
  • Slow first request: Scale-to-zero endpoints may need approximately 30 seconds to warm up after being idle (actual time varies).
  • Resource or quota error: Check Free Edition endpoint caps; reuse the endpoint created during setup instead of deploying another.
  • Invalid request: Compare the ai_query() input against the endpoint’s expected request schema; text and agent-style JSON payloads are not interchangeable.
  • Permission denied: Confirm permission to query the endpoint, access the SQL warehouse, and use any underlying resources the RAG app needs.
  • Poor answers: Inspect retrieved documents, prompts, MLflow traces, and evaluation metrics rather than assuming deployment itself caused the issue.

Where is the official documentation?