Prompt Engineering Techniques: From Zero-Shot to Chain-of-Thought
Summary
Prompt engineering is the set of techniques for crafting instructions for LLMs to achieve desired outcomes without changing model weights. Learn more in the glossary.
Basic Approaches
Zero-Shot Prompting
The model receives only the instruction without examples. Suitable for simple tasks such as classification and fact extraction. Learn more in the glossary.
Few-Shot Prompting
A few examples (usually 2–5) with correct answers are added to the prompt. The model learns from them in context. Learn more in the few-shot article.
Role Prompting
The model is assigned a role: "you are an SQL expert," "you are an editor." The role sets the style and boundaries of the response. Learn more in the glossary.
Advanced Techniques
Chain-of-Thought (CoT)
The model is asked to reason step-by-step before responding. Improves results in logic and math tasks. Learn more in the CoT article.
Self-Consistency
Multiple reasoning chains are generated, and the most frequent response is selected. Increases reliability. Learn more in the glossary.
Tree of Thoughts
The model considers several reasoning branches and selects the best one. Learn more in the glossary.
Technique Comparison
| Technique | Complexity | Improvement | Token Cost |
|---|---|---|---|
| Zero-Shot | Low | Basic level | Low |
| Few-Shot | Medium | +10–30% | Medium |
| Role Prompting | Low | +5–15% | Low |
| Chain-of-Thought | Medium | +20–50% on logic | High |
| Self-Consistency | High | +5–15% to CoT | Very high |
Practical Recommendations
- Start with zero-shot — if the result is satisfactory, do not complicate.
- Use a system prompt to set the role and constraints. Learn more in the system prompt article.
- Formulate instructions explicitly — specify the response format, constraints, and criteria.
- Test on a validation set — prompts need to be tested on various examples.
Limitations
Prompt engineering does not replace fine-tuning for tasks requiring new knowledge or a stable format. The effectiveness of techniques depends on the model: newer models handle zero-shot better.
Prompt templates and versioning are used to systematize prompts.