Overview
Prompt engineering is the practice of designing and refining inputs to language models to elicit desired outputs. It encompasses system prompts that establish behavior and constraints, user prompts that specify tasks, and few-shot examples that demonstrate expected patterns. Effective prompts are specific, structured, and provide the model with sufficient context to produce accurate results. As models have grown more capable, prompt engineering has evolved from simple instruction-writing to sophisticated context engineering — managing what information the model sees and when.
Key Concepts
- System prompts — Instructions that define the model’s role, constraints, and output format. Set once per conversation.
- Few-shot examples — Providing input-output pairs that demonstrate the desired behavior. More reliable than zero-shot for structured tasks.
- Temperature and sampling — Parameters that control output randomness. Lower temperature for factual tasks, higher for creative ones.
- Structured output — Requesting JSON, XML, or other machine-parseable formats. Reduces post-processing and improves reliability.
- Context engineering — The broader discipline of managing what information enters the model’s context window, including retrieval, summarization, and prioritization.
- Prompt injection — Security concern where user input overrides system instructions. Requires input sanitization and architectural mitigations.
Trade-offs
- Verbose prompts improve accuracy but consume context window space
- Few-shot examples increase token cost per request
- Prompt techniques that work on one model may not transfer to another
- Over-constrained prompts can reduce model creativity and problem-solving
Related
- Chain-of-Thought is a specific prompting technique for complex reasoning
- Context Windows constrain how much information a prompt can include
- Tool Use extends what prompts can accomplish beyond text generation