The prompting playbook

Share

Summary

This video discusses best practices for prompting large language models (LLMs), focusing on two scenarios: maintaining an existing prompt and building a new agent from scratch. It emphasizes the importance of evaluations, structured prompting, providing tools for calculations, and balancing trade-offs in instructions to achieve desired model behavior.

Highlights

Introduction to Prompting Best Practices
00:00:20

Margo van Laar, an applied AI engineer at Anthropic, introduces the essential skill of prompting for effective AI systems. The session will cover best practices for two scenarios: refining existing production prompts and building new agentic use cases from the ground up.

Understanding Prompt Issues and the Role of Evaluations
00:02:14

The speaker illustrates common problems with complex, collaborative prompts, such as conflicting instructions and legacy patches. The solution begins with rigorous evaluations (evals) to measure prompt performance, differentiate between model capabilities and behavior, and test for regressions during model migration.

Setting Up an Evaluation Suite with Key Test Cases
00:03:56

An effective eval suite needs control cases (expected to pass), edge cases (where the model previously failed), and refusal cases (where the model should hand off to a human or refuse to answer). An example is presented using a customer support bot for a Telco company with five specific test cases.

Initial Prompt Cleanup and General Hygiene
00:06:07

Before detailed debugging, general prompt hygiene is applied. This includes clarifying the bot's role (removing 'human' designation), removing irrelevant information (like website-specific text), and structuring instructions with XML tags to separate policy, guidelines, and tone. This leads to an immediate improvement in model performance.

Ensuring Output Consistency with an Output Contract
00:11:27

A key best practice for consistent output format is to define an 'output contract'. For conversational bots, this might involve specifying XML tags for responses. For more complex structures like nested JSONs, using structured outputs and API stop sequences (to detect closing tags) can ensure consistency and prevent parsing errors.

Addressing the Hotspot Data Failure Mode (Withholding Information)
00:13:48

The model was deflecting inquiries about hotspot data for legacy plans, even when the information was available. This was due to an overfitted instruction from a previous model patch. The fix involves providing a balanced view in the prompt, emphasizing accuracy from customer-specific data over general policy, and tracking reasons for defensive changes through version control.

Solving Proration Calculation Issues with Tools
00:17:31

The model failed to perform accurate proration calculations. The initial prompt instructions to 'do a good job' or 'calculate correctly' were insufficient. The solution was to provide the model with a 'calculate proration tool', defining its schema and implementing the underlying math. This demonstrates that instructions don't add capability; tools do.

Correcting Billing Error Escalation Behavior
00:20:25

The bot was failing to escalate billing errors to a human, instead attempting to self-diagnose. This was caused by an instruction that emphasized the cost of escalation without mentioning the cost of getting it wrong. The fix involves presenting both sides of the trade-off, allowing the model to make more informed decisions, especially as models become more intelligent.

Building a New Agent from Scratch: Retail Staff Schedule Case Study
00:23:34

The second scenario involves building a new agent, a retail staff scheduler, from scratch. The evaluation uses hard rules checked by a Python function. The talk explores how model choice, prompt complexity, and thinking strategies impact performance.

Exploring Different Approaches for Agent Building
00:25:09

Initial attempts with a simple prompt and a smaller model (Sonnet 4.6) result in many violations. Switching to a larger, more capable model (Opus 4.7) reduces violations but doesn't eliminate them. Using Opus with adaptive thinking (allowing it to decide how much reasoning to use) reliably generates compliant schedules but increases token usage and latency.

Optimizing Cost, Latency, and Performance with Agentic Loops
00:28:31

Further attempts involve improving the Sonnet 4.6 prompt with more reasoning instructions, but this still faces token limits. The most effective approach is an agentic generate-evaluate-repair loop, where a generator creates a draft, a separate LLM evaluates violations, and a repair prompt makes targeted fixes. This method achieves high compliance with lower token usage and latency, offering flexibility for soft constraints at runtime.

Conclusion and Key Takeaways
00:32:16

The presentation concludes by summarizing the learnings: applying general hygiene principles provides initial uplift, evals are crucial for rigor, targeting failure modes systematically improves performance, and agentic loops can solve complex problems efficiently by splitting tasks across multiple prompts and leveraging model capabilities effectively.

Recently Summarized Articles

Loading...