知识吧 知识资讯 干货分享 | Prompt实践 – 个人生产力篇

干货分享 | Prompt实践 – 个人生产力篇

如何让大语言模型更好地帮助个人生活和工作?本篇文章将对此进行解析。在我们使用Prompt时,首先需要了解其整体的运转流程,以及关键特性,而其中的具体细节,我们看看作者的分享。

大模型的出现无疑能提升个人生产力,但具体如何提升,这方面身边其实很多人不知道,因此笔者打算从个人实践来分享,如何让LLM更好的帮我们工作和生活。

总的来说,合理使用Prompt可以提高个人生产力,让LLM更好地帮助我们工作和生活。希望这些总结对大家有所帮助!

一、了解Prompt原理及基础概念

1. Prompt的前提及原则

在LLM中,Prompt是针对输入输出的一个描述或者问题,提出一个恰当的问题可以说是解决了问题的一半。因此在使用LLM前,需要先思考以下几方面:

  • 是一个什么样的问题,封闭问题 / 开放问题(input)
  • 提出这个问题的人和解决这个问题是什么角色(role)
  • 这个问题需要从哪几个方面或者说步骤来解决(step)
  • 这个问题需要一个怎样的答案(output)

无疑明确好问题的具体细节能更好的帮助我们得到答案,因此在定义完上面的内容后再结合Prompt的几个原则:

  • 清晰明了:请告诉我关于狗的消息(不清晰)、狗的智商与其他动物相比如何?(清晰)。
  • 具体:解释机器学习(不具体)、请用简单的语言解释机器学习是如何通过数据和算法来训练模型(具体)。
  • 引导性:你怎么看待气候变化(缺乏引导)、依据科学证据,描述一下气候变化对环境和人类社会的影响。(引导性)。
  • 避免偏见:为什么某个政党是最好的选择?(存在偏见)、列举一些政党的核心理念、并讨论对国家发展产生的影响(中立客观)。

另考虑到目前大模型训练的数据来看,提问时用英文的效果会比中文更优,因此建议以英文prompt为首选。

2. Prompt的关键特性

目前存在的两种Prompt分类有两种:

  1. 编码Prompt工程
  2. 撰写相关输入指令-本次分享的范围

message列表对象

LLM对于内容的输入输出采用message列表,可以理解为message列表对象是LLM交互的媒介,一般包含两个内容:

  1. Role(角色)-user/system/assistant
  2. Content(内容)-输入内容及返回内容

其中user为用户输入时的值,system为系统通知LLM,用户无感知,assistant为LLM返回内容时的值。

如用户输入:请帮我找下番茄炒蛋的做法。

此时构建的messages:

  • Role:user
  • Content:请帮我找下番茄炒蛋的做法
  • Role:system
  • Content:NA
  • Role:assistant
  • Content:一般来说,番茄炒蛋的做法为…

因此为什么前文提及了需要先明确好问题的具体细节再使用LLM。若没定义清楚message的细节,你获得的答案有可能差强人意。

Temperature

LLM超参数Temperature(温度)是控制生成文本的随机性程度。取值范围在[0,1]。

当温度接近于0时,模型倾向于选择更高概率的词。因此生成的内容更连贯及准确,但缺乏多样性。

当温度接近于1时,模型按照原始概览分布选择单词,意味着生成的内容更加发散多样,充满想象力。但缺乏准确性。

因此,如果你期望得到更具创造性的回答,可以提高温度值,如0.7或者1。如果你期望获得更准确连贯的回答,可以降低温度值,如0。

二、Prompt模板及具体场景应用(重点内容)

1. Prompt模板

干货分享 | Prompt实践 – 个人生产力篇

结合前文我们确定的问题细节及LLM关键特性,我们可以整理一个大致的Prompt模板如下,可依据需求酌情增删:

[用户角色][任务][AI扮演的角色][思路步骤][附加条件]

1)用户角色

以我是一名…开头,可以是社会角色(打工人)职位(售后专员)等。

2)任务

任务可以简要概述你的任务背景,明确好需要生成的内容结果结构。

3)AI扮演的角色

可以让AI扮演资深人士,如统计学家、CEO或者有着10年行业经验的职员等。

4)思路步骤

即按你预设的步骤进行思考,如问题不是很复杂,可不展开。

5)附加条件

这里可补充外部环境、项目背景、需处理的文本内容等等。

2. Prompt具体场景应用

1)Summary(总结文本)

pro_review

Got this panda plush toy for my daughter’s birthday,
who loves it and takes it everywhere. It’s soft and
super cute, and its face has a friendly look. It’s
a bit small for what I paid though. I think there
might be other options that are bigger for the
same price. It arrived a day earlier than expected,
so I got to play with it myself before I gave it
to her.

Prompt

Your task is to generate a short summary of a product
review from an ecommerce site to give feedback to the
Shipping department.

Summarize the review below, delimited by triple
backticks, in at most 30 words, and focusing on any aspects
that mention shipping and delivery of the product.

Response

The customer is happy with the product but suggests offering larger options for the same price. They also mention that the item arrived a day earlier than expeced.

2)Inference(推断)

Review

Needed a nice lamp for my bedroom, and this one had
additional storage and not too high of a price point.
Got it fast. The string to our lamp broke during the
transit and the company happily sent over a new one.
Came within a few days as well. It was easy to put
together. I had a missing part, so I contacted their
support and they very quickly got me the missing piece!
Lumina seems to me to be a great company that cares
about their customers and products!!

Prompt

Identify the following items from the review text:
– Sentiment (positive or negative)
– Is the reviewer expressing anger? (true or false)
– Item purchased by reviewer
– Company that made the item

The review is delimited with triple backticks.
Format your response as a JSON object with
“Sentiment”, “Anger”, “Item” and “Brand” as the keys.
If the information isn’t present, use “unknown”
as the value.
Make your response as short as possible.
Format the Anger value as a boolean.

Response

{

“Sentiment”: “positive”,

“Anger”: false,

“Item”: “lamp”,

“Brand”: “Lumina”

}

三、总结

1. Prompt模板

本文分享的模板是适用于通用范畴,每个行业每个人的需求都属于定制化,可以将该模板作为工具按需调整:

[用户角色][任务][AI扮演的角色][思路步骤][附加条件]

工具是好是坏,得看人怎么使用,LLM和Prompt模板也是一样的道理。

2. Prompt优化流程

发现问题->提出Prompt->获取结果->内容评估->发现问题->优化Prompt模板

3. Prompt原则

  1. 清晰明了
  2. 具体
  3. 引导性
  4. 避免偏见

关于如何让LLM更好地帮助我们工作和生活,下面我会对此内容进行总结:

  • Prompt的前提及原则:在使用LLM之前,需要思考问题的类型、角色、解决步骤和期望答案,并遵循清晰明了、具体、引导性和避免偏见的原则。
  • Prompt的关键特性:包括编码Prompt工程、message列表对象、温度参数的控制。合理利用这些特性可以更好地引导LLM生成准确、连贯或创造性的回答。
  • Prompt模板及具体场景应用:你提供了一个模板供参考,包括用户角色、任务、AI扮演的角色、思路步骤和附加条件。根据实际需求,可以调整和定制化该模板。
  • Prompt优化流程:发现问题、提出prompt、获取结果、内容评估和优化Prompt模板。通过不断优化Prompt,可以获得更好的回答效果。

本文由 @SiegZhong 原创发布于知识吧,未经许可,禁止转载

题图来自 Unsplash,基于 CC0 协议

本文来自网络,不代表知识吧立场,转载请注明出处:https://zhishiba.net/6281.html
上一篇
下一篇

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

返回顶部

Warning: error_log(/www/wwwroot/www.zhishiba.net/wp-content/plugins/spider-analyser/#log/log-2917.txt): failed to open stream: No such file or directory in /www/wwwroot/www.zhishiba.net/wp-content/plugins/spider-analyser/spider.class.php on line 2900