Prompt Best Practices

The purpose of this guide is to provide comprehensive insights and practical recommendations for crafting effective prompts when interacting with AI agents. By understanding the significance of well-structured prompts and leveraging best practices, you can optimize the GenAI agents you are building, leading to more accurate and tailored responses. Effective prompt writing is pivotal in facilitating clear and meaningful interactions with GenAI agents, enabling you to convey their intents precisely and ultimately improving the overall end-user experience.

1. Write Clear Instructions

Overview:

AI models cannot read your mind. Clear and concise instructions are crucial for obtaining the desired output. If outputs are too long, ask for brief replies. If they are too simple, request expert-level writing.

Strategies:

  • Include Details: Specify your query details to get more relevant answers.
  • Adopt a Persona: Ask the model to assume a specific role or persona.
  • Use Delimiters: Clearly indicate distinct parts of the input.
  • Specify Steps: Outline the steps required to complete a task.
  • Provide Examples: Give examples to illustrate the desired output.
  • Define Length: Specify the desired length of the output.

 

2. Provide Reference Text

Overview:

Providing reference text can help reduce fabrications and improve the accuracy of the AI's responses. This is particularly useful when dealing with esoteric topics or requiring citations.

Strategies:

  • Use Reference Text: Instruct the model to answer using a specific reference text.
  • Citations: Instruct the model to provide answers with citations from the reference text.

 

3. Split Complex Tasks

Overview:

Complex tasks tend to have higher error rates. Breaking them into simpler, modular tasks can improve accuracy and manageability.

Strategies:

  • Intent Classification: Identify the most relevant instructions for a user query.
  • Dialogue Summarization: Summarize or filter previous dialogue in long conversations.
  • Recursive Summarization: Summarize long documents piecewise to construct a full summary.

 

4. Guidelines for Writing Effective Prompts

Overview:

When interacting with an AI agent's prompt, it's beneficial to use a language in which you are comfortable expressing your needs. Our AI Agent can comprehend and respond to prompts in multiple languages, ensuring that language choice does not negatively impact response capability. Utilize clear and comprehensible language to articulate prompts. Be mindful of the linguistic preferences of the AI agent and ensure that the language used effectively conveys the intended message.

Strategies:

  • Content Clarity and Specificity

Craft prompts with explicit and detailed information, clearly outlining the user's request or query. Avoid ambiguity and strive for precision to enhance the AI agent's understanding of the user's needs.

  • Organizing Paragraphs

Present information in a logically structured manner, arranging paragraphs coherently to facilitate the seamless comprehension of complex requests or multi-step queries.

  • Handling Wrong Information

In the event of identifying inaccuracies in AI responses, provide succinct clarifications within subsequent prompts to enable the AI agent to rectify any erroneous information in subsequent interactions.

  • Proper Use of Special Characters

Exercise discretion when incorporating special characters, utilizing them judiciously for emphasis, clarification, or expression within prompts to enhance communication.

Proper punctuation helps structure your prompt and communicates your expectations to the model more effectively. It can reduce ambiguity and ensure that the model generates responses that align with your intent. However, keep in mind that excessive or incorrect punctuation might confuse the model, so strike a balance between clarity and simplicity.

  1. End punctuation: Use appropriate end punctuation, such as periods and question marks, to signal the type of response you expect. For example:
    1. Tell me about your baggage policies.
    2. What are the main causes of flight cancellations?
  2. Commas: Use commas to separate different parts of a prompt or to make the prompt easier to understand. For example:
    1. In your response, discuss the benefits, drawbacks, and ethical considerations.
    2. Compare and contrast the economic, social, and environmental impacts.
  3. Quotation marks: Use quotation marks to indicate that you want the model to treat a specific portion of text as a quoted or verbatim statement. Quotation marks can also be used to refer to something in the prompt. Also, one common convention is to enclose longer strings in triple quotes. For example:
    1. Succinctly and accurately summarize the conversation in the "text" below:
      text: 
📘

Using quotation marks

"""

{text input here}

"""


5. Give the Model Time to “Think”

Overview:

Models make more reasoning errors when trying to answer immediately. Allowing time for the model to think can improve the quality of the response.

Strategies:

  • Chain of Thought: Encourage the model to work out its solution before concluding.
  • Inner Monologue: Use a sequence of queries to reveal the model’s reasoning process.
  • Review Misses: Ask the model if it missed anything on previous passes.

 

6. Use External Tools

Overview:

Enhance the capabilities of your AI model by supporting it with structured datasets. You can create folders, upload documents, and assign these folders to AI agents, combined with effective file indexing, significantly improves the model’s response accuracy and relevance.

Strategies:

  • Knowledge base:

Provide the AI agent with access to structured datasets/folders uploaded. These folders, once indexed, allow the AI agent to generate more precise and contextually relevant responses.

 

7. Test Changes Systematically

Overview:

Improving performance is easier if you can measure it. Evaluate changes using a comprehensive test suite to ensure they lead to net positive performance.

Strategies:

Gold-Standard Answers: Evaluate model outputs with reference to gold-standard answers.


Summary: By following these guidelines on creating effective prompts, you can greatly improve the quality of interactions with AI agents. Well-defined personas, clear task instructions, engaging tones, organized chat flows, and thoughtful user guidance all play a role in establishing a smooth and positive user experience. Incorporating these principles will guarantee that AI agents deliver precise, welcoming, and effective assistance, leading to enhanced user satisfaction and engagement levels.


What’s Next

On the following page, you will find a selection of effective prompts that you can study and utilize for learning purposes.