ChatGPT提示词工程(二):Iterative迭代

本文是吴恩达《ChatGPTPromptEngineeringforDevelopers》课程的笔记,展示了如何通过迭代改进Prompt以根据产品技术规格生成适合家具零售商的营销文案。从初步描述到添加字数限制、关注目标受众、包含产品ID到最后形成包含材料数据的HTML表格,逐步细化和完善Prompt的过程被详细记录下来。
摘要由CSDN通过智能技术生成

一、说明

这是吴恩达 《ChatGPT Prompt Engineering for Developers》 的课程笔记系列。
本文是第三讲的内容:Iterative
课程主讲:Andrew Ng,Isa Fulford
Isa Fulford也是《OpenAI Cookbook》的主要贡献者之一

二、安装环境

参考: ChatGPT提示词工程(一):Guidelines准则 的第二节

三、Iterative

在本课中,您将反复分析和提炼您的提示,以根据产品情况说明书生成营销文案

第一次写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 = 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)

代码中,提供了一断椅子的描述文字,要求写一个文案,放到网站上去,通过简单的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)

添加了最多50个单次的条件,运行结果:
在这里插入图片描述

第三次写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)

运行结果:
在这里插入图片描述

第四次写Prompt

添加一些ID的说明,再次改写:

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)

在这里插入图片描述

第五次写Prompt

要求以表格的形式展示一些材料等数据,并且输出为html格式:

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)

在这里插入图片描述
在这里插入图片描述

将输出的html渲染出来的效果:

from IPython.display import display, HTML
display(HTML(response))

在这里插入图片描述
https://blog.csdn.net/Jay_Xio/article/details/130452393



四、总结

在这里插入图片描述

在这里插入图片描述

编写Prompt时,您对要做什么、要完成的任务有一个想法,然后您可以第一次尝试编写一个Prompt,希望它是明确和具体的,如果合适的话,可能会给系统时间思考,然后您可以运行它,看看您会得到什么结果。
如果它第一次不能很好地工作,那么迭代过程就是找出为什么指令不够清楚,或者为什么它没有给算法足够的时间来思考,允许您完善想法,完善提示,等等。
并多次循环这个循环,直到得到一个适用于您的应用程序的Prompt

https://blog.csdn.net/Jay_Xio/article/details/130452393



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值