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
ChatAgentorResponsesAgentwrapper. - 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.
