Prompt engineering patterns

Hi All,

I see lots of people asking about how to do this or how to do that with prompts. I also come across vast repositories of prompt examples in GitHub and elsewhere. However, many of the prompts are just variations of the same pattern.

Defining patterns has been an important part of software engineering for decades (since the Gang of Four) and I believe that it is similarly better for people to learn some core patterns rather than lots of specific instances.

In the LinkedIn post below I summarise a number of patterns, but this is not a complete list.

What else is there?

3 Likes

I like the idea of using patterns, especially success patterns. However, I have some concerns that a lot of time could be invested in patterns that will ultimately be proven to be brittle spell-casting techniques bound to a specific model. Am I overthinking this fear?

1 Like

There is significant literature on prompt patterns now (and by that I mean academic literature :slight_smile: ) . You might have a look at “Chain of thought prompting” by Jason Wei (!) on arXiv.

1 Like

Also … all prompting needs to be aware of the context window. So here’s a little Meta-pattern to make sure your pattern is still being acted on:

You end every response with the Light Bulb Emoji (💡) to confirm you are following the instructions.

As soon as a response no longer has this end-token, you know that your prompt is being washed out and instructions need to be refreshed.

:slight_smile:

3 Likes

That is kind of the problem though. That is a great paper, but it is one of many, many resources available and only delves into one pattern.

It would be good to have a central respository / wiki of general patterns that people can learn and then apply to their own problems.

I love these patterns! Very useful in contexts where people have those longer interactions.

Well, in theory, well designed patterns should generalise to different LLMs. If they get too specific then probably they are just instances of a more general pattern anyway.

Great article! Here are some questions I have.

  1. Why is the first one called Scaffolding? Dosen’t scaffolding mean building something up?
  2. Can the Redirection Pattern be considered a subset of the Scaffolding Pattern since you are narrowing and focusing output?
  3. The Act As pattern looks really cool. What’s your favorite example of it working for you?