范文健康探索娱乐情感热点
投稿投诉
热点动态
科技财经
情感日志
励志美文
娱乐时尚
游戏搞笑
探索旅游
历史星座
健康养生
美丽育儿
范文作文
教案论文
国学影视

发挥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:  
  例如,如果想获取带有分页的 API,编写以下注释:
  Prompt /* Method: fetchFirst5Pages  * Language: Javascript  * Description: Fetch the first 5 pages from this paginated API: http://example.com/pages/?n=x  * Context: This API accepts the following URL parameters:  *   n: the number of the page to fetch  * Output: the content of the first 5 pages  */
  Output Here"s an example implementation of the fetchFirst5Pages method in JavaScript, assuming the use of the fetch function:  async function fetchFirst5Pages() {   const baseUrl = "http://example.com/pages/?n=";   const pages = [];    for (let i = 1; i <= 5; i++) {     const url = baseUrl + i;     const response = await fetch(url);      if (!response.ok) {       throw new Error(`Error fetching page ${i}`);     }      const pageData = await response.json();     pages.push(pageData);   }    return pages; }  This function uses a loop to fetch the first 5 pages from the API by appending the page number to the base URL. It checks if the response from the server is okay and throws an error if it"s not. Then, it parses the JSON data from the response and adds it to an array of pages. Finally, it returns the array of pages.推理
  LLM可能难以完成一些基本任务,例如算术问题。但是,如果我们要求 LLM 根据其响应进行推理,我们可以帮助它找到正确的答案。这是推荐的模板:
  Template Q:  A: Let"s work this out in a step by step way to be sure we have the right answer. First, .
  在这个例子中,如果我们不加推理地提出一个简单的算术问题,它就会失败:
  Prompt Answer the following question. Respond "Not sure" if not sure about the answer. Q: The sum of prime numbers in the following list are a multiple of 3: [2, 4, 6, 7, 9, 14] A: [Yes or No]
  Output No. The sum of prime numbers in the list [2, 4, 6, 7, 9, 14] is not a multiple of 3. Therefore, the answer is "No".
  但是,如果我们指示 LLM 对其答案进行推理,我们会得到截然不同的结果:
  Prompt Q: The sum of prime numbers in the following list are a multiple of 3: [2, 4, 6, 7, 9, 14] A: Let"s work this out in a step by step way to be sure we have the right answer. First, we find the prime numbers in the list and add them together. Then we check whether the resulting number can be pided by 3.
  Output Sure, let"s work this out step by step.  The prime numbers in the list are 2 and 7. So we can add them together:  2 + 7 = 9  The resulting number is 9. Now we need to check whether it is a multiple of 3. We can do this by checking if the remainder of 9 pided by 3 is equal to 0:  9 % 3 = 0  Since the remainder is 0, we know that 9 is indeed a multiple of 3.  Therefore, the answer is "Yes", the sum of prime numbers in the list [2, 4, 6, 7, 9, 14] is a multiple of 3.攻略
  虽然这些模板充分发挥 LLM 的潜力以满足你的需求,但有时它们仍然难以完成某些复杂的任务。已经开发了一些技术来帮助 LLM 获得满意的答案。到目前为止,我们只使用了零样本提示,但是,我们可以使用更复杂的技术。 零次提示
  我们一直在对本文中的所有示例使用零样本提示。零样本提示意味着向 LLM 传递一个提示,只包含我们希望它回答的问题,而没有任何示例说明它在其他情况下应该如何响应。例如,在之前的例子中我们做了:
  Prompt Classify the text into positive, neutral or negative: Text: That shot selection was awful Classification:
  Output Negative
  对于模型来说,这可能不足以准确回答我们想要的结果。那我们还有别的办法吗? 小提示
  与零样本提示相反,使用少样本提示,提出问题之前给 LLM 一些它应该如何回应的例子。例如,假设要对文本的情感进行分类。但我们希望它每次都能以非常具体的格式给我们答案。我们可以像这样预先给它举几个例子:
  Prompt Classify the text into positive, neutral or negative: Text: Today the weather is fantastic Classification: Pos Text: The furniture is small. Classification: Neu Text: I don"t like your attitude Classification: Neg Text: That shot selection was awful Classification:
  Output Neg思维链提示
  对于更复杂的任务,可以将小样本提示与让模型推理其答案相结合。我们可以使用与之前相同的示例来查看推理和小样本提示如何影响结果:
  Prompt Q: The sum of prime numbers in the following list are a multiple of 3: [2, 4, 6, 7, 9, 14] A: The prime numbers in the list are 2 and 7. Their sum is 9. 9 % 3 = 0. The answer is yes. Q: The sum of prime numbers in the following list are a multiple of 3: [1, 2, 4, 7, 8, 10] A: The prime numbers in the list are 1, 2 and 7. Their sum is 10. 10 % 3 = 1. The answer is no. Q: The sum of prime numbers in the following list are a multiple of 3: [1, 2, 3, 4] A: The prime numbers in the list are 1, 2 and 3. Their sum is 6. 6 % 3 = 0. The answer is yes. Q: The sum of prime numbers in the following list are a multiple of 3: [5, 6, 7, 8] A:
  Output The prime numbers in the list are 5 and 7. Their sum is 12. 12 % 3 = 0. The answer is yes.最后说明
  LLM彻底改变了自然语言处理领域,但要最大限度地发挥其潜力,及时工程至关重要。通过了解 LLM 可以执行的任务、它们的缺点以及各种及时的工程策略,开发人员可以利用 LLM 的力量来创建创新和有效的解决方案。在不久的将来可能会开发出更多的策略和技术,因此请关注该领域的进一步发展,以最大限度地发挥 LLM 的潜力。此外,随着 LLM 继续变得越来越大,增加了数十亿个参数,我们现在甚至无法想象的更多任务很可能会成为可能。想想使用这些新工具可以做什么,以及它们将来会为我们服务哪些用例,真是令人惊叹。

咋想的?雷克萨斯RZ450eSUV在美起售价高于特斯拉ModelY小隆哥从外媒了解到,在美首款雷克萨斯纯电动SUVRZ450e已开放预订。雷克萨斯让用户体验该车与其它品牌纯电车型的区别,其中,就有特斯拉ModelY。但RZ450e是否比特斯拉Mo3。9秒破百!特斯拉全新车型谍照曝光近日,外媒曝光一组特斯拉全新车型的路试谍照,或命名为ModelQ。新车定位于紧凑型轿车,预计将于2023年3月发布。动力上,将搭载单双电机驱动系统,综合续航将超过400公里。新车整等等党出手!特斯拉降价三天获得三万订单!这波过后还会降吗?在特斯拉官宣价格直降之后,3天时间获3万订单,销量激增的表现在国内市场并不是特别罕见,但作为高端豪华车型,能够拥有如此成绩,这代表了完全不同的含义,这次介绍以Model32022款2月12日,合肥造量子计算机首次免费开放参观大皖新闻讯据合肥发布消息,4台中国造量子计算机首次免费向中国公民开放参观!零距离了解现实版流浪地球MOSS雏形影片中的MOSS并非科幻,在中国量子科技创新之城合肥高新区,中国第一家杭州神人造出无人驾驶自行车,堪比特斯拉,专家发言将引起新时代无人驾驶自动自行车,听起来很炫酷,大家并表示到这怎么可能实现呢?因为在大家心里像这种黑科技只会出现在科幻电影里,所以大家心里保持怀疑。在接下的时间有一位来自杭州高中生,打破大家的怀金税四期不严,但释放的信号很严金税四期早就上线了。此前一直有传言称其严重性,企业方方面面的逃税行为都受到限制。今天就来聊聊金税四期的一些事情吧。首先,金税四期相比三期有什么优势?四期金税主要以大数据为主。我相信詹姆斯我和布雷迪经常交流,他给我带来动力继续征战湖人前锋勒布朗詹姆斯昨日接受了ESPN专访。关于他和NFL名宿汤姆布雷迪之间的交流,詹姆斯说是的,我们确实有交流。我实际上拥有很棒的沟通。每次我和他聊天时,我都说,听着,你激励着我江阴银行第一大股东变更后,第三大股东股权将被拍卖目前,华发实业的全部股权都已被冻结。同时,华发实业已多次被列为失信被执行人,法定代表人孙志华被限制高消费。江阴银行第三大股东持有的股份被拍卖。公开资料显示,江阴市人民法院将于202长三角铁路2023年建设投资保持高位运行年度计划超900亿元江苏南沿江城际铁路铺轨作业场景。朱永安摄中新网上海2月10日电(浦帆)记者10日从中国铁路上海局集团有限公司(以下简称铁路上海局)获悉,2023年,长三角铁路建设将继续保持投资规模盘点切尔西近些年的四大超级后腰他们为切尔西的崛起扫清障碍头条创作挑战赛切尔西俱乐部自从引进马克莱莱之后,领略到了黑又硬后腰的好处,于是从此开始发掘一代代的黑又硬超级后腰,他们的出色发挥也让我们看到了超级后腰的能量。下面我们盘点一下切尔西这就是信心丨开年用工热,六大关键词看经济回稳向好兔年春节刚过,劳动力市场就呈现加速回暖两头旺。各地正加力保用工稳就业,推动新一年经济发展拔得头彩。六大关键词感知用工热度折射出的经济温度。一边是企业加速复工满产用工需求涨一边是劳动
爱奇艺热播剧被搬运到外网,境内外访问内容还不同知名视频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年的时间了。但在这全职带娃