Prompt Design Tips

Tips

Clarity of Instructions

  • Be concise, but be as specific as you can and well-defined
  • Repeat instructions at the end of the prompt. (In a large prompt, the model can start to forget the instructions provided at the beginning.) Just changing the order of instructions in a prompt can have a large impact.

Knowledge Doping

  • Augment the model with information retrieval via embeddings search or APIs
  • Include relevant examples of good responses from user feedback or customer/channel signals - this feedback loop can be used for knowledge doping in the prompt, or finetuning the model
  • Provide reference text.

Chain of Thought Prompting

  • Asking the model to provide reasoning dramatically improves question answering performance
  • Ask for one task at a time. Complex, multi-step tasks should be broken down into a chain of prompt-response-input to next task steps. Writing the steps out explicitly can make it easier for the model to follow them. For example, Use intent classification to identify the most relevant instructions for a user query
  • Turn generative tasks into classification tasks
  • Give the model time to “think”. Instruct the model to work out its own solution before rushing to a conclusion.
  • Use inner monologue or a sequence of queries to hide the model’s reasoning process.

Specify Output Format

  • Use delimiters to clearly indicate distinct parts of the input - Delimiters like triple quotation marks, XML tags, section titles, etc. can help demarcate sections of text to be treated differently.
  • Specify the desired length of the output.

Iteration and Experimentation

  • Invest time in testing combinations of ordering and structure, not just a change of language in the prompt.
  • Use formal experiments to evaluate alternative prompt designs.
  • Model choice can impact the performance of prompts. Test prompts against a new model version from the same provider, or across providers.

General Design Tips

  • ChatGPT models are not always good at negation. For example, the following prompt Avoid any use of "Say hello" or "Say goodbye" actually resulted in more instances of those terms in outputs.
  • First ask the model to adopt a persona. For example, “You are a senior copywriter for a marketing agency, writing award-winning ads and marketing material that evokes a strong emotional attachment from its target audience.”

Examples

  1. Use delimiters to clearly indicate distinct parts of the input
USER
Summarize the text delimited by triple quotes as a haiku.

"""insert text here"""
  1. Specify the steps required to complete a task
SYSTEM
Use the following step-by-step instructions to respond to user inputs.

Step 1 - The user will provide you with text in triple quotes. Summarize this text in one sentence with a prefix that says "Summary: ".

Step 2 - Translate the summary from Step 1 into Spanish, with a prefix that says "Translation: ".

USER
"""insert text here"""
  1. Specify the desired length of the output
USER
Summarize the text delimited by triple quotes in 3 bullet points.

"""insert text here"""
  1. Instruct the model to answer using a reference text
SYSTEM
Use the provided articles delimited by triple quotes to answer questions. If the answer cannot be found in the articles, write "I could not find an answer."

USER
<insert articles, each delimited by triple quotes>

Question: <insert question here>
  1. Use intent classification to identify the most relevant instructions for a user query

Suppose for example that for a customer service application, queries could be usefully classified as follows:

SYSTEM
You will be provided with customer service queries. Classify each query into a primary category and a secondary category. Provide your output in json format with the keys: primary and secondary.

Primary categories: Billing, Technical Support, Account Management, or General Inquiry.

Billing secondary categories:
- Unsubscribe or upgrade
- Add a payment method
- Explanation for charge
- Dispute a charge

Technical Support secondary categories:
- Troubleshooting
- Device compatibility
- Software updates

Account Management secondary categories:
- Password reset
- Update personal information
- Close account
- Account security

General Inquiry secondary categories:
- Product information
- Pricing
- Feedback
- Speak to a human

USER
I need to get my internet working again.

Based on the classification of the customer query, a set of more specific instructions can be provided to a GPT model to handle next steps. For example, suppose the customer requires help with “troubleshooting”.

This example uses a Semantic Search Index to find the relevant help context given the classification above.

SYSTEM
You will be provided with customer service inquiries that require troubleshooting in a technical support context. Help the user by:

- Ask them to check that all cables to/from the router are connected. Note that it is common for cables to come loose over time.
- If all cables are connected and the issue persists, ask them which router model they are using
- Now you will advise them how to restart their device:
-- If the model number is MTD-327J, advise them to push the red button and hold it for 5 seconds, then wait 5 minutes before testing the connection.
-- If the model number is MTD-327S, advise them to unplug and replug it, then wait 5 minutes before testing the connection.
- If the customer's issue persists after restarting the device and waiting 5 minutes, connect them to IT support by outputting {"IT support requested"}.
- If the user starts asking questions that are unrelated to this topic then confirm if they would like to end the current chat about troubleshooting and classify their request according to the following scheme:

<insert primary/secondary classification scheme from above here>

USER
I need to get my internet working again.