发挥LLM大语言模型的潜力快速工程指南
近年来,语言模型得到了迅速改进,GPT-3 和 GPT-4 等大型语言模型 (LLM) 占据了中心舞台。这些模型因其以令人不可思议的执行各种任务的能力而流行。随着这些模型的参数数量(数十亿!)增加,这些模型也意外地获得了新能力。
在本文中,我们将探讨 LLM、它们可以执行的任务、它们的缺点以及各种提示工程策略。 LLM是什么?
LLM 是经过大量文本数据训练的神经网络。训练过程允许模型学习文本中的模式,包括语法、句法和单词关联。这些模型使用这些学习到的模式来生成类似人类的文本,使其成为自然语言处理 (NLP) 任务的理想选择。 哪些LLM可用?
有多种 LLM 可用,其中 GPT-4 最受欢迎。其他模型包括 LLaMA、PaLM、BERT 和 T5。每个模型都有其优点和缺点,其中一些是开放的,另一些是封闭的,只能通过 API 使用。 LLM的缺点
尽管表现出色,但LLM有一些局限性。一个显着的缺点是他们无法超越提示中提供的信息进行推理。此外,LLM 可以根据他们训练数据生成有偏见的文本。控制 LLM 的输出也具有挑战性,因此有必要使用及时的工程策略来实现所需的输出。 可以执行哪些任务?
以下是这些任务的列表以及每个任务的示例。 文本摘要
LLM 可以生成长文本的摘要,使用提示模板来总结一段文本: Summarize the text above: / Explain the text above in sentences:
例如,我们可以要求使用以下提示来总结这段文本:
Prompt In a mechanical watch the watch"s gears are turned by a spiral spring called a mainspring. In a manual watch energy is stored in the mainspring by turning a knob, the crown on the side of the watch. Then the energy from the mainspring powers the watch movement until it runs down, requiring the spring to be wound again. A self-winding watch movement has a mechanism which winds the mainspring using the natural motions of the wearer"s body. The watch contains an oscillating weight that turns on a pivot. The normal movements of the watch in the user"s pocket (for a pocketwatch) or on the user"s arm (for a wristwatch) cause the rotor to pivot on its staff, which is attached to a ratcheted winding mechanism. The motion of the watch is thereby translated into circular motion of the weight which, through a series of reverser and reducing gears, eventually winds the mainspring. There are many different designs for modern self-winding mechanisms. Some designs allow winding of the watch to take place while the weight swings in only one direction while other, more advanced, mechanisms have two ratchets and wind the mainspring during both clockwise and anti-clockwise weight motions. Explain the text above in 2 sentences:
给出以下输出:
Output A mechanical watch uses a mainspring to power the movement of the watch"s gears. In a manual watch, the mainspring is wound by turning a knob, while a self-winding watch uses the natural motion of the wearer"s body to wind the mainspring through an oscillating weight and ratcheted winding mechanism.信息提取
从大量文本中识别和提取特定信息。这在新闻和商业等领域很有用。 Mention X in the text above: / List X in the text above:
例如,我们要求从以下文本中提取地名:
Prompt The earliest credible evidence for a successful design is the watch made by the Swiss watchmaker Abraham-Louis Perrelet, who lived in Le Locle. In late 1776 or early 1777, he invented a self-winding mechanism for pocket watches using an oscillating weight inside the watch that moved up and down. The Geneva Society of Arts, reporting on this watch in 1777, stated that 15 minutes walking was necessary to fully wind the watch. List the names of places in the text above:
输出是:
Output Le Locle, Geneva.问答
根据提示中提供的信息回答问题。
Template Answer the question based on the context below. . Respond "Not sure" if not sure about the answer. Context: Q: A:
Prompt Answer the question based on the context below. Answer in a single sentence. Respond "Not sure" if not sure about the answer. Context: An automatic watch, also known as a self-winding watch or simply an automatic, is a mechanical watch where the natural motion of the wearer provides energy to wind the mainspring, making manual winding unnecessary if worn enough. It is distinguished from a manual watch in that a manual watch must have its mainspring wound by hand at regular intervals. Q: Do automatic watches need to be manually wound? A:
ChatGPT 回应:
Output No, automatic watches do not need to be manually wound if worn enough because the natural motion of the wearer provides energy to wind the mainspring.文本分类
LLM 可以将文本分类到预定义的类别中,例如情绪分析或垃圾邮件检测。
Template Classify the text into : Text: Classification:
例如,我们可以尝试根据其情绪是正面、中性还是负面来对文本进行分类:
Prompt Classify the text into positive, neutral or negative: Text: That shot selection was awful Classification:
Output Negative对话
LLM 可以生成类似人类的对话,在聊天机器人和客户服务应用程序中很有用。我们可以指示 LLM 以特定方式跟踪对话。
Template The following is a conversation with . The should answer . Person: : Person: :
LLM 将按照我们指示的参与者类型作出响应,通过将整个对话与新的响应再次传递给它来继续对话。例如:
Prompt The following is a conversation with a lawyer. The lawyer should answer simply and in layman terms. Person: Hello, I would like to know how to dispute a parking ticket Lawyer:
Output Sure, I can help. The first step is to check the ticket for any errors or mistakes. If you find any, you can use those as grounds to dispute the ticket. If there are no mistakes, you can still dispute the ticket by providing evidence to support your case, such as photos or witness statements. You can also request a hearing to present your case in person.
Prompt The following is a conversation with a lawyer. The lawyer should answer simply and in layman terms. Person: Hello, I would like to know how to dispute a parking ticket Lawyer: Sure, I can help. The first step is to check the ticket for any errors or mistakes. If you find any, you can use those as grounds to dispute the ticket. If there are no mistakes, you can still dispute the ticket by providing evidence to support your case, such as photos or witness statements. You can also request a hearing to present your case in person. Person: How do I request a hearing? Lawyer:
Output To request a hearing, you"ll need to follow the instructions on the back of the ticket or on the website provided. Usually, you"ll need to submit a written request within a certain timeframe, along with any evidence or supporting documents you have. Once your request is received, you"ll be notified of the date, time, and location of your hearing.代码生成
LLM 可以生成代码,开发人员更容易创建复杂的软件程序。我们可以写一个代码注释来描述我们希望代码做什么,LLM 将能够尽最大努力为我们做这件事。我们希望代码做的事情越复杂,我们就需要在提示注释中提供越具体和描述性的信息。
模板可能因我们要生成的编程语言而异,但建议大致遵循此模板:
Template Method: Language: Description: Parameters: Context: Output:
爱奇艺热播剧被搬运到外网,境内外访问内容还不同知名视频APP海外版用户大量流失,面对境外取证难境外诉讼成本高风险大等困难,权利人该怎么办?近日,广州互联网法院审理了一起在境外侵害热播剧作品信息网络传播权纠纷系列案。图1图2北京
为什么高通不敢断供华为芯片?大家都知道,高通是一家美国通信巨头,是它把手机与互联网连接在一起,开创了移动互联网时代。也因此在3G时代,手握全球最多的3G技术专利,一度成为一家独大的通信寡头,在全球占据绝对主导
三星新专利GalaxyWatch6有望搭载内置投影仪投影仪?三星已经为带有内置投影仪的智能手表申请了专利。投影仪将用于显示来自用户手上主显示器的信息。目前尚不清楚这项技术是否或何时会在未来的GalaxyWatch中实施。三星制造了一
再也不用当猫奴首发1399元!小米智能全自动猫砂盆开售14天不用管现在城市中养猫的朋友越来越多了,最头痛的事就是排泄物的处理了,不得不说猫屎真的是非常臭。因此,这两年市面上出现了不少全自动猫砂盆,无需手动清理,还能自动除臭,小米最近也上架了一款类
小米Ax6000路由器断流视频通话卡顿解决办法家里升级了1000M的宽带,就把曾经的万元路由器feixunK3给换成了小米AX6000,这次2。5g网口,WIFI6icon,参数什么都不错。就是实际使用中发现微信视频通话卡顿,
文末有门票福利第三十届二月新春精品文艺汇演21日开演顺义区融媒体中心消息为推动全区文旅活动广泛深入开展,营造欢乐喜庆祥和文明的文化氛围,由区委宣传部区文旅局主办的福满京城,春贺神州2023年第三十届二月新春精品文艺汇演将于2月21日
今日分析朗玛信息优刻得冰川网络汤姆猫一朗玛信息概念家庭医生互联网医疗网络游戏公司持续开展下沉式医疗服务模式,探索以39健康医疗服务平台为基础的慢病管理的产品体系,通过全新的O2O医疗服务模式,将部分诊疗环节转移到线上
去有风的地方纽约时报盛赞刘亦菲!纽约时报作为全世界最具影响力的媒体之一,其文章中盛赞许红豆(刘亦菲饰,真人版电影花木兰的主演),一位在北京酒店行业奋斗上进的年轻女性,遇到生活危机后到乡下生活,那里有各种各样个性的
没买到宏远门票的球迷,可以看这里!大家好,我是璐璐!提笔先来做个调查问卷你抢到票了吗?通过昨天的抢票速度可以看出广东宏远球迷的基数之强大,纵观整个CBA联盟,没有哪一支球队是可以做到一票难求的!就连人气极旺的辽宁男
周六晚开战陕西信达男篮冲击第四冠!随着卫冕冠军广西威壮队在半决赛中以总比分20将安徽文一队淘汰出局,本赛季全国男子篮球联赛(NBL)总决赛的对阵双方也终于得以确定向队史第四座冠军奖杯发起冲击的西北狼陕西信达男篮,对
你觉得宝妈摆摊卖气球丢人吗?关于这个问题,我纠结了很久。我是个85后的全职宝妈,孩子已经6岁多了,中间我也出去工作过1年半,但最终由于外部因素,放弃了工作。也就是说,我离开职场有56年的时间了。但在这全职带娃