提示工程技术简介与常见提示用法(一)

What is Prompt engineering?

Prompt engineering is the process of creating prompts or asking or instructions that guide the output of a language model like ChatGPT. It allows users to control the output of the model and generate text that is tailored to their specific needs.

好的提示词需要具有的三个因素

任务:简介明了的陈述
指令:模型为了完成任务所执行的指令
角色:应该扮演什么样的角色来生成文本

1. 指令提示技术

Examples:
客服服务响应
Prompt formula:“Generate [task] following these instructions:[instructions]”
Task:对于客户诉求生成回答
Instructions:回答应专业并提供准确的信息
Prompt formula:
“Generate professional and accurate
responses to customer inquiries following these instructions:
The responses should be professional and provide accurate
information.”

2. 角色提示

Prompt formula: “Generate [task] as a [role]”
Example:
Generating customer service responses:
Task: Generate responses to customer inquiries
Role: Customer service representative
Prompt formula: “Generate responses to customer inquiries
as a customer service representative.”

Using the role prompting technique with instruction prompting and seed-word prompting will enhance the output of ChatGPT.
Example:
Task: Generate a product description for a new smartphone
Instructions: The description should be informative, persuasive and highlight the unique features of the smartphone
Role: Marketing representative
Seed-word: "innovative"Prompt formula: "As a marketing representative, generate an informative, persuasive product description that highlights the innovative features of the new smartphone. The smartphone has the following features [insert your features]”

3. Standard Prompts (标准化)

Task: Generate a product review for a new laptop
Instructions: The review should be objective, informative and highlight the unique features of the laptop
Role: Tech expert
Seed-word: “powerful”
Prompt formula: “As a tech expert, generate an objective and informative product review that highlights the powerful features of the new laptop.”

4. Zero, One and Few Shot Prompting (零、一和少样本提示)

The zero-shot prompting technique is used when there are no examples available for the task. The model is provided with a general task and it generates text based on its understanding of the task.

The one-shot prompting technique is used when there is only one example available for the task. The model is provided with the example and generates text based on its understanding of the example.

The few-shot prompting technique is used when there are a limited number of examples available for the task. The model is provided with the examples and generates text based on its understanding of the examples.

Prompt formula: “Generate text based on [number] examples”
Example:
zero-shot
Generating a product description for a new product with no examples available:
Task: Write a product description for a new smartwatch
Prompt formula: “Generate a product description for this new smartwatch with zero examples”
one-shot
Generating a product comparison with one example available:
Task: Compare a new smartphone to the latest iPhone
Prompt formula: “Generate a product comparison of this new smartphone with one example (latest iPhone)”
few-shot
Generating a product review with few examples available:Task: Write a review of a new e-reader
Prompt formula: “Generate a review of this new e-reader with few examples (3 other e-readers)”

这个技术使得生成的文本是基于对所提供的任务或者例子的理解

5. “Let’s think about this” prompt(引导思考)

让GPT生成深思熟虑的回答,
常用于写散文、诗歌、创造性写作
Example:

  • Generating a reflective essay:
    Task:Write a reflective essay on the topic of personal growth
    Prompt formula:“Let’s think about this: personal growth”
  • Generating a poem:
    Task: Write a poem about the changing seasons
    Prompt formula:“Let’s think about this: the changing seasons”
    This prompt is asking for a conversation or discussion about a specific topic or idea. The speaker is inviting ChatGPT to engage in a dialogue about the subject at hand.
    以提示词作为对话或者文本生成的开始

使用该提示词技术需要注意以下步骤

  1. Identify the topic or idea you want to discuss
  2. Formulate a prompt that clearly states the topic or idea, and starts the conversation or text generation.
  3. Preface the prompt with “Let’s think about” or “Let’s discuss” to indicate that you’re initiating a conversation or discussion.
    Here are a few examples of prompts using this technique:
  • Prompt: “Let’s think about the impact of climate change on agriculture”
  • Prompt: “Let’s discuss the current state of artificial intelligence”
  • Prompt: “Let’s talk about the benefits and drawbacks of remote work”

Give it a try and see for yourself

6. Self-Consistency Prompt(自洽提示)

This technique is useful for tasks such as fact-checking, data validation, or consistency checking in text generation.
Example 1: Text Generation

  • Task: Generate a product review
  • Instructions: The review should be consistent with the product information provided in the input
  • Prompt formula:"Generate a product review that is consistent with the following product information [insert product information] "

Example 2: Text Summarization

  • Task: Summarize a news article
  • Instructions: The summary should be consistent with the information provided in the article
  • Prompt formula: “Summarize the following news article in a way that is consistent with the information provided [insert news article]”

Example 3: Text Completion

  • Task: Complete a sentence
  • Instructions: The completion should be consistent with the context provided in the input
  • Prompt formula: “Complete the following sentence in a way that is consistent with the context provided [insert sentence]”

Example 4:

  1. Fact-checking:
  • Task: Check for consistency in a given news article
  • Input text: “The article states that the population of the city is 5 million, but later on, it says that the population is 7 million.”
  • Prompt formula: “Please ensure the following text is self consistent: The article states that the population of the city is 5 million, but later on, it says that the population is 7 million.”
  1. Data validation:
  • Task: Check for consistency in a given data set
  • Input text: “The data shows that the average temperature in July is 30 degrees, but the minimum temperature is recorded as 20 degrees.”
  • Prompt formula: “Please ensure the following text is self consistent: The data shows that the average temperature in July is 30 degrees, but the minimum temperature is recorded as 20 degrees.”
7. Seed-word Prompt (关键词)

Examples:

  • Text generation:
    Task: Generate a story about a dragon
    Seed-word:“Dragon”
    Prompt formula:“Please generate text based on the following seed-word:Dragon”
  • Language Translation:
    Task:Translate a sentence from English to Spanish
    Seed-word: “Hello”
    Prompt formula: "Please generate text based on the following seed-word: Hello "

该技术可以与role prompting 和 instruction prompting 相结合生成更具体和目标更强的文本
Example 1: Text Generation
Task: Generate a poem
Instructions: The poem should be related to the seed word “love” and should be written in the style of a sonnet.
Role: Poet
Prompt formula: “Generate a sonnet related to the seed word ‘love’ as a poet”

Example 2: Text Completion
Task: Complete a sentence
Instructions: The completion should be related to the seed word “science” and should be written in the style of a research paper
Role: Researcher
Prompt formula: “Complete the following sentence in a way that is related to the seed word ‘science’ and in the style of a research paper as a researcher: [insert sentence]”

Example 3: Text Summarization
Task: Summarize a news article
Instructions: The summary should be related to the seed word “politics” and should be written in a neutral and unbiased tone
Role: Journalist
Prompt formula: “Summarize the following news article in a way that is related to the seed word ‘politics’ in a neutral and unbiased tone as a journalist: [insert news article]”

8. Knowledge Generation prompt(知识生成)

一种从ChatGPT生成新的和原始信息的技术
The prompt formula for the Knowledge Generation prompt is “Please generate new and original information about X”, where X is the topic of interest.

Example 1: Knowledge Generation
Task: Generate new information about a specific topic
Instructions: The generated information should be accurate and relevant to the topic
Prompt formula: “Generate new and accurate information about[specific topic]”

Example 2: Question Answering
Task: Answer a question
Instructions: The answer should be accurate and relevant to the question
Prompt formula: “Answer the following question:[insert question]”

Example 3: Knowledge Integration
Task: Integrate new information with the existing knowledgeInstructions: The integration should be accurate and relevant to the topic
Prompt formula: “Integrate the following information with the existing knowledge about [specific topic]: [insert new information]”

Example 4: Data Analysis:
Task: Generate insights about customer behavior from a given dataset
Prompt formula: “Please generate new and original information about customer behavior from this dataset”

9. Knowledge Integration prompts(知识整合提示)

The model should be provided with a new information and the existing knowledge as input, along with a prompt that specifies the task or goal for the generated text. The prompt should include information about the desired output, such as the type of text to be generated and any specific requirements or constraints.

Example 1: Knowledge Integration
Task: Integrate new information with the existing knowledge
Instructions: The integration should be accurate and relevant to the topic
Prompt formula: “Integrate the following information with the existing knowledge about [specific topic]: [insert new information]”

Example 2: Connecting pieces of information
Task: Connect different pieces of information
Instructions: The connections should be relevant and logical
Prompt formula: “Connect the following pieces of information in a way that is relevant and logical: [insert information 1] [insert information 2]”

Example 3: Updating existing knowledge
Task: Update existing knowledge with new information
Instructions: The updated information should be accurate and relevant
Prompt formula: “Update the existing knowledge about [specific topic] with the following information: [insert new information]”

10. Multiple Choice prompts(多选提示)

有预设选项
This technique presents a model with a question or task and a set of predefined options as potential answers.
Example 1: Question Answering
Task: Answer a multiple-choice question
Instructions: The answer should be one of the predefined options
Prompt formula: “Answer the following question by selecting one of the following options: [insert question] [insert option 1] [insert option 2] [insert option 3]”

Example 2: Text completion
Task: Complete a sentence with one of the predefined options
Instructions: The completion should be one of the predefined options
Prompt formula: “Complete the following sentence by selecting one of the following options: [insert sentence] [insert option 1] [insert option 2] [insert option 3]”

Example 3: Sentiment analysis
Task: Classify a text as positive, neutral or negative
Instructions: The classification should be one of the predefined options
Prompt formula: "Classify the following text as positive, neutral or negative by selecting one of the following options: [insert text] [positive] [neutral] [negative]

11. Interpretable Soft Prompts (可解释的软提示)

That allows to control the model’s generated text while providing some flexibility to the model.

Example 1: Text generation
Task: Generate a story
Instructions: The story should be based on a given set of characters and a specific theme
Prompt formula: “Generate a story based on the following characters: [insert characters] and the theme: [insert theme]”

Example 2: Text completion
Task: Complete a sentence
Instructions: The completion should be in the style of a specific author
Prompt formula: “Complete the following sentence in the style of [specific author]: [insert sentence]”

Example 3: Language modeling
Task: Generate text in a specific style
Instructions: The text should be in the style of a specific period
Prompt formula: “Generate text in the style of [specific period]: [insert context]”

  • 9
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值