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 生成其推理链
相关推荐
Swizard1 天前
逐行解剖:扒开 Lovable Agent 源码,看顶级 AI 是如何“思考”与“动刀”的
ai·prompt
杜子不疼.3 天前
大模型应用开发实战:从 Prompt 工程到企业级落地全流程
prompt
觅特科技-互站3 天前
告别手动微调Prompt:DevOps用陌讯Skills重构AI运维工作流
运维·prompt·线性回归·kmeans·devops
小马_xiaoen3 天前
AI Prompt 工程完全指南:从入门到精通的提示词设计艺术
人工智能·prompt
Swizard4 天前
还在无脑堆砌提示词?三分钟看懂 Vercel v0 价值千万的 System Prompt 底层逻辑
ai·prompt
Loo国昌4 天前
【AI应用开发实战】Guardrail风险控制中间件:Agent系统的安全防线
人工智能·python·安全·自然语言处理·中间件·prompt
啦啦啦_99994 天前
SpringAI Alibaba(SAA) 之 Prompt
prompt
AC赳赳老秦4 天前
DeepSeek助力云原生AI降本:容器化部署资源优化与算力利用率提升技巧
网络·python·django·prompt·tornado·ai-native·deepseek
Loo国昌4 天前
【AI应用开发实战】09_Prompt工程与模板管理:构建可演进的LLM交互层
大数据·人工智能·后端·python·自然语言处理·prompt
minhuan5 天前
大模型应用:遗传算法 (GA)+大模型:自动化进化最优Prompt与模型参数.95
prompt·大模型应用·遗传算法 ga·prompt自动调优