اشتراک یکساله با 45 درصد تخفیف به مدت محدود فعال شد. 3 فصل اول تمامی کتاب ها رایگانه!

Production LLM system design

Chapters
15 Flashcards
10 Gallery cards
40 Audio
15 Prompts
15 Glossary

Ready to move your Large Language Model (LLM) from a promising prototype to a robust production system? This chapter is your essential guide to the operational discipline required for deploying LLM applications reliably and at scale. We'll dive deep into the unique challenges generative AI presents, moving beyond traditional machine learning practices to embrace new paradigms for testing, monitoring, and safety. The core problem we address is the inherent nondeterminism and complexity of LLMs, which traditional ML engineering practices often overlook. Unlike deterministic models, LLM outputs can vary, making standard validation and monitoring insufficient. This chapter equips you with the strategies and tools to manage this unpredictability, ensuring your LLM applications are not just functional, but also safe, efficient, and cost-effective in a live environment. Prompt engineering is reimagined as a critical development practice, akin to writing code. We'll explore treating prompts not as mere text inputs, but as essential pieces of infrastructure that require version control, rigorous testing, and careful management. This is crucial because subtle changes in prompts can drastically alter an LLM's behavior, leading to unexpected outputs or security vulnerabilities like prompt injection (see Figure 13.1 and 13.2). Tools like Langfuse help manage these prompts effectively in production, allowing for tracking, versioning, and debugging, which is vital for maintaining application stability and performance. Testing LLM applications demands a new approach due to their probabilistic nature. We introduce an evaluation framework designed to handle nondeterministic responses, moving beyond simple accuracy metrics. This includes developing strategies for safety and adversarial testing to proactively identify and mitigate vulnerabilities. Imagine trying to trick your LLM assistant into revealing sensitive information or performing actions outside its intended scope; adversarial testing simulates these attacks, as demonstrated in reports from tools like Promptfoo (Figure 13.3, 13.4, 13.5), ensuring your system is resilient. Governance and safety in production are paramount. We delve into implementing safety guardrails—multilayered systems that filter inputs, monitor LLM processing, and validate outputs (Figure 13.6). These guardrails, potentially utilizing tools like Guardrails AI (Figure 13.7, 13.8), act as crucial checks to prevent harmful content, protect Personally Identifiable Information (PII) (Figure 13.9), and enforce business logic, thereby preventing issues like unintended competitor mentions (Figure 13.10). Finally, we tackle cost optimization strategies, a critical aspect of running LLMs at scale. This involves understanding LLM economics, making informed model selection decisions based on performance and cost, implementing effective caching strategies to reduce redundant computations, and performing prompt optimization for efficiency. The transition from traditional ML to LLMOps is highlighted, emphasizing the need for specialized workflows and monitoring for cost and performance in production environments. The key trade-off lies between the flexibility and power of LLMs and the need for control, predictability, and cost-efficiency in production. Achieving robust performance often requires careful balancing of model capabilities against stringent safety measures and optimized resource utilization. As a takeaway, you can now: [ ] Implement version control for your LLM prompts. [ ] Design and execute adversarial tests to uncover vulnerabilities. [ ] Integrate safety guardrails into your LLM application pipeline. [ ] Select appropriate LLM models based on cost and performance requirements. [ ] Apply caching and prompt optimization techniques to reduce operational costs. [ ] Monitor LLM application costs and performance in production.

Chapter

1

Cover of Machine Learning Platform Engineering
Manning Publications

Chapter 13 of Machine Learning Platform Engineering: Production LLM system design

Book release

Published

Sections

Part 4: Extending MLOps for Large Language Models

Chapter 13 progress
Book progress

Reading time

00:41

Gallery

Yes

Audio status

Preview

Analysis

AI