Prompt Engineering Techniques Techniques for crafting effective prompts for foundation models
Prompting Strategies
| Technique | Description | Best For |
|---|
| Zero-shot | Task description only, no examples | Simple, well-understood tasks |
| Few-shot | 2–10 labeled examples in prompt | Tasks requiring format or style guidance |
| Chain-of-thought (CoT) | Prompt model to reason step-by-step | Multi-step reasoning, math, logic |
| System prompt | Sets persona, constraints, tone | Consistent behavior across turns |
| Retrieval augmentation | Inject relevant docs into context | Grounding responses in factual data |
| ReAct | Reason + Act interleaved | Agentic workflows with tool calls |
Inference Parameters
- Temperature (0–1): Higher = more creative/random; Lower = more deterministic
- Top-P (nucleus sampling): Cumulative probability threshold for token selection
- Top-K: Restrict sampling to top-K most probable tokens
- Max tokens: Maximum length of generated response
- Stop sequences: Strings that halt generation when encountered
Exam Focus Areas
- Temperature=0 for deterministic outputs (classification, extraction)
- Temperature=0.7–1.0 for creative tasks (content generation, brainstorming)
- System prompt is the most effective way to enforce consistent model behavior
- Prompt injection: User input that overrides system instructions — mitigate with Guardrails