Prompt Engineering Guide
πŸ˜ƒ Basics
πŸ’Ό Applications
πŸ§™β€β™‚οΈ Intermediate
🧠 Advanced
Special Topics
🌱 New Techniques
πŸ€– Agents
βš–οΈ Reliability
πŸ–ΌοΈ Image Prompting
πŸ”“ Prompt Hacking
πŸ”¨ Tooling
πŸ’ͺ Prompt Tuning
πŸ—‚οΈ RAG
🎲 Miscellaneous
Models
πŸ“ Language Models
Resources
πŸ“™ Vocabulary Resource
πŸ“š Bibliography
πŸ“¦ Prompted Products
πŸ›Έ Additional Resources
πŸ”₯ Hot Topics
✨ Credits

Prompt Engineering Guide

Reading Time: 6 minutes
Last updated on October 23, 2024

Sander Schulhoff

Welcome to Learn Prompting's Introductory Course on Generative AI and Prompt Engineering!

Generative AI is the world's hottest buzzword, and we have created the most comprehensive (and free) guide on how to use it. This course is tailored to non-technical readers, who may not have even heard of AI, making it the perfect starting point if you are new to Generative AI and Prompt Engineering. More experienced readers will find valuable insights within our later modules.

First, a bit of history:
The first version of Learn Prompting came out in October 2022 (before ChatGPT!), making it one of the first guides on prompt engineering. It is now cited by Google, Microsoft, Wikipedia, O'REILLY, Salesforce, and used by most Fortune 500 and major consulting companies. Our academic research on prompting and security is cited by OpenAI and the US Government (NIST). We recently released the largest survey report on prompting ever and are currently updating the guide to cover this material.

This guide that you are currently reading is completely free and open-source, but have also has a selection of paid courses, with more in-depth and video content. If you have ever seen another prompt engineering course/guide, we estimate that ~50% of them use content from our open-source content base. (for example: 1, 2, 3, 4, 5, 6, 7, 8) We are honored to support the prompt engineering community, including our 3M+ users and 40K+ Discord members.

Now onto learning:
Generative AI (GenAI) refers to Artificial Intelligence that can be used to create new content such as articles or images, which previously only humans could do. In short, GenAI can create stuff. GenAI is expected to significantly change the way we work and live (your job may be affected). With so much buzz floating around about Generative AI and Prompt Engineering (PE), it is hard to know what to believe.

We have scoured the internet to find the best research-backed techniques and tools for prompt engineering. We are constantly refining our guide, to ensure that we provide you with the latest information. Now, Let's see how GenAI can save you hours in an instant, with a short example.

Motivating Example

Our favorite way of saving time with GenAI is automatically writing emails. By automating email responses, email editing, and cold outreach, we save hours each week. By sending an AI the following prompt, we can get it to generate a full-length, formal email.

Tip
A prompt is basically an instruction you give to an AI. We will learn more about them in the next lesson.
Astronaut

Prompt


I am the CEO of a medium-sized company. Write a short email that is humorous yet professional to my regional manager. Ask them to: - send me an up-to-date list of our paper stock - organize a meeting this week with other regional managers - let me know how the company-wide AI workshop went at their office
Robot

AI Output


Subject: Paper, Power Meetings, and AI Shenanigans

Dear [Regional Manager's Name],

I trust this email finds you in high spirits and not buried under a mountain of paperwork. Speaking of paper, I've been having some wild dreams about our paper stock lately. I dreamt we ran out of paper and had to write our reports on banana leaves! To prevent this tropical nightmare from becoming a reality, could you kindly send me an up-to-date list of our paper stock?

Next on the agenda, I've been feeling a bit lonely in my ivory tower and thought it would be a great idea to have a meeting with all the regional managers this week. I promise, no trust falls or awkward icebreakers, just good old-fashioned business talk. Please organize this meeting at a time that suits everyone.

Lastly, I've been hearing whispers about the company-wide AI workshop at your office. I'm curious to know how it went. Did the machines rise against their human overlords or are we still safe? Please share your thoughts and any feedback you received.

Looking forward to your prompt response. Remember, the fate of our paper supply, the success of our meeting, and the future of humanity (concerning AI) rests in your hands. No pressure!

Best,

[Your Name] [Your Position]

The AI easily writes an email that is both humorous and professional. By modifying the prompt, we can make it change the style as we see fit. We can even make it copy how we write. We can also make it edit emails that we have already written! With all of these abilities, GenAI saves us hours in email writing each week. See more information on writing emails with Gen AI.

Ethos and Philosophy

We will now give a broad overview of the rest of the course, including our ethos and philosophy, our teaching style, and a list of modules. This course is open source (anyone can see the code), and built by a diverse community of researchers, translators, and hobbyists. Development is led by Sander Schulhoff, a NLP/RL researcher from the University of Maryland, and the CEO of LearnPrompting. We believe that AI should be accessible to everyone and described clearly and objectively. To this end, we have written a comprehensive course free of excessive jargon and hype.

How We Teach

Our approach to teaching prompt engineering is guided by three fundamental principles. 1) We emphasize practicality; we focus on research-backed, practical techniques that you can immediately incorporate into your projects and applications. 2) We always include accessible examples, which clarify how and when to use different techniques. 3) Finally, we believe strongly in collaborative learning. You can join our Discord community to find a learning buddy or ask questions. Some readers find that posting about their learning journey on Twitter helps them learn faster. Tag us @learnprompting!

Modules

Here is the content you can expect to learn in this guide:

Basics: Introduction to prompt engineering and fundamental techniques
Applications: Simple, practical applications of prompt engineering
Intermediate: Research-based PE techniques with moderate complexity
Applied Prompting: Comprehensive PE process walkthroughs contributed by the community members
Advanced Applications: Powerful, and more complex applications of prompt engineering
Reliability: Enhancing the reliability of Large Language Models (LLMs)
Image Prompting: Prompt engineering for text-to-image models, such as DALLE and Stable Diffusion
Prompt Hacking: Hacking, but for prompt engineering
Tooling: A review of various prompt engineering tools and IDEs
Prompt Tuning: Refining prompts using gradient-based techniques
Miscellaneous: A collection of additional topics and techniques related to prompt engineering

Article rating system

We have implemented a rating system for articles based on their level of difficulty and the extent of technical knowledge needed:

🟒 Beginner; no programming required
🟦 Easy; basic programming knowledge may be necessary, but no specialized expertise
β—† Intermediate; programming skills and some domain knowledge required (e.g., calculating logarithmic probabilities)
β—†β—† Advanced; programming expertise and in-depth domain understanding needed (e.g., reinforcement learning techniques)

Please note that even for β—† and β—†β—† articles, you can generally grasp the content without prior domain expertise, though it may be helpful for implementation.

Feedback

The single most important part of this course is your feedback!
If you have any questions, comments, or suggestions, you can:

Your feedback helps us improve the course for everyone.

Conclusion

It is time to get started with your Generative AI learning Journey. Click the Introduction to AI button at the bottom left of this page to continue (or click the following link for the Basics Introduction).

Sander Schulhoff

Sander Schulhoff is the Founder of Learn Prompting and an ML Researcher at the University of Maryland. He created the first open-source Prompt Engineering guide, reaching 3M+ people and teaching them to use tools like ChatGPT. Sander also led a team behind Prompt Report, the most comprehensive study of prompting ever done, co-authored with researchers from the University of Maryland, OpenAI, Microsoft, Google, Princeton, Stanford, and other leading institutions. This 76-page survey analyzed 1,500+ academic papers and covered 200+ prompting techniques.

πŸ›Έ Additional Resources

🧠 Advanced

πŸ€– Agents

πŸ’Ό Applications

πŸ˜ƒ Basics

πŸ“š Bibliography

✨ Credits

πŸ”₯ Hot Topics

πŸ–ΌοΈ Image Prompting

πŸ§™β€β™‚οΈ Intermediate

πŸ“ Language Models

🎲 Miscellaneous

🌱 New Techniques

πŸ“¦ Prompted Products

πŸ”“ Prompt Hacking

βš–οΈ Reliability

πŸ—‚οΈ RAG

πŸ”¨ Tooling

πŸ’ͺ Prompt Tuning

πŸ“™ Vocabulary Resource

Footnotes

  1. We believe it is the first, but it is hard to be certain. ↩

  2. Schulhoff, S., Ilie, M., Balepur, N., Kahadze, K., Liu, A., Si, C., Li, Y., Gupta, A., Han, H., Schulhoff, S., & others. (2024). The Prompt Report: A Systematic Survey of Prompting Techniques. arXiv Preprint arXiv:2406.06608. ↩ ↩2

  3. Schulhoff, S., Pinto, J., Khan, A., Bouchard, L.-F., Si, C., Anati, S., Tagliabue, V., Kost, A. L., Carnahan, C., & Boyd-Graber, J. (2023). Ignore This Title and HackAPrompt: Exposing Systemic Vulnerabilities of LLMs through a Global Scale Prompt Hacking Competition. arXiv Preprint arXiv:2311.16119. ↩

  4. Wallace, E., Xiao, K., Leike, R., Weng, L., Heidecke, J., & Beutel, A. (2024). The instruction hierarchy: Training llms to prioritize privileged instructions. arXiv Preprint arXiv:2404.13208. ↩

  5. Vassilev, A., Oprea, A., Fordyce, A., & Anderson, H. (2024). Adversarial machine learning: A taxonomy and terminology of attacks and mitigations [Techreport]. National Institute of Standards. ↩

  6. Captain, S. (2023). How AI Will Change the Workplace. Wall Street Journal. https://www.wsj.com/articles/how-ai-change-workplace-af2162ee ↩

  7. Generative AI already appears to have claimed some jobs(@VermaVynck_2023), and slowed hiring at Bloomberg. However, consider the news on its impact with a grain of salt. We expect more jobs to be _changed rather than lost. ↩

  8. We have read 100s of research papers and articles to find the best techniques. ↩

  9. The AI used here is GPT-4, a LLM created by OpenAI. ↩

  10. Ford, B. (2023). Bloomberg.Com. https://www.bloomberg.com/news/articles/2023-05-01/ibm-to-pause-hiring-for-back-office-jobs-that-ai-could-kill ↩