Prompt Engineering Guide — 73K-Star Learning Hub
The most comprehensive open-source prompt engineering resource with guides, papers, notebooks, and courses covering chain-of-thought, RAG, AI agents, and 13 languages. 3M+ learners, MIT.
先审查再安装
这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。
npx -y tokrepo@latest install fc6496bc-fe40-4af3-bbb5-050e41c1f938 --target codex先 dry-run,确认写入项后再运行此命令。
What it is
The Prompt Engineering Guide is an open-source educational resource covering prompt engineering techniques for large language models. It includes written guides, research paper summaries, Jupyter notebooks, and course materials on topics like chain-of-thought prompting, retrieval-augmented generation, AI agents, and multi-modal models. The content is available in 13 languages.
This resource targets developers, researchers, and AI practitioners who want to understand and apply prompt engineering systematically rather than through trial and error.
How it saves time or tokens
Understanding prompt engineering techniques directly reduces token waste. A well-structured prompt that uses chain-of-thought or few-shot examples gets better results on the first try, avoiding the iterative cycle of prompt refinement that consumes tokens.
The guide covers token-efficient patterns: when to use system prompts vs user prompts, how to structure few-shot examples for maximum effect, and when chain-of-thought helps vs hurts (simple tasks do not benefit from verbose reasoning).
How to use
- Clone the repository or read online:
git clone https://github.com/dair-ai/Prompt-Engineering-Guide.git
cd Prompt-Engineering-Guide
- Start with the fundamentals:
guides/
prompts-intro.md # Introduction to prompting
prompts-basic-usage.md # Basic techniques
prompts-advanced.md # Advanced patterns
prompts-chatgpt.md # ChatGPT-specific tips
prompts-applications.md # Real-world applications
- Explore technique-specific notebooks in the
notebooks/directory for hands-on practice.
Example
Chain-of-thought prompting pattern from the guide:
# Without CoT (often wrong on complex tasks)
Q: Roger has 5 tennis balls. He buys 2 more cans
of 3 tennis balls each. How many does he have?
A: 11
# With CoT (step-by-step reasoning)
Q: Roger has 5 tennis balls. He buys 2 more cans
of 3 tennis balls each. How many does he have?
A: Roger starts with 5 balls.
He buys 2 cans of 3 balls each = 6 balls.
5 + 6 = 11.
The answer is 11.
Explicit reasoning steps improve accuracy on math, logic, and multi-step tasks.
Related on TokRepo
- Prompt library -- Curated prompts and templates for various AI tasks
- AI tools for research -- Research tools and resources for AI practitioners
Common pitfalls
- Applying chain-of-thought to every prompt. Simple factual questions and classification tasks do not benefit from verbose reasoning. CoT adds tokens without improving accuracy on straightforward tasks.
- Ignoring model-specific prompt formats. Claude, GPT-4, and Gemini have different system prompt conventions and capabilities. Techniques that work on one model may underperform on another.
- Over-engineering prompts when a simple instruction suffices. Start with the simplest prompt that works and add complexity only when needed.
常见问题
The guide covers foundational techniques (zero-shot, few-shot, chain-of-thought), advanced patterns (tree-of-thought, RAG, agents), model-specific tips (GPT-4, Claude, Llama), and applications (code generation, reasoning, creative writing). It also summarizes relevant research papers.
Yes. The entire guide is open source under the MIT license. All written content, notebooks, and course materials are freely available on GitHub and the project website.
The guide is actively maintained by the DAIR.AI community. New techniques, model-specific tips, and research summaries are added regularly. Contributors submit updates via pull requests.
Yes. The MIT license permits use in educational settings, including university courses, corporate training, and workshops. Attribution to the project is appreciated but not legally required.
Yes. The guide includes sections on Claude-specific prompting techniques, including system prompts, XML tags for structured output, and Anthropic's recommended prompt engineering patterns.
引用来源 (3)
- Prompt Engineering Guide GitHub— The most comprehensive open-source prompt engineering resource
- Chain-of-Thought Prompting Paper— Chain-of-thought prompting improves reasoning accuracy
- Anthropic Prompt Engineering Guide— Anthropic prompt engineering best practices
来源与感谢
Created by DAIR.AI. Licensed under MIT.
Prompt-Engineering-Guide — ⭐ 72,900+
讨论
相关资产
Awesome Prompt Engineering — Papers, Tools & Courses
Hand-curated collection of 60+ papers, 50+ tools, benchmarks, and courses for prompt engineering and context engineering. Covers CoT, RAG, agents, security, and multimodal. Apache 2.0.
Prompt Engineering Techniques — 20+ Methods
Comprehensive prompt engineering collection with 20+ techniques. 7.3K+ stars. Chain-of-Thought, ReAct, Tree-of-Thought, runnable notebooks.
Prompts.chat — 155K-Star ChatGPT Prompt Library
The largest open-source ChatGPT prompt library with 155K+ GitHub stars. Community-curated prompts for every role — developer, writer, translator, analyst, and more. Self-hostable.
AI Prompt Engineering Best Practices Guide
Comprehensive guide to writing effective prompts for Claude, GPT, and Gemini. Covers system prompts, few-shot learning, chain-of-thought, and structured output techniques.