Develop, tune and evaluate generative AI applications
Build the evaluation set before tuning
Generative AI development is iterative: prompt, evaluate, inspect failures, then change data, prompt, retrieval, or model. Create a small, representative evaluation set with expected answers or rubrics plus edge cases. Use MLflow evaluation to score retrieval and generation separately: retrieval recall and precision, answer correctness, groundedness or faithfulness, relevance, and safety. LLM-as-a-judge scales well but must be calibrated with human labels; keep a human-reviewed subset.
Tuning options
Prompt engineering (instructions, few-shot examples, output format), retrieval tuning (chunk size, k, filters, reranking), and model tuning (fine-tuning or LoRA) are progressively more expensive. Fine-tuning teaches style, format, and domain behavior; it does not reliably add fresh facts, so use RAG for knowledge. For agents, use agent evaluation with traces to inspect tool calls, retrieval steps, and failure points.
Traps
- Judging with the same model and prompt that produced the answer without a rubric, creating self-preference bias.
- Tuning before establishing a baseline, so improvement cannot be attributed.
- Leaking evaluation questions into training or few-shot examples.
- Optimizing fluency while groundedness drops.
- Reporting one aggregate score; segment results by question type.
Rule of thumb
Baseline first, change one variable at a time, and require both a quality gain and no safety regression before shipping. Example: if groundedness is low but retrieval recall is high, the prompt is likely ignoring context; if recall is low, fix chunking or increase k.