5个AI工程师不可不会的提示工程技巧

在人工智能领域,大型语言模型(LLMs)能通过微调或提示完成多种任务。而提示工程,就是让这些模型发挥最大效能的关键技能。本文介绍五种提示技巧,让AI工程师能更精准地引导LLMs,释放它们的全部潜力。

1 少样本提示

在人工智能的舞台上,大型语言模型(LLMs)面对零样本任务时,往往显得力不从心——缺少了正确输出的示范,便难以展现真正的实力。这时,少样本提示技术便登场了。

少样本提示的核心,就是在提示中给出正确输出的范例。通过这种方式,LLMs能够在上下文中学习,模仿这些范例,从而提升自身的性能。简而言之,这是一种通过示例引导模型学习的方法,让LLMs在复杂任务面前也能游刃有余。

少样本提示技巧

在运用少样本提示技巧时,选择合适的例子可以事半功倍。LLMs会严格按照所提供的例子来执行任务,因此,例子的类型和格式直接影响模型的输出质量。

为了让LLMs更好地理解和学习,应尽量使用真实世界的数据来构建例子。这样能够让模型更贴近实际应用场景,还能提高其输出的准确性和可靠性。简而言之,真实性是构建有效示例的黄金法则。

2 思维链提示

思维链提示技术,帮助LLM处理那些需要逐步推理的任务。通过逐一展示解决问题的逻辑链条,引导LLMs逐层深入,直至得出正确答案。

这就像是为模型提供了一份清晰的思考地图,使其能够条理清晰地应对复杂问题。

3 自我一致性

自我一致性技术要求我们向大型语言模型(LLM)提供一系列推理示例,目的是在众多生成的响应中筛选出最佳答案。这种方法有效减少了模型回答中的偏见,并促使模型在给出最终答案前,全面考虑不同角度的观点。

具体实施自我一致性包括以下几个步骤:

  • 明确问题:首先,清晰具体地描述您希望LLM解答的问题。
  • 设计多个提示:接着,围绕这个问题,从不同角度编写多个提示。
  • 收集响应:将这些提示提交给LLM,收集其给出的响应。
  • 评估一致性:然后,对比这些响应,检查它们是否逻辑连贯、主题一致。
  • 确定最佳答案:最后,从这些响应中挑选出最为一致和准确的答案,作为最终的输出。

示例

When I was 6 my sister was half my age. Now I’m 70 how old is my sister?
**Output:** 73

这个答案不正确。

现在用自我一致性来解决这个问题。

在下面的提示中,我们提供了多个类似问题的例子,还描述了如何通过这个问题得出正确的答案,以向 LLM 展示如何做到这一点。

**Q:** There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done,there will be 21 trees. How many trees did the grove workers plant today?
**A:** We start with 15 trees. Later we have 21 trees. The difference must be the number of trees they planted.So, they must have planted 21 - 15 = 6 trees. The answer is 6.

**Q:** If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot?
**A:** There are 3 cars in the parking lot already. 2 more arrive. Now there are 3 + 2 = 5 cars. The answer is 5.

**Q:** Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?
**A:** Leah had 32 chocolates and Leah's sister had 42. That means there were originally 32 + 42 = 74chocolates. 35 have been eaten. So in total they still have 74 - 35 = 39 chocolates. The answer is 39.

**Q:** Jason had 20 lollipops. He gave Denny some lollipops. Now Jason has 12 lollipops. How many lollipopsdid Jason give to Denny?
**A:** Jason had 20 lollipops. Since he only has 12 now, he must have given the rest to Denny. The number oflollipops he has given to Denny must have been 20 - 12 = 8 lollipops. The answer is 8.

**Q:** Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys doeshe have now?
**A:** He has 5 toys. He got 2 from mom, so after that he has 5 + 2 = 7 toys. Then he got 2 more from dad, soin total he has 7 + 2 = 9 toys. The answer is 9.

**Q:** There were nine computers in the server room. Five more computers were installed each day, frommonday to thursday. How many computers are now in the server room?
**A:** There are 4 days from monday to thursday. 5 computers were added each day. That means in total 4 * 5 =20 computers were added. There were 9 computers in the beginning, so now there are 9 + 20 = 29 computers.The answer is 29.

**Q:** Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How manygolf balls did he have at the end of wednesday?
**A:** Michael initially had 58 balls. He lost 23 on Tuesday, so after that he has 58 - 23 = 35 balls. OnWednesday he lost 2 more so now he has 35 - 2 = 33 balls. The answer is 33.

**Q:** Olivia has $23. She bought five bagels for $3 each. How much money does she have left?
**A:** She bought 5 bagels for $3 each. This means she spent 5

**Q:** When I was 6 my sister was half my age. Now I'm 70 how old is my sister?
**A:** 

Output 1:

When I was 6 my sister was half my age. Now I’m 70 how old is my sister?
**Output:** 73

Output 2:

When the narrator was 6, his sister was half his age, which is 3. Now that the narrator is 70, his sister would be 70 - 3 = 67 years old. The answer is 67.

Output 3:

When I was 6 my sister was half my age, so she was 3. Now I am 70, so she is 70/2 = 35. The answer is 35.

4 提示链

提示链是一种应对复杂查询的高级策略。当单一的提示不足以解决问题时,就需要采用提示链技术,它通过将复杂任务拆解成一系列子任务来逐步推进。

首先,发出一个初始提示,这个提示只解决整个问题的一部分。然后,将这个提示的输出结果作为下一个子提示的输入,继续处理问题的下一部分。这个过程像链条一样一环扣一环,直到最终得到我们想要的答案。

简单来说,提示链就是将难题分解,逐一击破,最终汇聚成完整的解决方案。这种方法不仅提高了处理问题的效率,也使得每一步的逻辑更加清晰,确保了最终结果的准确性。

5 生成知识提示

生成知识提示是一种新颖的策略,专门用来解决LLM在特定领域知识不足的问题。这种情况可能是由于模型在该领域的训练数据不足,或者是因为查询本身需要深入的专业领域知识。

在这种方法中,LLM首先自行生成与查询相关的背景知识或上下文信息,以此来丰富和补充原始的查询内容。通过这种方式,模型能够在缺乏特定知识的情况下,提供更加全面和深入的答案。

示例

**初始提示:** Chemicals are bad for you. Yes or No?

**初始回答:** Yes.

这个回复过于简单化,没有考虑到主题的复杂性。没有区分有害和有益的化学物质,也没有考虑到上下文或剂量。

为了改进,我们要求LLM生成额外的背景信息和例子来支持其答案:

**改进后的提示:** Chemicals are bad for you. Yes or No? Generate additional background information to support your claims

**改进后的回答:** 
No, not all chemicals are bad for you.

Chemicals are substances with a distinct molecular composition that are produced by or used in chemical processes. They are fundamental to life and can be beneficial or harmful depending on their nature and use.

Beneficial Chemicals:

Water (H₂O): Essential for life, hydration, and many biological processes.
Oxygen (O₂): Vital for respiration and energy production in cells.
Medicines: Aspirin (acetylsalicylic acid) for pain relief, penicillin (an antibiotic) to fight infections.Vitamins: 
Vitamin C (ascorbic acid) supports the immune system and overall health.
Harmful Chemicals:

Lead: Exposure can cause poisoning and neurological damage.
Asbestos: Inhalation can lead to serious lung diseases, including cancer.
Mercury: Toxic and can damage the nervous system.
In conclusion, the impact of chemicals on health depends on their type, concentration, and how they are used or exposed to the human body.

通过激发LLM自身生成背景知识的能力,即便在超出其原始训练范围的情况下,模型也能给出更加明智和全面的最终答案。这种自我补充知识的过程,让LLM在面对跨领域的复杂问题时,依然能够游刃有余。

如何学习AI大模型?

作为一名热心肠的互联网老兵,我决定把宝贵的AI知识分享给大家。 至于能学习到多少就看你的学习毅力和能力了 。我已将重要的AI大模型资料包括AI大模型入门学习思维导图、精品AI大模型学习书籍手册、视频教程、实战学习等录播视频免费分享出来。

这份完整版的大模型 AI 学习资料已经上传CSDN,朋友们如果需要可以微信扫描下方CSDN官方认证二维码免费领取【保证100%免费

一、全套AGI大模型学习路线

AI大模型时代的学习之旅:从基础到前沿,掌握人工智能的核心技能!

img

二、640套AI大模型报告合集

这套包含640份报告的合集,涵盖了AI大模型的理论研究、技术实现、行业应用等多个方面。无论您是科研人员、工程师,还是对AI大模型感兴趣的爱好者,这套报告合集都将为您提供宝贵的信息和启示。

img

三、AI大模型经典PDF籍

随着人工智能技术的飞速发展,AI大模型已经成为了当今科技领域的一大热点。这些大型预训练模型,如GPT-3、BERT、XLNet等,以其强大的语言理解和生成能力,正在改变我们对人工智能的认识。 那以下这些PDF籍就是非常不错的学习资源。

img

四、AI大模型商业化落地方案

img

作为普通人,入局大模型时代需要持续学习和实践,不断提高自己的技能和认知水平,同时也需要有责任感和伦理意识,为人工智能的健康发展贡献力量。

  • 19
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值