ChatGPT Prompting开发实战(七)

一、什么是迭代式的prompt开发

对于一些复杂的任务来说,如果只编写一次prompt来调用模型,不一定能够得到理想的效果,那么可以采用迭代开发的方式,基于每一次使用当前版本的prompt调用模型的效果来不断调整优化prompt,使得prompt的最终版本能够产生满足预期的效果。接下来会给出示例,通过调用模型“gpt-3.5-turbo”来演示并解析这样一个迭代开发prompt的过程。

二、结合案例演示解析prompt迭代开发

案例需求是基于一份产品事实清单来生成一份产品营销文本,具体的产品事实清单如下:

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

"""

首先尝试编写一个最初的prompt版本。

prompt示例如下:

prompt = f"""

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 backticks.

Technical specifications: ```{fact_sheet_chair}```

"""

response = get_completion(prompt)

print(response)

打印输出结果如下:

Introducing our stunning mid-century inspired office chair, the perfect addition to any home or business setting. This chair is part of a beautiful family of office furniture, including filing cabinets, desks, bookcases, meeting tables, and more, all designed with a timeless mid-century aesthetic.

One of the standout features of this chair is the variety of customization options available. You can choose from several shell colors and base finishes to perfectly match your existing decor. The chair is available with either plastic back and front upholstery or full upholstery in a range of 10 fabric and 6 leather options, allowing you to create a look that is uniquely yours.

The chair is also available with or without armrests, giving you the flexibility to choose the option that best suits your needs. The base finish options include stainless steel, matte black, gloss white, or chrome, ensuring that you can find the perfect match for your space.

In terms of construction, this chair is built to last. It features a 5-wheel plastic coated aluminum base, providing stability and mobility. The pneumatic chair adjust allows for easy raise and lower action, ensuring optimal comfort throughout the day.

When it comes to dimensions, this chair is designed with both style and comfort in mind. With a width of 53 cm (20.87"), depth of 51 cm (20.08"), and height of 80 cm (31.50"), it offers ample space without overwhelming your space. The seat height is 44 cm (17.32") and the seat depth is 41 cm (16.14"), providing a comfortable seating experience for extended periods.

We understand that every space is unique, which is why we offer a range of options to further customize your chair. You can choose between soft or hard-floor caster options, ensuring that your chair glides smoothly across any surface. Additionally, you have the choice between two seat foam densities: medium (1.8 lb/ft3) or high (2.8 lb/ft3), allowing you to select the level of support that suits your preferences. The chair is also available with armless design or 8 position PU armrests, providing additional comfort and versatility.

When it comes to materials, this chair is crafted with the utmost attention to quality. The shell base glider is made from cast aluminum with a modified nylon PA6/PA66 coating, ensuring durability and longevity. The shell thickness is 10 mm, providing a sturdy and reliable structure. The seat is made from HD36 foam, offering a comfortable and supportive seating experience.

Finally, this chair is proudly made in Italy, known for its exceptional craftsmanship and attention to detail. With its timeless design and superior construction, this chair is not only a stylish addition to any space but also a reliable and functional piece of furniture.

Upgrade your office or home with our mid-century inspired office chair and experience the perfect blend of style, comfort, and functionality.

从以上模型输出的信息来看,内容有点多,对于产品营销来说,可能需要内容更简洁一些,更有针对性,那么可以改造一下prompt。

prompt示例如下:

prompt = f"""

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 backticks.

Use at most 50 words.

Technical specifications: ```{fact_sheet_chair}```

"""

response = get_completion(prompt)

print(response)

打印输出结果如下:

Introducing our mid-century inspired office chair, part of a stunning furniture collection. With various color and finish options, choose between plastic or full upholstery in fabric or leather. The chair features a durable aluminum base with 5 wheels and pneumatic height adjustment. Perfect for home or business use. Made in Italy.

仔细看一下上面的内容,发现模型输出的信息对于营销受众(这里指家具零售商)来说有点偏离主题,那么可以再次改造上面的prompt,增加相关的内容来指导模型如何生成更加合适的文本。

prompt示例如下:

prompt = f"""

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 backticks.

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}```

"""

response = get_completion(prompt)

print(response)

打印输出结果如下:

Introducing our mid-century inspired office chair, part of a beautiful furniture collection. With various shell colors and base finishes, it offers versatility for any setting. Choose between plastic or full upholstery in a range of fabric and leather options. The chair features a durable aluminum base with 5-wheel design and pneumatic chair adjustment. Made in Italy.

以上关于产品的文本信息已经比较简洁切题了,但是现在又发现还缺少product ID的信息,所以在prompt中添加相关的提示信息。

prompt示例如下:

prompt = f"""

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 backticks.

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}```

"""

response = get_completion(prompt)

print(response)

      

打印输出结果如下:

Introducing our mid-century inspired office chair, part of a beautiful family of furniture. With various shell colors and base finishes, this chair offers versatility and style. Choose between plastic or full upholstery in a range of fabric and leather options. The chair features a 5-wheel plastic coated aluminum base and a pneumatic chair adjust for easy height adjustment. Available with or without armrests, this chair is suitable for both home and business settings. Made with high-quality materials, including a cast aluminum shell and HD36 foam seat, this chair is built to last. Product ID: SWC-100, SWC-110.

接下来的需求是制作一张维度表格,这就要求模型抽取相关的信息并且放入到一张表格中,此外,在prompt中还提到需要按照HTML的格式输出内容,这样做的目的是方便用户能够以网站网页的方式来进行访问。

prompt示例如下:

prompt = f"""

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 backticks.

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

element.

Technical specifications: ```{fact_sheet_chair}```

"""

response = get_completion(prompt)

print(response)

打印输出结果如下:

 

Product Description

 

    Introducing our latest addition to our mid-century inspired office furniture collection - the SWC Chair. This chair is part of a beautiful family of furniture that includes filing cabinets, desks, bookcases, meeting tables, and more. With its sleek design and customizable options, the SWC Chair is the perfect choice for any home or business setting.

 

 

    The SWC Chair offers several options for customization. You can choose from a variety of shell colors and base finishes to match your existing decor. The chair is available with plastic back and front upholstery or full upholstery in a range of fabric and leather options. The base finish options include stainless steel, matte black, gloss white, or chrome. You can also choose whether to have armrests or not, depending on your preference.

 

 

    The construction of the SWC Chair is top-notch. It features a 5-wheel plastic coated aluminum base, ensuring stability and durability. The chair also has a pneumatic adjuster, allowing for easy raise and lower action. This makes it convenient for users to find their desired seating height.

 

 

    The SWC Chair is not only stylish and functional, but it is also designed with comfort in mind. The seat is made with HD36 foam, providing a comfortable and supportive seating experience. You can also choose between soft or hard-floor caster options, depending on your flooring needs. Additionally, the chair offers two choices of seat foam densities - medium (1.8 lb/ft3) or high (2.8 lb/ft3). This allows you to customize the level of firmness to suit your preferences.

 

 

    The SWC Chair is made with high-quality materials. The shell, base, and glider are constructed with cast aluminum with a modified nylon PA6/PA66 coating. The shell has a thickness of 10 mm, ensuring durability and stability. The chair is proudly made in Italy, known for its craftsmanship and attention to detail.

 

 

    The SWC Chair is a versatile and stylish addition to any office or home. With its customizable options, comfortable seating, and durable construction, it is the perfect choice for those seeking both style and functionality.

 

 

Product Dimensions

 

   

     

     

   

   

     

     

   

   

     

     

   

   

     

     

   

   

     

     

   

   

     

     

   

 

Dimension Measurement (inches)
Width 20.87"
Depth 20.08"
Height 31.50"
Seat Height 17.32"
Seat Depth 16.14"

Product IDs: SWC-100, SWC-110

最后我们来看看按照HTML格式输出内容的网页展示效果:

ChatGPT Prompting开发实战(七)_第1张图片

你可能感兴趣的:(AI,chatgpt,prompt,大模型开发,自然语言处理,人工智能)