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 <div> element.

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

"""

response = get_completion(prompt)

print(response)

打印输出结果如下:

<div>

<h2>Product Description</h2>

<p>

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.

</p>

<p>

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.

</p>

<p>

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.

</p>

<p>

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.

</p>

<p>

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.

</p>

<p>

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.

</p>

<h2>Product Dimensions</h2>

<table>

<tr>

<th>Dimension</th>

<th>Measurement (inches)</th>

</tr>

<tr>

<td>Width</td>

<td>20.87"</td>

</tr>

<tr>

<td>Depth</td>

<td>20.08"</td>

</tr>

<tr>

<td>Height</td>

<td>31.50"</td>

</tr>

<tr>

<td>Seat Height</td>

<td>17.32"</td>

</tr>

<tr>

<td>Seat Depth</td>

<td>16.14"</td>

</tr>

</table>

</div>

Product IDs: SWC-100, SWC-110

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

相关推荐
ZHOU_WUYI3 小时前
3.langchain中的prompt模板 (few shot examples in chat models)
人工智能·langchain·prompt
如若1233 小时前
主要用于图像的颜色提取、替换以及区域修改
人工智能·opencv·计算机视觉
老艾的AI世界4 小时前
AI翻唱神器,一键用你喜欢的歌手翻唱他人的曲目(附下载链接)
人工智能·深度学习·神经网络·机器学习·ai·ai翻唱·ai唱歌·ai歌曲
DK221514 小时前
机器学习系列----关联分析
人工智能·机器学习
Robot2514 小时前
Figure 02迎重大升级!!人形机器人独角兽[Figure AI]商业化加速
人工智能·机器人·微信公众平台
浊酒南街5 小时前
Statsmodels之OLS回归
人工智能·数据挖掘·回归
畅联云平台5 小时前
美畅物联丨智能分析,安全管控:视频汇聚平台助力智慧工地建设
人工智能·物联网
加密新世界5 小时前
优化 Solana 程序
人工智能·算法·计算机视觉
hunteritself5 小时前
ChatGPT高级语音模式正在向Web网页端推出!
人工智能·gpt·chatgpt·openai·语音识别
Che_Che_6 小时前
Cross-Inlining Binary Function Similarity Detection
人工智能·网络安全·gnn·二进制相似度检测