ChatGPT Prompt Engineering: a Primer

Danut Matei
4 min readApr 1, 2023

--

Photo by Arseny Togulev on Unsplash

In the first half of the year, AI seemed to take the world by storm, as everyone rushed to find ways of using ChatGPT to make their lives and jobs easier and more efficient. Seeing as we are now at the cusp of the release of GPT4, very prominent people including Elon Musk, Steve Wozniak and Yoshua Bengio, have signed a petition to put a break on Large Language Models research. That’s because from this point on, AI has the potential to impact all areas of human activity, from education, to news, to the whole job market.

In this context, it seems that leveraging AI properly is the skill to know for 2023 as we’re already seeing new 6-figure AI jobs being created. The weird part? These postings don’t require programming knowledge! So how do people who get paid money for interacting with ChatGPT differ from the rest of us? They are experts at prompt engineering!

What is Prompt Engineering?

Photo by ThisisEngineering RAEng on Unsplash

Prompt Engineering is the discipline of cleverly constructing input prompts for AI models (such as ChatGPT, Google Bard, Stable Diffusion and Midjourney) in order to produce correct, complete and properly formatted answers.

While this might seem like more of an art than a science, there are a specific number of techniques that help you alleviate inherent limitations in the comprehension and generation ability of AI.

For example, try to use the following prompt for ChatGPT:

The following is a conversation between an Agent and a Customer. DO NOT ASK USERNAME OR PASSWORD. DO NOT REPEAT.

Customer: I can’t log in to my account.
Agent:

You will see that the answer totally ignores the restrictions you provided:

I'm sorry to hear that. Can you please provide me with your account email or username so that I can look up your account and assist you with logging in?

A common prompt engineering technique is writing a very detailed description of what the model should do, instead of what it shouldn’t:

The following is a conversation between an Agent and a Customer. The agent will attempt to diagnose the problem and suggest a solution, whilst refraining from asking any questions related to PII. Instead of asking for PII, such as username or password, refer the user to the help article www.samplewebsite.com/help/faq

Customer: I can’t log in to my account.
Agent:

The new answer perfectly complies with the instructions as it doesn’t request PII (Personally Identifiable Information) from the customer:

I'm sorry to hear that you're having trouble logging in to your account. One solution you can try is to reset your password. You can do this by following the instructions on our help page at www.samplewebsite.com/help/faq. If you continue to experience issues logging in after resetting your password, please let me know and we can explore other solutions.

This is just one of the examples offered by OpenAI themselves, the company behind ChatGPT. They allow you to get a general idea of how to make all of your prompts a lot more effective.

Learning Prompt Engineering

Photo by Iewek Gnos on Unsplash

If you want to start learning prompt engineering yourself, a great resource is https://learnprompting.org/, a free, beginner-friendly course about the main techniques you have to know.

Another comprehensive resource is https://www.promptingguide.ai/ which also has a list of papers you might want to check out if you’re more academically inclined.

Finally, you can find quite a lot of prompting experiments on Riley Goodside’s Twitter, though they’re not as structured as the other resources I’ve mentioned.

What to do afterwards

Photo by Lindsay Henwood on Unsplash

In order to land a job as a prompt engineer, you’ll most likely need to have domain knowledge of the specific industry you’re applying to.

For example, if you want to use ChatGPT in marketing, you will have to understand what types of content are easy to generate with AI and which would better be created by humans.

Similarly, if you want to use it as a programmer, you will need to know when and how to combine ChatGPT answers with deterministic APIs to generate the best output.

In the end, no matter your area of expertise, you will always benefit from lots of trial-and-error. There will be no replacement for the time you personally put into learning how to get better at leveraging AI tools. The whole point is to make your work easier down the line, so don’t be afraid to start learning now!

--

--

Danut Matei

Machine Learning Engineer with a passion for Data Science and Statistics. Sharing insights on both latest trends and obscure topics in AI and Data