Databricks - Gen AI Engineer Associate Study Guide

    3: Application Development

    This chapter assembles a working generative AI application on Databricks from the design contract of Chapter 1 and the retrieval pipeline of Chapter 2. It walks through orchestration framework selection, model selection from hubs and marketplaces, qualitative response assessment, chunking decisions driven by retrieval evaluation, prompt augmentation, prompt engineering for behavior shaping, guardrail implementation, multi-agent data access via Genie Spaces, and embedding-model sizing, anchored throughout to MLflow and the Mosaic AI Agent Framework.

    Learning Objectives

    By the end of this chapter, you will be able to:

    • Select LangChain or an alternative orchestration tool for a generative AI application, including reading model metadata from a model hub or marketplace.
    • Qualitatively assess responses for quality and safety issues, and pick the best model for a task based on metrics produced in MLflow experiments.
    • Select a chunking strategy from model and retrieval evaluation evidence, and use MLflow and the Mosaic AI Agent Framework to develop agentic systems.
    • Augment a prompt with additional context extracted from user input, and compare the evaluation and monitoring phases of the Gen AI application lifecycle.
    • Create a prompt that shifts an LLM response from a baseline to a desired output, and enable multi-agent systems to read data via Genie Spaces or the conversational API.
    • Implement input and output guardrails to prevent negative outcomes including toxicity, jailbreaks, PII leakage, and off-topic drift.
    • Select the best LLM for an application by matching model attributes (cost, latency, context, tool-calling, multimodality, license) to application requirements.
    • Select an embedding-model context length based on source documents, expected queries, and the optimization strategy.

    Executive Summary

    • Orchestration on Databricks centers on the Mosaic AI Agent Framework. LangChain, LlamaIndex, DSPy, AutoGen, and raw Foundation Model API calls are supported authoring styles that all log to MLflow through a ChatAgent or ResponsesAgent wrapper.
    • Model selection is an evidence-driven process: read the model card, run a fixed eval set through mlflow.evaluate, and decide on a weighted score of accuracy, safety, latency, cost, and license.
    • A prompt has two jobs in a production application: it shifts the base model from a default behavior to the desired behavior, and it absorbs context extracted from user input or retrieved from a vector store.
    • Guardrails compose in layers: AI Gateway input policies, prompt-side instructions, output classifiers (Llama Guard, Meta Prompt Guard), PII masking, and topic restrictions. None of them is sufficient alone.
    • Evaluation and monitoring are different phases of the same scoring loop. Evaluation runs on a static ground-truth eval set before a release. Monitoring runs on the live request stream after release and writes to Inference Tables and Agent Monitoring.

    Assumptions

    • The reader has built the retrieval pipeline from Chapter 2 and has a Mosaic AI Vector Search index registered in Unity Catalog with a known embedding model.
    • Foundation Model API pay-per-token and provisioned throughput endpoints are available in the workspace region.
    • All terms defined in Chapters 1 and 2 (chain, retriever, prompt template, output parser, chunk, recall@k, MRR, evaluation set, Agent Bricks, Mosaic AI Agent Framework, Foundation Model APIs) are used without re-definition.

    Sections in this chapter

    1. Free
    2. Free with account
    3. Free with account
    4. Free with account
    5. Free with account
    6. Free with account
    7. Free with account
    8. Free with account
    9. Free with account