在个中,她分享了一个可以方便用于设计 prompt 构造的模板——CO-STAR 框架,这是新加坡政府科技局的数据科学与 AI 团队的创意成果。
其事情办法为:
(C) 高下文(Context):供应与任务有关的背景信息。这有助于 LLM 理解正在谈论的详细场景,从而确保其相应是干系的。(O) 目标(Objective):定义你希望 LLM 实行的任务。明晰目标有助于 LLM 将自己相应重点放在完成详细任务上。(S) 风格(Style):指定你希望 LLM 利用的写作风格。这可能是一位详细名人的写作风格,也可以是某种职业专家(比如商业剖析师或 CEO)的风格。这能勾引 LLM 利用符合你需求的办法和词语给出相应。(T) 语气(Tone):设定相应的态度。这能确保 LLM 的相应符合所需的情绪或感情高下文,比如正式、诙谐、善解人意等。(A) 受众(Audience):确定相应的目标受众。针对详细受众(比如领域专家、初学者、孩童)定制 LLM 的相应,确保其在你所需的高下文中是适当的和可被理解的。(R) 相应(Response):供应相应的格式。这能确保 LLM 输出你的下贱任务所需的格式,比如列表、JSON、专业报告等。对付大多数通过程序化方法将 LLM 响运用于下贱任务的 LLM 运用而言,空想的输出格式是 JSON。CO-STAR 的一个实际运用
这里通过一个实际案例解释 CO-STAR 为什么有用。假设你是一位社交媒体管理者,你须要帮助草拟一篇 Facebook 帖文,其內容是宣扬你公司的新产品。
如果不该用 CO-STAR,那么你可能会利用这样的 prompt:
Write a facebook post to advertise my company’s new product. My company’s name is Alpha and the product is called Beta, a new ultra-fast hairdryer.
GPT-4 的输出如下:
Introducing the Revolutionary Beta Hairdryer by Alpha!- Say goodbye to long, tedious hair drying sessions! Alpha is proud to unveil the Beta, our latest innovation in haircare technology. - Ultra-Fast Drying: The Beta is designed to cut your drying time in half, thanks to its advanced, powerful motor. Get ready faster and enjoy more time doing what you love!Shop Now: [Link to product page]
这个结果大概够用了,但却只是泛泛而谈,缺少详细的细节和有针对性的吸引力,而这些是吸引目标受众所必需的。
那如果利用 CO-STAR 模板呢?CO-STAR 会提醒你将任务涉及的其它方面也整合进 prompt 之中,详细来说便是上面的大略 prompt 中缺失落的 STYLE、TONE、AUDIENCE 方面:
# CONTEXT #I want to advertise my company’s new product. My company’s name is Alpha and the product is called Beta, which is a new ultra-fast hairdryer.# OBJECTIVE #Create a Facebook post for me, which aims to get people to click on the product link to purchase it. # STYLE #Follow the writing style of successful companies that advertise similar products, such as Dyson.# TONE #Persuasive # AUDIENCE #My company’s audience profile on Facebook is typically the older generation. Tailor your post to target what this audience typically looks out for in hair products.# RESPONSE #The Facebook post, kept concise yet impactful.
通过利用 CO-STAR,GPT-4 的相应会变得明显更有针对性、效果更好:
Embrace Effortless Elegance with Alpha Beta — The Ultra-Fast Hairdryer for the Wise Generation. Rediscover the joy of simple, effective hair care with Alpha Beta. Our latest innovation is more than just a hairdryer; it’s a promise of swift, gentle, and reliable hair styling for those who appreciate the finer things in life. - Easy and Intuitive Use: Say goodbye to complicated gadgets. Alpha Beta iscrafted for comfort and simplicity, perfect for those who value straightforward,hassle-free technology. - Time-Saving Technology: We understand your time is precious. That’s why Alpha Beta cuts down drying time significantly, giving you more moments to enjoy life’s pleasures. Make every day a good hair day with Alpha Beta. Experience the blend of sophistication and simplicity today.[Your Product Link Here]
CO-STAR 框架能勾引用户以一种构造化的办法向 LLM 供应有关你的任务所有关键信息,从而确保得到完备符合你的需求的定制化的更优的相应。
现在有没有觉得到AI提示词也不是想象中的那么难写呢?
原文链接:https://towardsdatascience.com/how-i-won-singapores-gpt-4-prompt-engineering-competition-34c195a93d41