扳布的AI摘要
HunYuan-turbos

经验法则和示例

这是OpenAI给出的使用他们家model api时设计prompt的一些建议

1.使用最新型号

为了获得最佳效果,我们通常建议使用最新、功能最强大的模型。较新的模型往往更容易进行提示工程。

注意:提示推理模型和提示 GPT 模型时需要考虑一些差异。更多详情请点击此处

2. 将说明放在提示的开头,并使用 ### 或 “”” 分隔说明和上下文。

效果欠佳❌:

1
2
3
Summarize the text below as a bullet point list of the most important points.

{text input here}

更好✅:

1
2
3
4
5
Summarize the text below as a bullet point list of the most important points.

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

3. 务必具体、详细描述所需的内容、结果、长度、格式、风格等。

请具体说明背景、结果、长度、格式、风格等。

效果欠佳❌:

1
Write a poem about OpenAI. 

更好✅:

1
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. 通过示例阐明所需的输出格式

效果欠佳❌:

1
2
3
Extract the entities mentioned in the text below. Extract the following 4 entity types: company names, people names, specific topics and themes.

Text: {text}

展示并讲解——当模型被展示特定的格式要求时,它们的响应速度会更快。这也使得以编程方式可靠地解析多个输出变得更加容易。

更好✅:

1
2
3
4
5
6
7
8
9
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,两种方法都不奏效,最后进行微调。

✅ zero shot

1
2
3
4
5
Extract keywords from the below text.

Text: {text}

Keywords:

✅ few shot - 请提供几个例子

1
2
3
4
5
6
7
8
9
10
Extract keywords from the corresponding texts below.

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
##
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. 减少“空泛”和不精确的描述

效果欠佳❌:

1
The description for this product should be fairly short, a few sentences only, and not too much more.

更好✅:

1
Use a 3 to 5 sentence paragraph to describe this product.

7. 不要只说不要做什么,还要说应该做什么

效果欠佳❌:

1
2
3
4
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:

更好✅:

1
2
3
4
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. 代码生成专用——使用“引导词”来引导模型朝着特定模式发展

效果欠佳❌:

1
2
3
# Write a simple python function that
# 1. Ask me for a number in mile
# 2. It converts miles to kilometers

在下面的代码示例中,添加“ import ”语句会提示模型应该开始用Python编写代码。(类似地,“SELECT”语句则提示应该开始编写SQL语句。)

更好✅:

1
2
3
4
5
# Write a simple python function that
# 1. Ask me for a number in mile
# 2. It converts miles to kilometers

import

9. 使用“生成任何内容”功能

开发者可以使用“生成任何内容”功能来描述任务或预期的自然语言输出,并收到定制的提示。

了解更多关于“生成任何内容”功能的信息。

参数

通常情况下,我们发现**model** 和是改变模型输出最常用的参数。 **temperature**

  1. **model**性能更高的型号通常价格更贵,延迟也可能更高
  2. **temperature**-该指标衡量模型输出不太可能出现的词元的频率。数值越高temperature,输出结果越随机(通常也越有创意)。然而,这与“真实性”并不相同。对于大多数事实性应用场景,例如数据提取和真实问答,该temperature值为 0 时效果最佳。
  3. **max_completion_tokens**最大长度) - 不控制输出的长度,而是对词元生成的硬性限制。理想情况下,您不会经常达到此限制,因为您的模型会在认为完成或遇到您定义的停止序列时停止。
  4. **stop**(停止序列) - 一组字符(标记),当生成这些字符时,将导致文本生成停止。