7 Contextual Prompting
This chapter covers
- Explaining In-Context Learning as the mechanism behind Few-Shot Prompting, and distinguishing it from fine-tuning
- Deciding when to use Zero-Shot Prompting versus Few-Shot Prompting based on task fit, consistency needs, and token cost
- Applying few-shot examples to classification, structured extraction, and domain-specific workflows with reliable output formatting
- Designing few-shot examples for format consistency, content diversity, edge-case coverage, and label coverage tradeoffs
Chapters 2 through 6 established the building blocks of prompt design: Structural Elements, Linguistic Elements, Prompt Patterns, Prompt Templates, and Prompt Types.
This chapter introduces Contextual Prompting: using information inside the prompt to guide the model's behavior for a specific request. You will compare instruction-only prompts with example-driven prompts, then learn how to design examples that improve consistency without adding unnecessary token cost.
Section 7.1 explains the mechanism behind this behavior. Section 7.2 establishes Zero-Shot Prompting as the baseline. Section 7.3 develops Few-Shot Prompting in depth: when to use it, how to apply it to classification and extraction tasks, how to keep examples consistent in format, and how to select examples that cover the most important cases and boundaries. Chapter 8 then builds on this foundation with Prompt Sampling techniques for higher output reliability.