🧠 Advanced

🟢 Prompt Engineering

Last updated on August 7, 2024 by Sander Schulhoff
Takeaways
  • What is prompt engineering?

What is Prompt Engineering?

Prompt engineering is the process of refining a prompt over time to improve its capabilities in responding to user inputs. This process is especially useful in instances where basic prompts don't work as well as we want them to.

What Happens When a Prompt Doesn't Work?

Sometimes Gen AIs give incorrect outputs to prompts. For example, they are not very good at multiplying numbers, and will often confidently give you an incorrect answer. Try giving the following prompt to ChatGPT:

Astronaut

Prompt


What is 923 * 99?
Robot

AI Output


923 * 99 equals 91,677.

ChatGPT gave an incorrect answer (the correct answer is 91,377). We can modify our prompt, and tell ChatGPT to think through its steps.

Astronaut

Prompt


What is 923 * 99? Let's go step by step. Always write out the full number of 0s for each term.
Robot

AI Output


To multiply 923 by 99, we can break it down into smaller steps:

Step 1: Write out the full number of 0s for each term: 923 * 99 = 923 * 990

Step 2: Multiply the first term by 9: 923 * 9 = 8307

Step 3: Multiply the first term by 90 (adding one 0): 923 * 90 = 83070

Step 4: Add the results from step 2 and step 3: 8307 + 83070 = 91377

Therefore, 923 multiplied by 99 is equal to 91,377.

Surprisingly, with these additional instructions, ChatGPT can solve the problem. This worked because ChatGPT wrote out all of its work, and thus did not make mistakes. Gen AI's mathematical abilities can be improved by prompt engineering. Now, let's try a different example.

Caution

Since ChatGPT is non-deterministic, even this prompt sometimes won't work. You may see answers like 91,177 or 91,077.

An Example of Prompt Engineering: ArchaeologistAI

This time, we will ask ChatGPT to write a marketing tweet about a new, fictional AI product we are thinking of creating: ArchaeologistAI. ArchaeologistAI tells stories about famous archaeologists.

Astronaut

Prompt


Write a tweet about ArchaeologistAI
Robot

AI Output


"🔍 Exciting times ahead with #ArchaeologistAI! This cutting-edge technology is revolutionizing the field of archaeology, helping us uncover ancient mysteries and piece together our past like never before. Can't wait to see what hidden treasures and insights it unveils! #AI #Archaeology"

This Tweet is not accurate, since ArchaeologistAI only tells stories, and does not discover new things. However, this is not ChatGPT's fault! It did not know anything about ArchaeologistAI. Let's include relevant information in the prompt.

Astronaut

Prompt


Write a tweet about ArchaeologistAI: ArchaeologistAI tells stories about famous archaeologists.
Robot

AI Output


"🔍 Unearth the captivating tales of legendary archaeologists with #ArchaeologistAI! From Indiana Jones to Mary Leakey, this AI-powered storyteller brings their adventures to life, shedding light on their groundbreaking discoveries and inspiring the next generation of explorers. 🌍 #Archaeology"

This is much better! Now let's try to make ChatGPT write the Tweet in the style of Indiana Jones.

Astronaut

Prompt


Write a tweet about ArchaeologistAI, in the style of Indiana Jones: ArchaeologistAI tells stories about famous archaeologists.
Robot

AI Output


"Grab your fedora and whip, folks! 🎩🔥 ArchaeologistAI is like having a personal Sallah by your side, sharing captivating tales of legendary archaeologists who've braved ancient tombs and unearthed hidden treasures! 🗺️💎 Get ready to embark on a digital adventure through history! #ArchaeologistAI #UnearthTheLegends"

Alright, that may be the message we need to target archaeology fans! By testing multiple prompts, we can see which one gives the best output.

Conclusion

You will never write the perfect prompt on your first try, so it is important to get good at refining your prompt. Being good at prompt engineering mostly comes from lots of practice (trial and error). The rest of the articles in this section will introduce you to different prompting strategies that you can use in your prompt engineering process.

FAQ

Why is prompt engineering important?

Sometimes, basic user inputs will lead to wrong answers from a generative AI model. However, with prompt engineering, we can specify user instructions and improve LLM responses.

Why was prompt engineering effective in the ArchaeologistAI example?

In this article's ArchaeologistAI example, the initial prompt was refined with additional details that gave the model context and style instructions to write a better tweet.

How can I become a better prompt engineer?

The Learn Prompting guides to prompt engineering are built to provide you with a varied arsenal of tools and strategies that you can use to create better AI applications.

Edit this page
Word count: 0

Get AI Certified by Learn Prompting


Copyright © 2024 Learn Prompting.