Skip to content

🏏 Prompt Design Guide

Abstract

This section covers how to craft different prompt elements (prompt design guide).

🦜 Video lecture for this chapter - Link

The quality (accuracy and relevance) of outputs generated depends largely on the quality of the input prompt i.e., how well the input prompts are crafted. In general, an input prompt consists of many elements like persona, context, instruction, format, tone, constraints etc. Let us see how to properly craft each of these prompt elements.

πŸŒ… Persona

The personal element specifies what role the chatbot has to assume to generate the output. Remember that the more specific and well-defined your persona element is, the better the chatbot can understand and respond appropriately. Here are some of the tips for writing the persona element.

  • Be specific - Clearly define the persona you want the chatbot to take on. This could be a specific character, profession, or role. For example, you can specify, "Assume the persona of a friendly librarian" or "Imagine you are a tech-savvy teenager”.
  • Use descriptive language - Provide a clear description of the persona using adjectives,Β adverbs,Β and illustrative phrases. Example:Β "You are a wise and compassionate therapist with over 20 years of experience helping people navigate life's challenges."
  • Be respectful and ethical - Ensure that the persona you're asking the chatbot to assume is respectful and adheres to ethical guidelines.
  • Mention limitations - If there are any limitations to the persona, such as knowledge restrictions or ethical boundaries, make them clear. For instance, "Provide medical advice, but do not diagnose illnesses" or "Avoid discussing sensitive political topics”.

πŸŒ„ Context

The context element provides the necessary background details for the chatbot to get a better understanding. Here are some of the tips to write the context element.

  • Provide relevant information - Include key details that are directly related to the user's request or question. This could include names, dates, locations, or any specific facts or events that are relevant to the conversation. For example,Β instead of simply saying "I'm planning a trip," provide details like "I'm planning a trip to Thailand for two weeks in July".
  • Be clear and concise - Keep the context element brief and to the point. Avoid unnecessary details or information that may confuse the chatbot.

🌠 Instruction

The instruction element specifies what the chatbot has to do. Here are some of the tips to write the instruction element

  • Be clear and concise - Your instruction should be straightforward and easy to understand. Avoid using complex language or unnecessary jargon.
  • Avoid ambiguity and vagueness - Ensure that your instruction leaves no room for ambiguity as Ambiguous instructions can lead to unexpected or incorrect responses.
  • Use action verbs - Use action verbs to convey the desired action. ****Some of the commonly used action words are: Explain, Describe, List, Summarize, Translate, Write, Classify, Complete, Generate etc.

πŸŽ‡ Exemplar

The exemplar element provides hints in the form of examples to the chatbot for desired output generation. Here are some of the tips to effectively design the exemplar element.

  • Use word delimiters - Use word delimiters to explicitly highlight the input and output.
  • Provide diverse examples - Include multiple exemplars to cover different aspects or variations of the desired output. This helps the model generalize and provide more accurate responses.
  • Balance positive and negative Examples - Include both positive and negative examples to guide the chatbot's behaviour in different scenarios. For instance, in the case of sentiment analysis, include examples for both positive and negative sentiments.

πŸŽ† Format

The format element defines the layout and structure of the output generated. Here are some of the tips to effectively design the format element.

  • Be specific and clear - State the desired format explicitly. Don’t specify what you don’t want. Instead, specify what you want clearly.
  • Use structural keywords - Employ words like "list," "paragraph," "table," "dialogue," etc.,Β to clearly signal the desired format.
  • Leverage placeholders - Use placeholders to indicate where specific information should be inserted. For example, Β "Write a product description in the following format:Β [Title] [Description] [Features] [Benefits]."

πŸŒ‡ Tone

The tone element specifies the style in which the output should be generated. Here are some of the tips to effectively design the tone element.

  • Be explicit - Clearly specify the tone you want in your prompt. Use adjectives and adverbs that describe the tone, such as "formal," "casual," "humorous," "serious," "friendly," or "authoritative."
  • Specify language and style preferences - If you have specific language preferences, mention them in the tone element. For instance, if you want the text to be written in a British English formal style, explicitly state that in your prompt.

πŸŒ‰ Constraints

The constraints element specifies the restrictions on the output to be generated. Here are some of the tips to effectively design the constraints element.

  • Be clear and specific - Clearly define the constraints in your prompt. Use explicit language to specify what is allowed and what is not allowed.
  • Use keywords and phrases - Incorporate keywords and phrases that are relevant to your constraints. These can include words like "must", "should not", "cannot,", "only," etc.

🚨 Data

The data element specifies the input data which is to be processed by the chatbot to generate the expected output. Here are some of the tips to effectively design the data element.

  • Use Delimiters - Use delimiters like tweet, text, QA etc to separate the input data from the rest of the elements in the prompt.
  • Use punctuation marks - Use punctuation marks like single quotes, double quotes, asterisks etc., to explicitly highlight the input data.