Prompt-Engineering-Guide
🐙 Guides, papers, lecture, notebooks and resources for prompt engineering
Top Related Projects
Examples and guides for using the OpenAI API
18 Lessons, Get Started Building with Generative AI 🔗 https://microsoft.github.io/generative-ai-for-beginners/
This repo includes ChatGPT prompt curation to use ChatGPT better.
This repository contains a hand-curated resources for Prompt Engineering with a focus on Generative Pre-trained Transformer (GPT), ChatGPT, PaLM etc
🦜🔗 Build context-aware reasoning applications
Quick Overview
The Prompt-Engineering-Guide is a comprehensive resource for learning about prompt engineering techniques in AI and natural language processing. It covers various aspects of prompt engineering, including best practices, applications, and tools, aimed at helping developers and researchers improve their skills in crafting effective prompts for language models.
Pros
- Extensive coverage of prompt engineering topics, from basics to advanced techniques
- Regularly updated with new content and examples
- Includes practical examples and case studies
- Open-source and community-driven, allowing for contributions and improvements
Cons
- May be overwhelming for beginners due to the breadth of information
- Some sections might require prior knowledge of machine learning concepts
- Limited interactive elements or hands-on exercises
- Primarily focused on text-based prompts, with less emphasis on multimodal prompting
Competitor Comparisons
Examples and guides for using the OpenAI API
Pros of openai-cookbook
- Directly maintained by OpenAI, ensuring up-to-date and accurate information
- Focuses on practical examples and code snippets for OpenAI's API
- Includes advanced topics like fine-tuning and embeddings
Cons of openai-cookbook
- Limited to OpenAI-specific implementations
- Less comprehensive coverage of general prompt engineering techniques
- Fewer explanations of underlying concepts and theories
Code Comparison
Prompt-Engineering-Guide example:
prompt = f"""
Summarize the text below in 50 words:
{text}
"""
response = get_completion(prompt)
print(response)
openai-cookbook example:
response = openai.Completion.create(
model="text-davinci-003",
prompt="Summarize the following text in 50 words:\n\n" + text,
max_tokens=60,
temperature=0.7
)
print(response.choices[0].text.strip())
The Prompt-Engineering-Guide focuses on a more generic approach, while the openai-cookbook provides specific implementation details for the OpenAI API. Both repositories offer valuable resources for developers working with language models, with Prompt-Engineering-Guide providing a broader overview of prompt engineering techniques and openai-cookbook offering more targeted examples for OpenAI's services.
18 Lessons, Get Started Building with Generative AI 🔗 https://microsoft.github.io/generative-ai-for-beginners/
Pros of generative-ai-for-beginners
- Comprehensive curriculum covering various aspects of generative AI
- Hands-on projects and practical examples for better learning
- Well-structured lessons with clear learning objectives
Cons of generative-ai-for-beginners
- More focused on general AI concepts, less specific to prompt engineering
- May be overwhelming for those solely interested in prompt engineering
- Requires more time investment to complete the full course
Code Comparison
Prompt-Engineering-Guide example:
prompt = f"""
Summarize the text delimited by triple backticks into a single sentence.
```{text}```
"""
response = get_completion(prompt)
print(response)
generative-ai-for-beginners example:
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
The Prompt-Engineering-Guide focuses more on crafting effective prompts, while generative-ai-for-beginners provides a broader introduction to working with AI models and APIs.
This repo includes ChatGPT prompt curation to use ChatGPT better.
Pros of awesome-chatgpt-prompts
- Extensive collection of ready-to-use prompts for various scenarios
- Community-driven with frequent updates and contributions
- Easy to browse and implement prompts without deep technical knowledge
Cons of awesome-chatgpt-prompts
- Lacks in-depth explanations of prompt engineering techniques
- Limited focus on the theory and principles behind effective prompts
- May not provide as much guidance for creating custom prompts
Code Comparison
Prompt-Engineering-Guide:
# Example of few-shot prompting
examples = [
{"input": "I loved the movie!", "output": "Positive"},
{"input": "The film was terrible.", "output": "Negative"}
]
prompt = f"Classify the sentiment: {user_input}\n\nExamples:\n"
for example in examples:
prompt += f"Input: {example['input']}\nOutput: {example['output']}\n\n"
awesome-chatgpt-prompts:
# Act as an Excel Sheet
Instruction: I want you to act as a text-based Excel sheet. You'll only reply with the text-based 10-row x 10-column Excel sheet with cell numbers and letter headers, and nothing else. I'll give you the cell content. The cells should be blank if I don't give you any content. Don't write explanations. I'll give you instructions for cell content, and you'll reply with the result of those instructions.
Human: Write "Hello World" in B2 cell
AI: (Excel sheet representation with "Hello World" in B2)
This repository contains a hand-curated resources for Prompt Engineering with a focus on Generative Pre-trained Transformer (GPT), ChatGPT, PaLM etc
Pros of Awesome-Prompt-Engineering
- More comprehensive collection of resources, including tools, papers, and tutorials
- Better organized with clear categories and subcategories
- Regularly updated with new content and contributions from the community
Cons of Awesome-Prompt-Engineering
- Less in-depth explanations and original content
- Lacks practical examples and hands-on guides
- May be overwhelming for beginners due to the sheer volume of resources
Code Comparison
While both repositories primarily focus on curating resources rather than providing code, Prompt-Engineering-Guide occasionally includes code snippets for demonstration purposes. For example:
Prompt-Engineering-Guide:
prompt = f"""
Translate the following English text to Spanish:
```{text}```
"""
Awesome-Prompt-Engineering doesn't typically include code snippets, focusing instead on linking to external resources.
Both repositories serve as valuable resources for prompt engineering, with Awesome-Prompt-Engineering offering a broader collection of links and Prompt-Engineering-Guide providing more detailed explanations and examples. The choice between them depends on whether you prefer a comprehensive list of resources or a more curated, educational approach.
🦜🔗 Build context-aware reasoning applications
Pros of langchain
- Comprehensive framework for building LLM-powered applications
- Extensive library of tools and integrations for various AI tasks
- Active development and community support
Cons of langchain
- Steeper learning curve due to its extensive features
- May be overkill for simple prompt engineering tasks
- Requires more setup and configuration
Code comparison
Prompt-Engineering-Guide (example prompt):
prompt = """
Summarize the following text in 3 sentences:
{text}
"""
langchain (example chain):
from langchain import PromptTemplate, LLMChain
from langchain.llms import OpenAI
template = """Summarize the following text in 3 sentences:
{text}
"""
prompt = PromptTemplate(template=template, input_variables=["text"])
llm_chain = LLMChain(prompt=prompt, llm=OpenAI())
The Prompt-Engineering-Guide focuses on providing guidelines and best practices for crafting effective prompts, while langchain offers a more comprehensive framework for building complex LLM-powered applications. Prompt-Engineering-Guide is better suited for those primarily interested in improving their prompt writing skills, whereas langchain is ideal for developers building full-fledged AI applications with multiple components and integrations.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Prompt Engineering Guide
Prompt engineering is a relatively new discipline for developing and optimizing prompts to efficiently use language models (LMs) for a wide variety of applications and research topics. Prompt engineering skills help to better understand the capabilities and limitations of large language models (LLMs). Researchers use prompt engineering to improve the capacity of LLMs on a wide range of common and complex tasks such as question answering and arithmetic reasoning. Developers use prompt engineering to design robust and effective prompting techniques that interface with LLMs and other tools.
Motivated by the high interest in developing with LLMs, we have created this new prompt engineering guide that contains all the latest papers, learning guides, lectures, references, and tools related to prompt engineering for LLMs.
ð Prompt Engineering Guide (Web Version)
ðº YouTube Mini Lectures on Prompting Engineering
ð We are excited to launch our brand new course website and releasing our first course on Introduction to Prompt Engineering. Join Now!
Happy Prompting!
Announcements / Updates
- ð New course on Prompt Engineering for LLMs announced! Enroll here!
- ð¼ We now offer several services like corporate training, consulting, and talks.
- ð We now support 13 languages! Welcoming more translations.
- ð©âð We crossed 3 million learners in January 2024!
- ð We have launched a new web version of the guide here
- ð¥ We reached #1 on Hacker News on 21 Feb 2023
- ð The First Prompt Engineering Lecture went live here
Guides
You can also find the most up-to-date guides on our new website https://www.promptingguide.ai/.
- Prompt Engineering - Introduction
- Prompt Engineering - Techniques
- Prompt Engineering - Zero-Shot Prompting
- Prompt Engineering - Few-Shot Prompting
- Prompt Engineering - Chain-of-Thought Prompting
- Prompt Engineering - Self-Consistency
- Prompt Engineering - Generate Knowledge Prompting
- Prompt Engineering - Prompt Chaining
- Prompt Engineering - Tree of Thoughts (ToT)
- Prompt Engineering - Retrieval Augmented Generation
- Prompt Engineering - Automatic Reasoning and Tool-use (ART)
- Prompt Engineering - Automatic Prompt Engineer
- Prompt Engineering - Active-Prompt
- Prompt Engineering - Directional Stimulus Prompting
- Prompt Engineering - Program-Aided Language Models
- Prompt Engineering - ReAct Prompting
- Prompt Engineering - Multimodal CoT Prompting
- Prompt Engineering - Graph Prompting
- Prompt Engineering - Applications
- Prompt Engineering - Prompt Hub
- Prompt Engineering - Classification
- Prompt Engineering - Coding
- Prompt Engineering - Creativity
- Prompt Engineering - Evaluation
- Prompt Engineering - Information Extraction
- Prompt Engineering - Image Generation
- Prompt Engineering - Mathematics
- Prompt Engineering - Question Answering
- Prompt Engineering - Reasoning
- Prompt Engineering - Text Summarization
- Prompt Engineering - Truthfulness
- Prompt Engineering - Adversarial Prompting
- Prompt Engineering - Models
- Prompt Engineering - ChatGPT
- Prompt Engineering - Code Llama
- Prompt Engineering - Flan
- Prompt Engineering - Gemini
- Prompt Engineering - GPT-4
- Prompt Engineering - LLaMA
- Prompt Engineering - Mistral 7B
- Prompt Engineering - Mixtral
- Prompt Engineering - OLMo
- Prompt Engineering - Phi-2
- Prompt Engineering - Model Collection
- Prompt Engineering - Risks and Misuses
- Prompt Engineering - Papers
- Prompt Engineering - Tools
- Prompt Engineering - Notebooks
- Prompt Engineering - Datasets
- Prompt Engineering - Additional Readings
Lecture
We have published a 1 hour lecture that provides a comprehensive overview of prompting techniques, applications, and tools.
Running the guide locally
To run the guide locally, for example to check the correct implementation of a new translation, you will need to:
- Install Node >=18.0.0
- Install
pnpm
if not present in your system. Check here for detailed instructions. - Install the dependencies:
pnpm i next react react-dom nextra nextra-theme-docs
- Boot the guide with
pnpm dev
- Browse the guide at
http://localhost:3000/
Appearances
Some places where we have been featured:
- Wall Street Journal - ChatGPT Can Give Great Answers. But Only If You Know How to Ask the Right Question
- Forbes - Mom, Dad, I Want To Be A Prompt Engineer
- Markettechpost - Best Free Prompt Engineering Resources (2023)
If you are using the guide for your work or research, please cite us as follows:
@article{Saravia_Prompt_Engineering_Guide_2022,
author = {Saravia, Elvis},
journal = {https://github.com/dair-ai/Prompt-Engineering-Guide},
month = {12},
title = {{Prompt Engineering Guide}},
year = {2022}
}
License
Feel free to open a PR if you think something is missing here. Always welcome feedback and suggestions. Just open an issue!
Top Related Projects
Examples and guides for using the OpenAI API
18 Lessons, Get Started Building with Generative AI 🔗 https://microsoft.github.io/generative-ai-for-beginners/
This repo includes ChatGPT prompt curation to use ChatGPT better.
This repository contains a hand-curated resources for Prompt Engineering with a focus on Generative Pre-trained Transformer (GPT), ChatGPT, PaLM etc
🦜🔗 Build context-aware reasoning applications
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot