Prompting Techniques in AI

Prompt Engineering is the process of talking to an AI model in order to get a task done. The input given to an AI model is called a prompt. How a prompt is designed is important as it drives the accuracy and quality of the output produced by the model.

Here are the different prompting techniques used for creating exceptional prompts :

  • Zero-shot prompting
  • One-shot prompting
  • Few-shot prompting
  • Role-based prompting
  • Chain-of-Thought prompting

Zero-shot prompting:

Zero-shot prompting is when an end-user asks an AI model to perform a task without providing any examples to it. If one has interacted with an LLM model like ChatGPT, one has used zero-shot prompting without realizing it. Zero-shot prompting is the most basic type. Also known as direct prompting. 

Example of zero-shot prompting : 

What is the origin of cotton fabric?

Rephrase the statement – Let me know if you are facing issues in the report.

Wish a colleague on completing 5 years in the company.

Explain the function of grep in bash

When the model is expected to do a common or simple task, zero-shot prompting can be leveraged.

One-shot prompting:

The AI model is provided exactly one example of what it is expected to do for the rest of the prompts. In the example both the input and the expected output are provided. This enables some in-context learning for the model.

Example :

The AI model learns from the provided example and mimics the same approach, format and style for the upcoming prompts.

Few-shot prompting

Few-shot prompting is similar to one-shot prompting but more than one example is provided to the model. This prompting technique is useful when one example is not enough to provide context to the AI model. It is used in cases where the model is provided multiple scenarios.


In the example above, the model has been provided with an instruction followed by three examples of how it should handle different customer queries. As shown above, the model learns from the examples and has tailored the response according to the provided prompt examples.

Role-based prompting

The model is asked to assume a certain role and handle the prompts. The model can be asked to take on any role like be a poet, be a news reporter etc. 

Chain-of-Thought prompting

Chain-of-Thought technique is useful in the case of complex problems. The model is provided with context learning by breaking down a complicated problem into steps. This allows the AI model to attempt the same approach while solving. This approach can also be used when solving arithmetic problems.



Zero-shot Chain-of-Thought prompting

When the model is asked to think step-by-step as an instruction along with a zero-shot prompt, it results in enabling the model to think in terms of steps and generally produces a more accurate answer than if the step-by-step instruction was not provided.

Example:


Published by: Urvashi Poonia