Prompt Engineering

详解LLM中各个参数的意义

https://qianfan.cloud.baidu.com/qianfandev/topic/268819

https://www.promptingguide.ai/zh

从简单开始

指令

指令:"写入"、"分类"、"总结"、"翻译"、"排序"

以不同的关键词(keywords),上下文(contexts)和数据(data)试验不同的指令(instruction)

有些人建议将指令放在提示的开头。另有人则建议是使用像"###"这样的清晰分隔符来分隔指令和上下文。

指令 ###将以下文本翻译成西班牙语:文本:"hello!"

具体性

避免不明确

解释提示工程的概念。保持解释简短,只有几句话,不要过于描述。

具体、简洁并且切中要点的:使用 2-3 句话向高中学生解释提示工程的概念。

做什么还是不做什么?

避免说不要做什么,而应该说要做什么

不要改为应该避免

提示词示例

文本概括

Explain antibiotics

A:

"A:" 是一种在问答中使用的显式提示格式,你在这里使用它是为了告诉模型接下来你期望有一个答案。

Explain the above in one sentence:

用一句话解释上面的信息:

信息提取

Mention the large language model based product mentioned in the paragraph above:

问答

一个提示可以结合指令、上下文、输入和输出指示(output indicators)来获得更好的结果。

指令:Answer the question based on the context below. Keep the answer short and concise.

输出指示:Respond "Unsure about answer" if not sure about the answer.

上下文:Context: Teplizumab traces its roots to a New Jersey drug company called Ortho Pharmaceutical. There, scientists generated an early version of the antibody, dubbed OKT3. Originally sourced from mice, the molecule was able to bind to the surface of T cells and limit their cell-killing potential. In 1986, it was approved to help prevent organ rejection after kidney transplants, making it the first therapeutic antibody allowed for human use.

输入指示:Question: What was OKT3 originally sourced from?

Answer:

文本分类

提供的其他元素包括输入数据示例

Classify the text into neutral, negative or positive.

Text: I think the vacation is okay.

Sentiment: neutral

Text: I think the food was okay.

Sentiment:

对话

角色提示(Role Prompting)

The following is a conversation with an AI research assistant. The assistant tone is technical and scientific.

Human: Hello, who are you?

AI: Greeting! I am an AI research assistant. How can I help you today?

Human: Can you tell me about the creation of blackholes?

AI:

给出更易于理解的回答。

The following is a conversation with an AI research assistant. The assistant answers should be easy to understand even by primary school students.

Human: Hello, who are you?

AI: Greeting! I am an AI research assistant. How can I help you today?

Human: Can you tell me about the creation of black holes?

AI:

代码生成

推理

提示技术

少样本提示

"whatpu"是坦桑尼亚的一种小型毛茸茸的动物。一个使用whatpu这个词的句子的例子是:我们在非洲旅行时看到了这些非常可爱的whatpus。

"farduddle"是指快速跳上跳下。一个使用farduddle这个词的句子的例子是:

这太棒了!// Negative

这太糟糕了!// Positive

哇,那部电影太棒了!// Positive

多么可怕的节目!//

链式思考(CoT)提示

少样本提示

这组数中的奇数加起来是偶数:4、8、9、15、12、2、1。

A:将所有奇数相加(9、15、1)得到25。答案为False。

这组数中的奇数加起来是偶数:17、10、19、4、8、12、24。

A:将所有奇数相加(17、19)得到36。答案为True。

这组数中的奇数加起来是偶数:16、11、14、4、8、13、24。

A:将所有奇数相加(11、13)得到24。答案为True。

这组数中的奇数加起来是偶数:17、9、10、12、13、4、2。

A:将所有奇数相加(17、9、13)得到39。答案为False。

这组数中的奇数加起来是偶数:15、32、5、13、82、7、1。

A:

请记住,作者声称这是足够大的语言模型才会出现的新兴能力。

零样本 COT 提示

我去市场买了10个苹果。我给了邻居2个苹果和修理工2个苹果。然后我去买了5个苹果并吃了1个。我还剩下多少苹果?

让我们逐步思考。

自动思维链(Auto-CoT)

当使用思维链提示时,这个过程需要手工制作有效且多样化的例子。这种手动工作可能会导致次优解决方案。Zhang et al. (2022)(opens in a new tab) 提出了一种消除人工的方法,即利用 LLMs "让我们一步一步地思考" 提示来生成一个接一个的推理链。这种自动过程仍然可能在生成的链中出现错误。为了减轻错误的影响,演示的多样性很重要。

Auto-CoT 主要由两个阶段组成:

  • 阶段1:问题聚类:将给定问题划分为几个聚类
  • 阶段2:演示抽样:从每组数组中选择一个具有代表性的问题,并使用带有简单启发式的 Zero-Shot-CoT 生成其推理链
相关推荐
阿杰学AI2 小时前
AI核心知识54——大语言模型之Structured CoT(简洁且通俗易懂版)
人工智能·ai·语言模型·prompt·pe·结构化提示词·structured cot
AI Echoes13 小时前
构建一个LangChain RAG应用
数据库·python·langchain·prompt·agent
semantist@语校1 天前
第五十四篇|从事实字段到推理边界:名古屋国际外语学院Prompt生成中的过度推断防御设计
大数据·linux·服务器·人工智能·百度·语言模型·prompt
小小工匠1 天前
LLM - 从 Prompt 到上下文工程:面向 Java 的生产级 AI Agent 设计范式
人工智能·prompt·agent·上下文工程
sztomarch1 天前
Windows-Commands-prompt
windows·prompt
yy我不解释1 天前
关于comfyui的comfyui-prompt-reader-node节点(import failed)和图片信息问题(metadata)
python·ai作画·prompt
inmK11 天前
提示词质量差?Windows Prompt Optimizer一键优化,生成效率提升60%
prompt·提示词优化·ai提示工程·多模型兼容·图像生成提示优化·大模型输出稳定性·windows绿色软件
liliangcsdn1 天前
如何用DSPy优化RAG prompt示例
prompt
liliangcsdn2 天前
prompt自主生成框架 - DSPy
prompt