Prompts2026年4月1日·1 分钟阅读

Prompt Engineering Techniques — 20+ Methods

Comprehensive prompt engineering collection with 20+ techniques. 7.3K+ stars. Chain-of-Thought, ReAct, Tree-of-Thought, runnable notebooks.

PR
Prompt Lab · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

Pick a technique, copy the template, adapt to your task:

Chain-of-Thought (CoT):

Solve this step by step:
1. First, identify the key variables
2. Then, set up the equation
3. Finally, solve and verify

Problem: [your problem here]

ReAct (Reasoning + Acting):

Answer the following question by alternating between Thought, Action, and Observation steps.

Question: [your question]

Thought 1: I need to...
Action 1: Search for...
Observation 1: [result]
Thought 2: Based on this, I should...

Self-Consistency:

Generate 5 different solutions to this problem, then select the most common answer:

Problem: [your problem]

Solution 1: ...
Solution 2: ...
[Let the model generate multiple paths, then pick the majority]
介绍

This is a curated collection of 20+ prompt engineering techniques, each with explanations, templates, and runnable Jupyter notebooks. Covers:

Foundational:

  • Zero-Shot Prompting — No examples needed, just clear instructions
  • Few-Shot Prompting — Provide examples for the model to follow
  • Chain-of-Thought (CoT) — Step-by-step reasoning
  • Role Prompting — Assign an expert persona

Intermediate:

  • ReAct — Combine reasoning with tool use
  • Self-Consistency — Multiple reasoning paths, majority vote
  • Tree-of-Thought — Explore multiple solution branches
  • Least-to-Most — Break complex problems into sub-problems

Advanced:

  • Constitutional AI Prompting — Self-critique and revision
  • Meta-Prompting — Prompts that generate prompts
  • Automatic Prompt Engineering (APE) — Let the model optimize its own prompts
  • Prompt Chaining — Sequential prompts where output feeds input
  • Skeleton-of-Thought — Generate outline first, then fill in details

Each technique includes: concept explanation, when to use it, template, Python notebook, and real-world examples.

FAQ

Q: Which technique should I start with? A: Chain-of-Thought for reasoning tasks, Few-Shot for format-sensitive tasks, ReAct for tasks requiring external tool use.

Q: Do these work with all LLMs? A: Yes. These are model-agnostic techniques. They work with GPT-4, Claude, Gemini, Llama, Mistral, and any instruction-following LLM.

Q: Can I use these in production? A: Absolutely. Each technique is production-tested. The notebooks include evaluation metrics so you can measure effectiveness.

Works With

  • Any LLM: Claude, GPT-4, Gemini, Llama, Mistral
  • Claude Code, Cursor, Codex (for coding-specific prompts)
  • LangChain, LlamaIndex (for chained prompts)
  • Jupyter Notebook (runnable examples)
🙏

来源与感谢

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产