当前位置: 首页 > article >正文

openAI官方prompt技巧(一)

1. 使用最新的模型

2. 将指令放在提示词的开头,并使用 ### 或 """ 来分隔指令和上下文,例如

错误示范❌
将下面的文本总结为一个要点列表,列出最重要的内容。
Summarize the text below as a bullet point list of the most important points.

{text input here}

正确示范✔
Summarize the text below as a bullet point list of the most important points.

Text: """
{text input here}
"""

3. 明确说明上下文、结果、长度、格式、风格等

错误示范❌
Write a poem about OpenAI. 

正确示范✔
写一首简短的鼓舞人心的诗,主题是 OpenAI 最近推出的 DALL-E 产品(DALL-E 是一个文本转图像的机器学习模型),以 {著名诗人} 的风格进行创作。
Write a short inspiring poem about OpenAI, focusing on the recent DALL-E product launch (DALL-E is a text to image ML model) in the style of a {famous poet}

4. 通过示例明确说明所需的输出格式

错误示范❌
提取下面文本中提到的实体。提取以下四种实体类型:公司名称、人物名称、特定话题和主题。
Extract the entities mentioned in the text below. Extract the following 4 entity types: company names, people names, specific topics and themes.

Text: {text}

正确示范✔
提取下面文本中提到的重要实体。首先提取所有公司名称,然后提取所有人物名称,再提取符合内容的特定话题,最后提取一般性的主题。

所需格式:
公司名称:<以逗号分隔的公司名称列表>
人物名称:-||-
特定话题:-||-
一般主题:-||-

文本:{text}
Extract the important entities mentioned in the text below. First extract all company names, then extract all people names, then extract specific topics which fit the content and finally extract general overarching themes

Desired format:
Company names: <comma_separated_list_of_company_names>
People names: -||-
Specific topics: -||-
General themes: -||-

Text: {text}

5. 先尝试零样本(Zero-shot),然后尝试少样本(Few-shot),如果都不起作用,再进行微调(Fine-tune)

Zero-shot
Extract keywords from the below text.

Text: {text}

Keywords:

Few-shot
从以下对应的文本中提取关键词。
Extract keywords from the corresponding texts below.


文本 1: Stripe 提供 API,Web 开发人员可以使用这些 API 将支付处理集成到其网站和移动应用程序中。
关键词 1: Stripe、支付处理、API、Web 开发人员、网站、移动应用程序
Text 1: Stripe provides APIs that web developers can use to integrate payment processing into their websites and mobile applications.
Keywords 1: Stripe, payment processing, APIs, web developers, websites, mobile applications
##

文本 2: OpenAI 训练了最前沿的语言模型,这些模型非常擅长理解和生成文本。我们的 API 提供了对这些模型的访问,并可用于几乎所有涉及语言处理的任务。
关键词 2: OpenAI、语言模型、文本处理、API
Text 2: OpenAI has trained cutting-edge language models that are very good at understanding and generating text. Our API provides access to these models and can be used to solve virtually any task that involves processing language.
Keywords 2: OpenAI, language models, text processing, API.
##
Text 3: {text}
Keywords 3:

6. 减少“华而不实”和不精确的描述

错误示范❌
此产品的描述应尽量简短,仅需几句话,不宜过多。
The description for this product should be fairly short, a few sentences only, and not too much more.

正确示范✔
使用一个包含 3 到 5 句话的段落来描述此产品。
Use a 3 to 5 sentence paragraph to describe this product.

7. 直接说明该做什么,而不是不该做什么

错误示范❌
以下是代理(Agent)与客户(Customer)之间的对话。不要询问用户名或密码。不要重复内容。

客户: 我无法登录我的账户。
代理:
The following is a conversation between an Agent and a Customer. DO NOT ASK USERNAME OR PASSWORD. DO NOT REPEAT.

Customer: I can’t log in to my account.
Agent:

正确示范✔
以下是代理(Agent)与客户(Customer)之间的对话。代理应尝试诊断问题并提供解决方案,同时避免询问任何与个人身份信息(PII)相关的问题。
不要询问 PII(如用户名或密码),而应引导用户访问帮助文章:www.samplewebsite.com/help/faq

客户: 我无法登录我的账户。
代理:
The following is a conversation between an Agent and a Customer. The agent will attempt to diagnose the problem and suggest a solution, whilst refraining from asking any questions related to PII. Instead of asking for PII, such as username or password, refer the user to the help article www.samplewebsite.com/help/faq

Customer: I can’t log in to my account.
Agent:

8. 代码生成相关 - 使用“引导词”引导模型遵循特定模式

错误示范❌
编写一个简单的 Python 函数
1. 询问用户输入一个英里数
2. 将英里转换为公里
Write a simple python function that
1. Ask me for a number in mile
2. It converts miles to kilometers

在下面的代码示例中,添加 “import” 可以提示模型应以 Python 代码开始编写。(类似地,在 SQL 语句开头使用 “SELECT” 是一个很好的引导。)

正确示范✔
Write a simple python function that
1. Ask me for a number in mile
2. It converts miles to kilometers
 
import

9. 使用 Generate Anything


http://www.kler.cn/a/539654.html

相关文章:

  • 继承(python)
  • http常用状态码
  • c++ haru生成pdf输出饼图
  • <论文>DeepSeek-R1:通过强化学习激励大语言模型的推理能力(深度思考)
  • C++ 继承(1)
  • java基础语法中阶
  • 【Java基础-44.2】Java中的LinkedList:特征与方法详解
  • 单例模式几种实现
  • 【漫话机器学习系列】082.岭回归(或脊回归)中的α值(alpha in ridge regression)
  • Linux 安装 Ollama
  • ASP.NET Core WebSocket、SignalR
  • 从零开始掌握Python人工智能:实战案例、学习路径与职业建议
  • MOSSE目标跟踪算法详解
  • 深度学习-可调整嵌入维度、隐藏层维度和训练轮数
  • Chrome 浏览器 支持多账号登录和管理的浏览器容器解决方案
  • 二级C语言题解:迭代求根、字符串加法、字符串拆分
  • ARM Cortex-M3/M4 权威指南 笔记【一】架构
  • PHP 完整表单实例
  • 嵌入式硬件篇---OpenMV串口流和缓冲区
  • 用AI写游戏3——模拟发牌
  • Golang中 var make new
  • vue表格拖拽,可以多个单元格拖拽
  • html 列动态布局
  • 2025年2月份的一次前端面试题记录....
  • 使用Redis解决使用Session登录带来的共享问题
  • 深度学习-利用Tacotron 2 和 WaveGlow 模型 进行语音合成