Skip to content

🧱 Prompt Elements

Abstract

This chapter covers different prompt elements like instruction, persona (role), context, exemplar, format, tone, constraint, data, technique etc.

🦜 Video lecture for this chapter - Link

A prompt is a text input given to the chatbot. In general, a prompt consists of multiple elements like instruction, persona (role), context, exemplar, format, tone, constraint, data, technique etc. Each of these elements has a specific purpose and conveys some information to the chatbot.

For example, the instruction element provides the task description information specifying what the chatbot has to do. Similarly, the persona and context elements provide necessary background information to the chatbot.

It is essential to have a good understanding of each of these elements to write effective prompts. An effective prompt which consists of all or some of these elements guides the chatbot to better understand the user requirements and generate the output accordingly.

Prompt elements.

The following table contains a brief overview of various prompt elements.

Element Specify
Instruction Task Description
Persona, Context Background Information
Exemplar Example
Format, Tone, Constraint Output Specifications
Delimiters Syntax
Data Input Data
Technique Approach

The instruction element provides the task description. The persona and context elements provide the necessary background information. The exemplar element provides examples which serve as a reference for output generation.

Format, tone and constraint elements dictate the output specifications. The data element provides the input data which is to be processed by the chatbot. The technique element specifies the approach to be used by the chatbot to generate the desired output.

Let us see a detailed description of each of these elements.

✒️ Instruction

Instruction is the most important element in the prompt. The instruction element specifies what the chatbot has to do. It can be answering a query or performing a task.

Instruction can be specified in one or two sentences but the instruction should (i) always start with an action verb and (ii) be clear & specific without any ambiguity.

🍿 Example 1:

In the prompt, “What is the capital of Australia?” . Here the instruction is to answer the given query asking for the capital of Australia.

🍿 Example 2:

In the prompt, “Generate a bulleted list of pros and cons of ChatGPT” . Here the instruction is to perform the task of generating a bulleted list of pros and cons of ChatGPT.

To summarize, the instruction element is the core of the prompt which describes what the chatbot has to do.

✒️ Persona

The persona element provides background information by specifying a role that the chatbot has to adopt while generating the response. By specifying a role-based identity to the chatbot, the chatbot generates the response which aligns with the role i.e., the chatbot generates the responses as if the responses are generated by that role.

Let us understand persona element with the following two examples.

🍿 Example 1:

  • Consider the prompt, “Imagine you are an expert AI research scientist specialized in natural language processing. Tell me how to start with NLP research”.
  • Here the prompt assigns the role of “expert AI research scientist” to the chatbot so that the chatbot generates the response as if the response is generated by an expert AI research scientist.

🍿 Example 2:

  • Consider the prompt, “As a professor of English, tell me how to improve my communication and writing skills in English”.
  • Here the prompts ask the chatbot to take the role of “Professor of English” and then generate the response.

To summarize, the persona element provides additional background details by assigning a role to the chatbot so that the chatbot generates more relevant responses.

✒️ Context

The context element provides the necessary background information by specifying the situation or the scenario in which the chatbot has to generate the response. By specifying the context, the chatbot understands that it has to generate the output according to the specified situation.

Let us understand the context element with the following two examples.

🍿 Example 1

  • Consider the prompt, “Considering the rise of advanced chatbots like ChatGPT and Bard, summarize the challenges of chatbots”. Here, the context is “considering the rise of advanced chatbot models like ChatGPT and Bard”.
  • Here, without the context, the chatbot may generate challenges that may not be relevant to the recent scenario.

🍿 Example 2

  • Consider the prompt, “I’m completely new to programming. Suggest me a roadmap to learn Python”. Here the context is “I’m completely new to programming”.
  • Without the context, the chatbot may generate a roadmap to learn Python which may not be suitable for a newbie.

To summarize, the context element provides the necessary background information which helps the chatbot to generate the desired output.

✒️ Exemplar

The exemplar element provides hints in the form of examples to the chatbot for desired output generation. Here examples are the references or samples for the desired output to be generated. By providing the examples, the chatbot generates the output which resembles the examples in terms of format, style and content.

Let us understand the exemplar element with the following example.

Prompt

Generate three questions and answers from the given paragraph similar to the given examples.

Paragraph: Artificial intelligence (AI) is like having a super helpful and smart robot friend! Imagine trying 
to learn a new language, like French. AI can help by translating things for you, suggesting the best words 
to use, and even checking your grammar. It's like having a personal language tutor, but way faster and more 
efficient! Just like AI can help with languages, it can be used to do lots of other amazing things, like driving 
cars, diagnosing diseases, and even composing music!

Examples: Q: What is AI compared to?  A: AI is compared to a super helpful and smart robot friend.
Here, without the exemplar element, the chatbot may generate lengthy questions.

✒️ Format

The format element defines the layout and structure of the chatbot output. When the format element is included in the prompt, the chatbot presents the generated output according to the formatting instructions specified in the format element.

Without the format element, the chatbot may generate the output in a random way which needs to be formatted later according to the requirements. To avoid this, it is always recommended to include the format element to get the chatbot output in the desired structure.

Let us understand the format element with the following examples.

🍿 Example 1:

  • Consider the prompt “Generate a bulleted list of exercises to do in the morning”.
  • Here the “a bulleted list” is the format element specifying the chatbot to present the generated exercises information in the form of a bulleted list.

🍿 Example 2:

  • Consider the prompt “Summarize the challenges of artificial intelligence. Use h3 headings for the challenges”.
  • Here, “h3 headings” is the format element.

To summarize, the format element guides the chatbot regarding the presentation of the generated text output.

✒️ Constraint

The constraint element specifies the restrictions on the output to be generated. Here the restrictions can be a limit on the word count, a limit on the character count, words to exclude, words to include etc. Without constraints element, the chatbot may generate the output in its way which need not align with the user requirements.

Let us understand the constraint element with the following examples.

🍿 Example 1:

  • Consider the prompt “Generate a tweet about Australia’s victory in Cricket World Cup 2023. Keep it within 280 characters with relevant hashtags and emojis”.
  • Here “Keep it within 280 characters” is the constraint element.

🍿 Example 2:

  • Consider the prompt “Generate an essay about the introduction to artificial intelligence. Make sure to limit the number of words to 100”.
  • Here, “Make sure to limit the number of words to 100” is the constraint element.

To summarize, the constraint element dictates the restrictions on the output to be generated.

✒️ Tone

The tone element specifies the style in which the output should be generated. Here the style can be formal, friendly, instructive, casual, serious, humorous etc. Suppose, you are writing an email to your friend, the tone can be friendly or informal. In the case of writing an email to your professor, the tone has to be formal.

Let us understand the tone element with the following examples.

🍿 Example 1:

  • Consider the prompt “Write an email in a formal tone to the professor thanking her for great guidance in the project work”.
  • Here the tone element “formal tone” asks the chatbot to write the email in a formal tone.

🍿 Example 2:

  • Consider the prompt “Generate a tweet in a satirical tone regarding the choice of cricket players in the recent auction”.
  • Here the tone element “satirical tone” asks the chatbot to generate the tweet in a satirical tone.

To summarize, the tone element dictates the style of the generated output.

✒️ Delimiter

The delimiter element is used to define the syntax of the prompt by using special characters or words to structure the different elements of the prompt. The delimiters (characters or words) separate the different elements of the prompt, help the chatbot to better parse and understand the prompt and then generate the desired output.

Some examples of character delimiters are period, comma, double quotes, triple quotes, single quotes, asterisk etc. Similarly, some examples of word delimiters are paragraph, tweet, etc.

Let us get more clarity regarding the delimiter element from the following examples.

🍿 Example 1:

  • Consider the prompt “Translate the given text from English to Tamil: Hello, how are you? I am fine, thank you”.
  • Here the delimiter is : and it helps separate the instruction from the input data.

🍿 Example 2:

  • Consider the prompt

    Generate three questions and answers from the given paragraph similar to the given examples.
    
    Paragraph: Artificial intelligence (AI) is like having a super helpful and smart robot friend! Imagine 
    trying to learn a new language, like French. AI can help by translating things for you, suggesting the best 
    words to use, and even checking your grammar. It's like having a personal language tutor, but way faster 
    and more efficient! Just like AI can help with languages, it can be used to do lots of other amazing 
    things, like driving cars, diagnosing diseases, and even composing music!
    

  • Here the word delimiter “paragraph:” highlights that the following text is the paragraph which the chatbot has to use as the reference text from which it has to generate the questions and answers.

To summarize, delimiters help to structure the different prompt elements so that the chatbot can better parse and understand the input prompt.

✒️ Data

The data element specifies the input data which is to be processed by the chatbot to generate the expected output. For example, in the case of generating an email response, the input data is the email received based on which the chatbot has to generate the reply email.

Similarly, in the case of text translation, the input data is the text in the source language.

Let us get some more clarity regarding the data element through the following examples.

🍿 Example 1:

  • Consider the prompt : Translate the given text from English to Tamil: “Hello, how are you? I am fine, thank you”.
  • Here the data is the text in the source language (English) i.e., “Hello, how are you? I am fine, thank you”.

🍿 Example 2:

  • Consider the prompt
    Summarize the given text in one line. 
    Text: “Generative artificial intelligence is a subset of AI that focuses on creating or generating content, 
    such as images, text, or even music, autonomously. It employs various techniques like deep learning and 
    neural networks to produce novel and creative outputs, often indistinguishable from human-made content. 
    This technology has applications in areas like art generation, text completion, and data synthesis.”.
    
  • Here the data is the given text which is to be summarized.

✒️ Technique

The technique element specifies the approach the chatbot has to use to generate the desired output. For simple tasks like generating a tweet, summarizing the text, translating the text etc., the user need not specify the technique element.

However, for complex tasks like solving a maths problem, answering a reasoning problem etc, specifying the technique helps the chatbot to generate the desired output.

Let us get more clarity through the following examples.

🍿 Example 1:

Prompt

Solve the following math problem:

Find the value of x in the equation:

3x + 5 = 17     

Let's think step by step.

Output

Of course, let's solve the equation step by step:

**Equation:**
3x + 5 = 17

**Step 1:** Isolate the variable term.

Subtract 5 from both sides of the equation to get rid of the constant term on the left side:

3x + 5 - 5 = 17 - 5

This simplifies to:

3x = 12

**Step 2:** Isolate the variable.

To isolate x, divide both sides by 3 (the coefficient of x):

(3x) / 3 = 12 / 3

This simplifies to:

x = 4

So, the solution to the equation 3x + 5 = 17 is x = 4.

🍿 Example 2:

Prompt

Identify the sentiment in the given tweet. Tweet: Tweet: ☀️ **Starting the day off with a grateful heart 
and a positive mind. Today is going to be a great day!** #positivevibes #newbeginnings #mindsetmatters.

Let’s think step by step.

Output

**Step 1:** Identify Keywords and Phrases

- "grateful heart"
- "positive mind"
- "great day"
- Hashtags like #positivevibes, #newbeginnings, and #mindsetmatters.

**Step 2:** Contextual Analysis

The keywords and phrases in this tweet convey a very positive and optimistic tone. The use of words like 
"grateful," "positive," and "great day" all indicate a positive sentiment. Additionally, the use of hashtags 
like #positivevibes and #newbeginnings reinforces the positive and optimistic outlook of the tweet.

**Step 3:** Sentiment Identification

The sentiment in the tweet is clearly **positive**. It reflects a positive and upbeat attitude, expressing 
gratitude and optimism for the day ahead.

So, the sentiment in the tweet is positive.

In the above two examples, let’s think step by step is the technique specified. This technique instructs the chatbot to solve the given task in a step-by-step manner.