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 生成其推理链
相关推荐
m0_603888711 天前
Mitigating Long-Tail Bias via Prompt-Controlled Diffusion Augmentation
ai·prompt·论文速览
手揽回忆怎么睡2 天前
一套 Prompt 组合
prompt
AI Echoes2 天前
LangChain Runnable组件重试与回退机制降低程序错误率
人工智能·python·langchain·prompt·agent
wasp5202 天前
Banana Slides 深度解析:AI Core 架构设计与 Prompt 工程实践
人工智能·prompt·bash
小明_GLC2 天前
大模型幻觉以及如何设计合适的prompt回答用户问题
人工智能·prompt
彷徨的蜗牛2 天前
用 Claude Code 重新定义编程效率:从 Prompt 工程到完整项目实战
prompt·ai 编程·claude code
石去皿3 天前
Depth Viewer: 16-bit 深度图可视化工具
人工智能·chatgpt·prompt
猫头虎3 天前
2026全网最热Claude Skills工具箱,GitHub上最受欢迎的7大Skills开源AI技能库
langchain·开源·prompt·github·aigc·ai编程·agi
伊甸33 天前
基于LangChain4j从0到1搭建自己的的AI智能体并部署上线-1
java·langchain·prompt
汉克老师3 天前
小学生0基础学大语言模型应用(第 19 课《字符串提示词训练(Prompt Thinking)》)
人工智能·深度学习·机器学习·语言模型·prompt·提示词