Advanced Prompting Techniques¶
-
Basic Approaches
Zero-shot and few-shot techniques for immediate improvements
-
Reasoning Methods
Techniques to improve model reasoning and problem-solving
-
Verification
Methods for self-assessment and correction
-
Collaboration
Ensemble techniques for aggregating multiple model outputs
This guide presents 58 research-backed prompting techniques mapped to Instructor implementations. Based on The Prompt Report by Learn Prompting which analyzed over 1,500 academic papers on prompting.
Prompting Technique Map¶
The following diagram shows how different prompting techniques relate to each other and when to use them:
flowchart TD
A[Choose Prompting Technique] --> B{Have Examples?}
B -->|No| C[Zero-Shot Techniques]
B -->|Yes| D[Few-Shot Techniques]
C --> C1[Role Prompting]
C --> C2[Emotional Language]
C --> C3[Style Definition]
C --> C4[Follow-Up Generation]
D --> D1[Example Ordering]
D --> D2[Example Selection]
D --> D3[Example Generation]
A --> E{Need Reasoning?}
E -->|Yes| F[Thought Generation]
F --> F1[Chain of Thought]
F --> F2[Step-Back Prompting]
F --> F3[Thread of Thought]
A --> G{Complex Problem?}
G -->|Yes| H[Decomposition]
H --> H1[Least-to-Most]
H --> H2[Tree of Thought]
H --> H3[Plan and Solve]
A --> I{Need Verification?}
I -->|Yes| J[Self-Criticism]
J --> J1[Self-Verification]
J --> J2[Chain of Verification]
J --> J3[Self-Refinement]
A --> K{Want Multiple Perspectives?}
K -->|Yes| L[Ensembling]
L --> L1[Self-Consistency]
L --> L2[Meta-CoT]
L --> L3[Specialized Experts]
classDef category fill:#e2f0fb,stroke:#b8daff,color:#004085;
classDef technique fill:#d4edda,stroke:#c3e6cb,color:#155724;
classDef decision fill:#fff3cd,stroke:#ffeeba,color:#856404;
class A,C,D,F,H,J,L category
class C1,C2,C3,C4,D1,D2,D3,F1,F2,F3,H1,H2,H3,J1,J2,J3,L1,L2,L3 technique
class B,E,G,I,K decision When to Use Each Technique¶
| Goal | Recommended Techniques |
|---|---|
| Improve accuracy | Chain of Thought, Self-Verification, Self-Consistency |
| Handle complex problems | Decomposition, Tree of Thought, Least-to-Most |
| Generate creative content | Role Prompting, Emotional Language, Style Definition |
| Verify factual correctness | Chain of Verification, Self-Calibration |
| Optimize with few examples | KNN Example Selection, Active Prompting |
| Handle uncertainty | Uncertainty-Routed CoT, Self-Consistency |
Zero-Shot¶
These techniques improve model performance without examples:
Few-Shot¶
Techniques for effectively using examples in prompts:
Thought Generation¶
Methods to encourage human-like reasoning in models:
Zero-Shot Reasoning¶
Few-Shot Reasoning¶
Ensembling¶
Techniques for combining multiple prompts or responses:
Self-Criticism¶
Methods for models to verify or improve their own responses:
Decomposition¶
Techniques for breaking down complex problems:
Implementation with Instructor¶
All these prompting techniques can be implemented with Instructor by:
- Defining appropriate Pydantic models that capture the expected structure
- Incorporating the prompting technique in your model docstrings or field descriptions
- Using the patched LLM client with your response model
import instructor
from pydantic import BaseModel, Field
# Example implementing Chain of Thought with a field
class ReasonedAnswer(BaseModel):
"""Answer the following question with detailed reasoning."""
chain_of_thought: str = Field(
description="Step-by-step reasoning process to solve the problem"
)
final_answer: str = Field(
description="The final conclusion after reasoning"
)
client = instructor.from_provider("openai/gpt-6-luna")
response = client.create(
model="gpt-6-luna",
response_model=ReasonedAnswer,
messages=[
{"role": "user", "content": "What is the cube root of 27?"}
]
)
print(f"Reasoning: {response.chain_of_thought}")
print(f"Answer: {response.final_answer}")
References¶
* Based on The Prompt Report: A Systematic Survey of Prompting Techniques