Prompt Design in Generative AI

Wipro Tech Blogs
4 min readJan 3, 2025

--

Principles of Effective Prompt Design

Anuj Mehra, Senior Architect, Wipro Limited

Introduction

Prompt in simple words is the way one interacts with LLMs (Large Language Model) to get the desired results. The way you ask questions to the LLM to get the desired, accurate and formatted output is called Prompt Design. Prompt design is a critical skill in leveraging the power of AI which relies on clear, precise and contextualized query to get the desired results. At its core, prompt design requires deep understanding of the AI models strength, structure and limitations. Models interpret inputs contextually, meaning that the phrasing, specificity and tone of the prompt directly influences the outcome. For instance, asking “Describe the causes of climate change in 300 words” will give a more focused response compared to a vague “Explain Climate Change” which would be a very generic response.

Effective Prompt Design follows principles such as clarity, contextualization, and iteration. Clarity ensures AI understands what exactly is being asked; contextualization provides the necessary background or parameters of the task and iteration fine tunes the response from the initial output. Iteration is repeated till we get the desired result.

Prompt Design consists of a structure which details out the components of the prompt for the desired accurate response.

Components of a prompt

1. Core instruction or objective of the prompt

2. Context / Personna provides background information

3. Constraints define the boundaries for AI

4. Output Specification defines the format and structure of output

5. Style or Tone defines the feeling of the o/p like formal, casual

6. Few Shots Examples train AI to classify the given input

7. Iteration to refine the output further

Details of prompt components

1. Core instruction or objective of the prompt: This defines the purpose of the prompt. What the end user wants AI to accomplish for him/her. This is the objective for which the user has written the prompt.

Example:

For writing task: Write a 300-word essay on Bangalore Traffic

For coding task: Write a Hello world code in Python

2. Context / Personna: It provides background information or the context in which to interpret and generate the output. It helps AI to understand the scope and constraints of the query.

Example:

Context for story telling: Imagine a futuristic world where Robots co-exist with humans. Write a story in 300 words to be narrated to creative director

Context for explanation: Explain laws of Newton to a high school student

Assume Personna: Imagine you are CFO of a mid-sized firm. OR assume you are AWS architect. Assume you are a doctor etc.

3. Constraints: define the boundaries within which AI should operate. This could include word count, tone, style or format.

Example:

  • Write a professional email to CXO of a company requesting appointment for Wipro proposal discussion on AWS cloud migration.
  • Generate a creative poem which is romantic and based in Indian village background in southern India.

4. Output Specification: This provides the format, structure and medium of the desired output.

Example:

  • Provide the output as table with three columns named x,y,z or a list or array
  • Provide step by step process to set up cloud CoE

5. Style or Tone: defines the feeling of the output like formal, casual, friendly, persuasive or humorous

Example:

  • Assume you are the CA of the mid-sized firm, write a formal report of the annual revenue and expenditure. Describe in detail the financial health of the company. Report should cover outstanding receivables and asset depreciation. The format should be tabular with bar graphs depicting dip in revenue or increase in expenses year on year

6. Few Shots Examples: serve as templates or demonstrations of the desired output. This is especially true in guiding AI for complex tasks. Few shot examples explicitly tell the AI model, what format, tone and structure the output should look like.

Example

Name: Thumbs up

Type: soft drink

Name: Tea

Type: hot drink

Name: Pepsi

Type: soft drink

Name: Coffee

Type: Hot drink

Name: Coca Cola

Type: ?

7. Iteration: helps refine the existing output. Many iterations may be needed to get the desired output.

Example

The output was good for sources of energy. Can you please provide more details about renewable energy sources

Synthesis of Components

For optimal results, all components of the prompt should work in cohesion. The prompt should be as specific as possible with context, constraint and desired output format of the result.

Example: “Assume you are fitness expert (Personna) with 20 years of experience. Write a 500-word blog post (objective) for fitness enthusiasts (Context / target audience) on the benefits of daily Yoga and meditation. Write in a persuasive style (Style and tone)and explain the mental and physical benefits of Yoga and mindfulness. End the blog post with call to join the fitness regime with early bird discounts (desired output and action)

Conclusion

Prompt design is as much an art as it is a science. Like with all other skills you get better with practice. The same prompt on different models of LLM will give a slightly different output. The exciting part is you can start treating LLM’s as your personal secretary to get the job done for you. You should be a good boss in telling exactly what the co-pilot needs to do. Happy prompting!!!

--

--

No responses yet