How To Write Effective AI Prompts (Updated)
2024-1-25 01:21:6 Author: danielmiessler.com(查看原文) 阅读量:25 收藏

Click for fullscreen

If you want AI to work for you, you have to know how to talk to it.

I’ve been grinding on AI since November 2022, and I recently taught a 3-hour live course on how I’ve integrated AI into my everyday workflows. One of the topics I covered was how to create concise and effective prompts.

Here’s some detail on each of these points.

I use Markdown because it’s simple, and simple is good for reading/editing.

One of the most important things about prompts is transparency. They have to be legible and super easy to read and edit. Markdown is perfect for that.

A prompt written in Markdown

As you can see above, this format makes it super clear what’s going on. You have clear sections at different levels, combined with numbered and bulleted lists.

Markdown is a human-first format

Most LLMs seem to also like Markdown because it’s easy to parse, e.g., lists of steps, hierarchical instructions, etc.

LLMs love Markdown for the same reason that humans do—because it’s easy to understand.

Clear formatting → Clear thinking → Better Prompts

The clearer you make prompts for yourself, the clearer they are for the AI as well.

I tell the LLM who it is, e.g., give it a role

When you tell an AI that it’s an astronaut, you’re priming it with all the knowledge in the model about that topic. That means it’ll give far better answers.

I often use the “take a step back and think step by step” setup

After I define the role of the AI, I then tell it to:

Take a step back and think step by step about how to achieve the best outcome.

There was a competition between prompting techniques and this one beat out dozens of other techniques!

I break things into small, discrete steps

After I define my role and tell the AI to think step-by-step, I then give it those steps one by one.

Each step should do only one thing and work with the one above and below it

I often don’t even use a user prompt

I’ve actually started using the system prompt almost exclusively. It’s taken more seriously by LLMs and I tend to get much better results.

I tell it exactly how I want the output to look

I am very clear about how I want the output to look. The clearer the better.

I also give examples of good output if it might be confusing

One of the best things you can do with an AI is give examples. And it’s especially good if you do both 1) great instructions, and 2) great examples of output at the same time.

EXAMPLE OUTPUT

- Nabisco (nabisco.com)
- Coke (coke.com)
- Cars (cars.com)

END EXAMPLE OUTPUT

I try to use as few words as possible; LLMs easily confused with too many instructions

Be as concise as you can. You might think saying more will help, but it often just confuses it.

You only output Markdown.

I’m a little rough with it (do this!, don’t do this!)

LLMs prefer being told what to do rather than having to think for themselves.

Be explicit in what you like and don’t like about what they’ve done.

The results of a clean prompt (click for fullscreen)

  1. I use Markdown because it’s simple, and simple is good for reading/editing

  2. Most LLMs seem to also like Markdown because it’s easy to parse, e.g., lists of steps, hierarchical instructions, etc.

  3. I tell the LLM who it is, e.g., give it a role

  4. I often use the “take a step back and think step by step” setup

  5. I break things into small, discrete steps

  6. I often don’t even use a user prompt

  7. I tell it exactly how I want the output to look

  8. I also give examples of good output if #7 might be confusing

  9. I try to use as few words as possible; LLMs easily confused with too many instructions

  10. I’m a little rough with it (do this!, don’t do this!)

If you combine all these techniques, your prompting game will upgrade multiple levels, and so will your results.


文章来源: https://danielmiessler.com/p/how-i-write-prompts
如有侵权请联系:admin#unsafe.sh