Prompt like Michelangelo: How to become a better prompt engineer
A prompt engineer. Generated by Imagen v2.

Prompt like Michelangelo: How to become a better prompt engineer

What does prompt engineering have to do with Michelangelo? It will make sense, I promise. First, we need to talk about the multiverse.

The best mental model and framework for conceptualizing large language models (LLM) that I’ve come across so far has been the multiversal view, or the idea that ”language models are multiverse generators” [1].

In this work, authors L. Reynolds and K. McDonell conceptualize language models as multiverse generators where several branching narratives can grow from a root node representing a starting prompt. By sampling tokens from the model’s probabilistic distribution at each point in a sentence, one can construct a narrative tree where the root is the starting prompt and the branches are the various possible responses that result from different token selections along the way.

The following image (from [1]) illustrates the process of constructing a narrative tree.

Constructing a narrative tree (multiverse)


And what is the point of all that? The idea is that you can think of a language model as a multiverse generator since any possible input you can give it can be used to generate a virtually infinite number of parallel branches, all representing possible futures with different probabilities. For each token that is chosen as the next token in a sentence, a concrete present (out of the infinite future possibilities) materializes. The authors even draw an analogy with the many-worlds interpretation of quantum mechanics.


Abstract art representing the multiverse generated by language models (image generated by Imagen v2)


Subtractive prompting

In a similar work by the same authors [2], they also describe how effective 0-shot prompt programming (or prompt engineering) can outperform few-shot prompting in many cases by approaching prompting in a subtractive manner, i.e., focusing not so much on steering the model’s toward the right output, but steering it away from all the possible wrong outputs (which, in that multiversal view of LLMs, would far outnumber the correct ones). Instead of writing a lot of instructions to your prompt, think about simple ways to tell the model what not to do.

As an example applied to the task of translation, the authors used a prompt structure such as :

English: <English sentence>
French:        

And that alone was better performing than such instructions as "translate this to French", or "translate the following sentence to French" which all leave room for undesirable continuations (for example, the model may well decide to continue the English sentence by generating a few more words before finally translating it to French, since it's not clearly defined where the sentence is supposed to end).

Another important thing to understand is that, fundamentally, an LLM is modeling not how any individual human may complete a sentence, but how any human potentially would. In other words, LLMs model language not after a single author but rather a superposition of authors, thus motivating a subtractive approach to prompting - i.e., one that constraints model behavior into a narrower view. As the authors put it, “we want a prompt that is not merely consistent with the desired continuation, but inconsistent with undesired continuations” (emphasis mine).

After all, the main reason that the prompt engineering discipline exists is because oftentimes the model fails to answer a question not because the answer doesn’t exist among the space of all possible answers the model can generate, but rather because it simply fails to arrive at the answer (even though it is already “there”), because it goes down the wrong "path". The primary function of prompt engineering is thus locating the solution to a given task in the model’s existing space of learned solutions. It’s about finding what’s already there, which may not be trivial to do given the size of the multiverse.

And this whole idea of locating and revealing a solution is what reminded me of Michelangelo’s famous quote:

The sculpture is already complete within the marble block, before I start my work. It is already there, I just have to chisel away the superfluous material.

So here’s my thesis: Prompt engineering is the art of revealing an answer that is already there by “chiseling away the superfluous”. Just like Michelangelo and his sculptures.

So how does that help you become better at prompting?

Moving from the philosophical to the practical, I believe that understanding language models in this way - though neither sufficient nor necessary for improving one’s prompt engineering skills - can help you determine a more effective prompting method for a given task. If nothing else, it helps you better understand why a particular prompting method is effective.

In other words, if you learn how to prompt like Michelangelo, you’ll be a better prompt engineer.

As an example, let’s take Open AI’s recently published prompt engineering guide [3], and look at how we can derive an explanation for why they work form the starting point of the intuition we just built.

Open AI’s six strategies to get better results

  1. Write clear instructionsThis one is an obvious corollary of the multiverse interpretation of LLMs and follows naturally from the subtractive paradigm of prompt engineering. Clear instructions increase the specificity of the task (and the expected output), pruning away undesired continuations and thus helping the model produce the desired output. Some of Open AI’s recommended tactics include adding details to get more relevant answers, asking the model to adopt a persona, specifying steps to complete a task, and providing examples.All of the tactics have as their common theme constraining the number of possible narrative branches the model could produce. For example, asking the model to adopt a persona will restrict the space of possible solutions to those that are coherent with the kind of solutions produced by said persona (who would presumably have the right answer or follow the instruction correctly). In [2], the authors show how adding “an expert translator would translate this sentence as” suffix to a prompt greatly improves the performance of the translation task, simply because many undesired continuations of a translation prompt (including grammatically correct translations but which are not of the greatest quality) are constrained away since those are now less likely to follow that new prompt (for a model sufficiently large and capable, that is).Providing examples, when correctly applied so as to avoid semantic contamination (described in [2]), will also greatly constraint the kind of output produced by the model, especially in terms of format, tone and structure.Also, specifying the steps required to complete a task is fundamentally a way of constraining degrees of freedoms within narratives.
  2. Provide reference textHere the idea is to ground the model’s response on some source of truth, for example a document. Providing reference text and asking the model to answer a question from the text is the ultimate pruning technique: you basically don’t allow the model to generate narratives, but only extract provided facts and occasionally summarize them.
  3. Split complex tasks into simpler subtasksFor tasks that require reasoning, breaking them into simpler subtasks is a way to not force the model to solve the task in a single forward pass, but make it solvable by breaking it up into individually tractable subtasks that have a much narrower set of possible continuations.
  4. Give the model time to “think”Similarly to the idea of splitting complex tasks into simpler subtasks, allowing the model to break down its own generated reasonings to produce an answer in a multi-step process is also a way to constraint the degrees of freedom the model has. For example, for a complex multi-step reasoning task, giving the model “time to think” means that a wrong initial though may be "corrected" by the model before it proceeds, thus preventing the situation where the LLM goes down a completely wrong path that has no hope of landing on the correct answer giving that those multiverse branches are all based on some wrong premise. Instead, this gives the model the ability to course-correct. Remember, there are a lot more wrong narratives than there are correct ones.
  5. Use external toolsUsing external tools is ultimately about delegating certain tasks (such as obtaining up-to-date information or checking facts from a more reliable source of truth) to external tools. This has the objective of greatly reducing the model’s degrees of freedom, by essentially providing the model with parts of the answer.
  6. Test changes systematicallyThis last strategy is really a tip for operationalizing prompt engineering by establishing evaluation procedures.


I recommend a thorough read of [2] for a more complete picture, but I hope this article gave you some inspiration for a mental framework with which to approach prompt engineering.


References

[1] https://arxiv.org/abs/2102.06391

[2] https://arxiv.org/abs/2102.07350

[3] https://platform.openai.com/docs/guides/prompt-engineering

Patrick Couch

AI Business Developer, Sales Specialist & Public Speaker

1 年

I love your posts! Clear, concise, informative. As always, #keepposting! ??????

要查看或添加评论,请登录

Victor Dantas的更多文章

  • GPT-4 and PaLM in 500 words

    GPT-4 and PaLM in 500 words

    What's new about GPT-4? Main enhancements: Multimodal input, accepting now both image and text. Better guardrails so…

  • Web3 for Cloud Architects

    Web3 for Cloud Architects

    I’ve observed that most articles on the Internet about web3 fall under 3 categories: The speculative: the tokenomics of…

    1 条评论
  • Cloud Networking: Azure vs GCP

    Cloud Networking: Azure vs GCP

    This article is an attempt to distill the differences between Microsoft Azure and Google Cloud Platform (GCP) when it…

    6 条评论
  • Using Tensorflow to apply machine learning on any CSV dataset (and beating Google's AutoML)

    Using Tensorflow to apply machine learning on any CSV dataset (and beating Google's AutoML)

    On a previous article, Using Google AutoML Tables to predict house prices in Stockholm, I discussed the use of Google…

    2 条评论
  • Using Google AutoML Tables to predict house prices in Stockholm

    Using Google AutoML Tables to predict house prices in Stockholm

    Introduction I have been lately very interested in learning more about Artificial Intelligence (AI) and Machine…

    2 条评论

社区洞察

其他会员也浏览了