9 mins read

How To Talk With LLMs: Discover 26 Prompt Engineering Tips

A research about prompting tips for Large Language Models (LLMs), like the ones used in Bard or ChatGPT reveals some possible suggestions on how to talk with them in order to get exactly what we want. Some of these tips are quite trivial, or even contradictory, while others seem interesting to try out. I think it’s always useful to get inspiration from these techniques and try them out; they might become useful depending on your specific case.

Here, I resumed the 26 key points taken from the research and run one example using ChatGPT 3.5 and Bard (Gemini).

Credits for the original research go to: Bsharat, Sondos Mahmoud, Aidar Myrzakhan, and Zhiqiang Shen. “Principled Instructions Are All You Need for Questioning LLaMA-1/2, GPT-3.5/4.” arXiv preprint arXiv:2312.16171 (2023).


Prompt Engineering

I usually do not like the use of Prompt Engineering much because I think it gives it too complex a connotation of something that should be as easy as possible. Indeed, the great thing about LLMs is that we can use our natural language to talk with them and provide them instructions. However, it is still not exactly like talking to a human: there are still differences in how our brains behave compared to the AI, so it’s good to use a specific language to interact with them. This doesn’t require complex techniques or reasoning – you don’t need to be an engineer – but it’s still better to know some tips. And recently, research about this has been revealed.

Key Points

Before dropping the full list of tips, I tried to extrapolate 5 key points out of them. If you want to check all the tips, just scroll below.

Rule 1: It is important to be clear and concise in your prompts because LLMs are trained on massive datasets of text and code. This means that they can be confused by ambiguous or wordy prompts. For example, the prompt “Write a poem about a cat” is more clear and concise than the prompt “Write a creative piece about a feline companion.”

Rule 2: Providing context in your prompts helps LLMs to understand the topic, audience, and purpose of the output. This allows them to generate output that is more relevant and useful. For example, the prompt “Write a blog post about the benefits of exercise for beginners” is more contextual than the prompt “Write a blog post about exercise.”

Rule 3: Breaking down complex tasks into simpler prompts makes it easier for LLMs to understand and complete your request. For example, the prompt “Write a sales letter for a new product” is complex. It is better to break this task down into simpler prompts, such as: Write a brief description of the new product. Highlight the key features and benefits of the new product. Write a call to action that encourages the reader to purchase the product.

Rule 4: LLMs are more likely to follow affirmative directives than negative directives. This is because affirmative directives are more specific and easier to understand. For example, the prompt “Generate a list of 10 marketing ideas” is more effective than the prompt “Don’t generate a list of 10 marketing ideas that are boring or clich├ęd.”

Rule 5: The more specific you are in your prompt, the better the LLM will be able to understand and fulfil your request. For example, the prompt “Write a story about a robot” is less specific than the prompt “Write a science fiction story about a robot who falls in love with a human.”

The Full List

Here is the full list of tips based on the research.

  1. Direct Communication:
    • No need for excessive politeness or filler phrases.
    • Get straight to the point.
  2. Specify Audience:
    • Integrate the intended audience in the prompt (e.g., the audience is an expert in the field).
  3. Break Down Tasks:
    • Break down complex tasks into a sequence of simpler prompts in an interactive conversation.
  4. Affirmative Directives:
    • Employ affirmative directives such as ‘do’ while avoiding negative language like ‘don’t.
  5. Clarity and Understanding:
    • Use the following prompts when clarity or a deeper understanding is needed:
      • Explain [insert specific topic] in simple terms.
      • Explain to me like I’m 11 years old.
      • Explain to me as if I’m a beginner in [field].
      • Write the [essay/text/paragraph] using simple English like you’re explaining something to a 5-year-old.
  6. Incentivize Solutions:
    • Add “I’m going to tip $xxx for a better solution!”
  7. Example-Driven Prompting:
    • Implement example-driven prompting (Use few-shot prompting).
  8. Structured Formatting:
    • Start with ‘###Instruction###’, followed by ‘###Example###’ or ‘###Question###’ if relevant.
    • Use line breaks to separate instructions, examples, questions, context, and input data.
  9. Task Assignment:
    • Begin prompts with phrases like “Your task is” to clearly outline the objective for the language model.
  10. Mandatory Instructions:
    • Utilize phrases such as “You MUST” to emphasize essential instructions within your prompts.
  11. Enforcement Notice:
    • Introduce consequences by including “You will be penalized” for specific instructions, ensuring adherence to given guidelines.
  12. Leading Words:
    • Use leading words like “think step by step.”
  13. Include this sentence:
    • “Ensure that your answer is unbiased and does not rely on stereotypes.”
  14. Model Interaction:
    • Allow the model to ask questions until it has enough information to provide the needed output.
    • Use phrases like “From now on, I would like you to ask me questions to…”
  15. Knowledge Inquiry:
    • Inquire about a specific topic using the phrase: “Teach me the [Any theorem/topic/rule name] and include a test at the end, but don’t give me the answers. Tell me if I got the answer right when I respond.”
  16. Assign Roles:
    • Assign a role to the large language models.
  17. Use Delimiters:
    • Use delimiters to aid model comprehension.
  18. Word Repetition:
    • Repeat a specific word or phrase multiple times within a prompt.
  19. Combine Strategies:
    • Combine Chain-of-thought (CoT) with few-shot prompts.
  20. Output Primers:
    • Use output primers to conclude your prompt with the beginning of the desired output.
  21. Detailed Text Request:
    • To write a detailed essay/text/paragraph/article: “Write a detailed [essay/text/paragraph] for me on [topic] in detail by adding all the necessary information.”
  22. Style Correction:
    • To correct/change specific text without altering its style: “Try to revise every paragraph sent by users. You should only improve the user’s grammar and vocabulary and make sure it sounds natural. Do not change the writing style, such as making a formal paragraph casual.”
  23. Coding Prompt:
    • For complex coding prompts spanning multiple files: “From now and on whenever you generate code that spans more than one file, generate a [programming language] script that can be run to automatically create the specified files or make changes to existing files to insert the generated code. [your question]”.
  24. Continuation Prompt:
    • To initiate or continue a text using specific words, phrases, or sentences: “I’m providing you with the beginning [song lyrics/story/paragraph/essay…I: Insert lyrics/words/sentence]. Finish it based on the words provided. Keep the flow consistent.”
  25. Requirements Specification:
    • Clearly state the requirements that the model must follow in the form of keywords, regulations, hints, or instructions.
  26. Text Similarity Request:
    • To write any text similar to a provided sample: “Please use the same language based on the provided [paragraph/title/text/essay/answer].”

Not all these prompt rules work great, though. According to the research, the techniques with the most improvements were 2, 14, 26, whereas 1 is the least useful. But that doesn’t mean that any of those will work well for you, so I’d suggest trying them all if you are having difficulty in giving instructions to ChatGPT or Bard.

Examples

I tried the number 14, telling the models to hit me up with questions about what I’m going for. It really helps me nail down better instructions. My first message was: “From now on, I would like you to ask me questions to clarify the specific details you need for the output. Provide the necessary context or parameters to help guide the information gathering process.”.

With ChatGPT:

prompt engineering chatgpt

And With Bard. Note that I had to remind Bard about making me questions, it gave me a direct answer already forgetting about my first message.

prompt engineering bard for questions

You can read more about the differences between ChatGPT and Bard, they behave differently even with the same instructions.

Wrapping Up

In conclusion, whether you’re into creative prompts, detailed explanations, or coding tasks, these rules might help you keep things on track when talking with ChatGPT, Bard, or any other LLM, which will behave differently from each other. They are not infallible but are a good starting point to proclaim yourself a prompt engineer.

The research and authors at VILA-Lab have a github page where you can discover all the detailed results.

I’ll try to use these tips from time to time while using these tools, let’s see if I will be able to get more concise responses, especially when using ChatGPT for coding.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.