DEV Community

Cover image for Iterative Prompt Development: Iteratively analyse and refine your prompts
Shan for Arkroot

Posted on • Edited on

Iterative Prompt Development: Iteratively analyse and refine your prompts

Note: This is a documented version of ChatGPT Prompt Engineering for Developers course. You can find the course here.

Note: This article is pretty boring. I have added a general summary here for all those who don't have time to read this.

In this article, we will see how to iteratively analyse and refine prompts to generate marketing copy from a product fact sheet. We will start with a simple prompt that generated a long, rambling text. We then iteratively will refine the prompt to limit the number of words, focus on the relevant details, and include the product IDs. Finally, we will add a table of dimensions. By following this iterative approach, we will be able to generate a concise and polished output that meets the needs of the marketing team. This is based on the example that is mentioned in the course.

Note: Before reading this please try to read two another articles which is part of this course. It will give you a general guidelines on how to interact with LLM in a better way.

Note: In this Article, you'll learn how to iteratively analyse and refine prompts.

We will iteratively analyse and refine our prompts to generate marketing copy from a product fact sheet.

fact_sheet_chair = """
OVERVIEW
- Part of a beautiful family of mid-century inspired office furniture, 
including filing cabinets, desks, bookcases, meeting tables, and more.
- Several options of shell color and base finishes.
- Available with plastic back and front upholstery (SWC-100) 
or full upholstery (SWC-110) in 10 fabric and 6 leather options.
- Base finish options are: stainless steel, matte black, 
gloss white, or chrome.
- Chair is available with or without armrests.
- Suitable for home or business settings.
- Qualified for contract use.

CONSTRUCTION
- 5-wheel plastic coated aluminum base.
- Pneumatic chair adjust for easy raise/lower action.

DIMENSIONS
- WIDTH 53 CM | 20.87”
- DEPTH 51 CM | 20.08”
- HEIGHT 80 CM | 31.50”
- SEAT HEIGHT 44 CM | 17.32”
- SEAT DEPTH 41 CM | 16.14”

OPTIONS
- Soft or hard-floor caster options.
- Two choices of seat foam densities: 
 medium (1.8 lb/ft3) or high (2.8 lb/ft3)
- Armless or 8 position PU armrests 

MATERIALS
SHELL BASE GLIDER
- Cast Aluminum with modified nylon PA6/PA66 coating.
- Shell thickness: 10 mm.
SEAT
- HD36 foam

COUNTRY OF ORIGIN
- Italy
"""

Your task is to help a marketing team create a 
description for a retail website of a product based 
on a technical fact sheet.

Write a product description based on the information 
provided in the technical specifications delimited by 
triple hyphen.

Technical specifications: ---{fact_sheet_chair}---
Enter fullscreen mode Exit fullscreen mode

As the prompt is bit big. When I unleashed this on GPT-3, it erupted with a whopping 369 words!😁. I won't be sharing the output here as it's a long text. To limit the number of words to certain limit we can tell GPT to generate at most x amount of words.

The new prompt will be:

Your task is to help a marketing team create a 
description for a retail website of a product based 
on a technical fact sheet.

Write a product description based on the information 
provided in the technical specifications delimited by 
triple hyphen.

Use at most 50 words.

Technical specifications: ---{fact_sheet_chair}---
Enter fullscreen mode Exit fullscreen mode

In this prompt we are mentioning the number of words to GPT to limit the output.

Issue 2 of the generated output: Text focuses on the wrong details.


Your task is to help a marketing team create a 
description for a retail website of a product based 
on a technical fact sheet.

Write a product description based on the information 
provided in the technical specifications delimited by 
triple hyphen.

The description is intended for furniture retailers, 
so should be technical in nature and focus on the 
materials the product is constructed from.

Use at most 50 words.

Technical specifications: ---{fact_sheet_chair}---

Enter fullscreen mode Exit fullscreen mode

Here in this prompt we are asking the model to focus on the aspects that are relevant to the intended audience. Here we need to generate the description for furniture retailers.

Output:

Limit Words Generated

We can further improve this prompt to attach the product ids in the description. The updated prompt will be:

"""
Your task is to help a marketing team create a 
description for a retail website of a product based 
on a technical fact sheet.

Write a product description based on the information 
provided in the technical specifications delimited by 
triple hyphen.

The description is intended for furniture retailers, 
so should be technical in nature and focus on the 
materials the product is constructed from.

At the end of the description, include every 7-character 
Product ID in the technical specification.

Use at most 50 words.

Technical specifications: ---{fact_sheet_chair}---
"""

Enter fullscreen mode Exit fullscreen mode

Output:

Output with product id

Issue 3 - Description needs a table of dimensions

We can ask the model to generate a table for us along with the description. Here we will be generating a table of dimensions.

Your task is to help a marketing team create a 
description for a retail website of a product based 
on a technical fact sheet.

Write a product description based on the information 
provided in the technical specifications delimited by 
triple hyphen.

The description is intended for furniture retailers, 
so should be technical in nature and focus on the 
materials the product is constructed from.

At the end of the description, include every 7-character 
Product ID in the technical specification.

After the description, include a table that gives the 
product's dimensions. The table should have two columns.
In the first column include the name of the dimension. 
In the second column include the measurements in inches only.

Give the table the title 'Product Dimensions'.

Format everything as HTML that can be used in a website. 
Place the description in a <div> element.

Technical specifications: ---{fact_sheet_chair}---
Enter fullscreen mode Exit fullscreen mode

Output generated is in HTML. I am not going to add the screenshot here as the output is a bit long. You can copy and paste this prompt to know how the output will look like.

Here is another example of how the iterative approach can be used to improve the quality of generated outputs. Let's say you want to write a poem about a flower. Your first prompt might be something like this:

Write a poem about a flower.
Enter fullscreen mode Exit fullscreen mode

This prompt is too general and will likely result in a poem that is not very specific or creative. To improve the prompt, you could add more details about the flower, such as its colour, shape, or smell. You could also specify the tone of the poem, such as whether you want it to be happy, sad, or reflective.

Write a happy poem about a red lily.
Enter fullscreen mode Exit fullscreen mode

This prompt is more likely to result in a poem that is both specific and creative. Once you have written the poem, you can then evaluate it and see if it meets your needs. If not, you can iterate on the prompt and try again until the desired output is achieved.

Top comments (0)