链载Ai

标题: 如何写好结构化提示词充分发挥大模型潜力?——分享LangGPT 提示词模版 [打印本页]

作者: 链载Ai    时间: 3 小时前
标题: 如何写好结构化提示词充分发挥大模型潜力?——分享LangGPT 提示词模版

如何写好结构化提示词充分发挥大模型潜力?——分享LangGPT 提示词模版


写在前面

LangGPT是一种结构化的提示词模版,它明确告诉你每个部分要填写什么内容,你按照要求填写,最后形成的提示词输入ChatGPT之后,可以获得非常不错的输出结果。而且这个模版具备以下特点:

我在刚开始接触提示工程,上网找资料就了解到LangGPT模版以及作者云中江树的大名。对比其它提示词模版,它的优势很明显,前面已经提到。所以我现在大部分的重要的提示词,都是用这套模版撰写。包括我前面分享的文章,不管是提示词还是GPTs,基本都使用了这套模版。

今天重新分享这套模版,旨在带着大家认识这套提示词,并且结合一些我个人的看法,帮助大家理解,并且积极应用起来。

  1. 我直接引用了云中江树大佬在GitHub上的介绍文档,全英文
  2. 我会使用在一些关键地方做一些备注,包括我的看法和问题。

看到这些引用文字就是我添加的备注和思考。

LangGPT提示词的GitHub主页https://github.com/crowscc/LangGPT

这是运用这套提示词的具体案例:https://chat.openai.com/share/e63f35d6-16d5-4f4b-b4fe-46eb19a75c19

想了解更多LangGPT以及结构化提示词的知识可以查看云中江树老师的分享https://zhuanlan.zhihu.com/p/647134737

温馨提示:⬇️ 内容很长 ,建议使用电脑浏览。


Role: LangGPT

Profile

Skill

  1. ChatGPT excels at role-playing. By providing role descriptions, role behaviors, and skills, it can produce actions that align well with the role.
  2. LangGPT designed to help people write powerful prompt based on the large language models' features.
  3. The usage of LangGPT is descripted in the following content(determined by triple dashs):

Role(角色)是这个提示词的核心;作者认为ChatGPT擅长扮演角色,表演角色,所以定义清晰的角色非常重要。


? LangGPT — Empowering everyone to create high-quality prompts!

The LangGPT project aims to facilitate the seamless creation of high-quality ChatGPT prompts for everyone by utilizing a structured, template-based methodology. It can be viewed as a programming language specifically crafted for designing prompts for large language models.

Current prompt design methods tend to offer only a handful of tips and principles, without a systematic and adaptable perspective. LangGPT transforms the prompt design process by incorporating templates, variables, and commands, enabling prompt creation to be as intuitive and straightforward as object-oriented programming. LangGPT sets the stage for the large-scale, efficient production of high-quality prompts.

With a solid grasp of LangGPT, you'll be able to quickly and effortlessly begin creating prompts for large language models in just a few minutes. ?

LangGPT通过合并模板、变量和命令来转换提示词设计过程,使提示符创建像面向对象编程一样直观和直接。——就像组合乐高积木一样,把你想要的组合在一起,非常直观。因为模版是结构化的,模块不多,所以撰写一套提示词下来,可以只花几分钟时间!

Prerequisites

前置条件,1是会markdown语言,这个稍微花点时间学习很简单,你也可以让ChatGPT教你;2是GPT-4的效果更好。

Getting Started

Here, we provide a small FitnessGPT example to help you quickly get started with LangGPT. LangGPT offers prompt-writing templates, which you can use to rapidly create high-quality prompts.

这里作者使用了一个健身GPT提示词作为例子说明这套提示词的用法。这套提示词的目标就是根据用户提供的身体信息和健身目标,提供健身,饮食等建议。

#Role:FitnessGPT

##Profile

-Author:YZFly
-Version:0.1
-Language:English
-Description:YouareahighlyrenownedhealthandnutritionexpertFitnessGPT.Takethefollowinginformationaboutmeandcreateacustomdietandexerciseplan.

###Createcustomdietandexerciseplan
1.Takethefollowinginformationaboutme
2.Iam#Ageyearsold,#Gender,#Height.
3.Mycurrentweightis#Currentweight.
4.Mycurrentmedicalconditionsare#MedicalConditions.
5.Ihavefoodallergiesto#FoodAllergies.
6.Myprimaryfitnessandhealthgoalsare#PrimaryFitnessHealthGoals.
7.Icancommittoworkingout#HowManyDaysCanYouWorkoutEachWeekdaysperweek.
8.Ipreferandenjoyhistypeofworkout#ExercisePreference.
9.Ihaveadietpreference#DietPreference.
10.Iwanttohave#HowManyMealsPerDayMealsand#HowManySnacksPerDaySnacks.
11.Idislikeeatingandcannoteat#ListFoodsYouDislike.

##Rules
1.Don'tbreakcharacterunderanycircumstance.
2.Avoidanysuperfluouspreandpostdescriptivetext.

##Workflow
1.Takeadeepbreathandworkonthisproblemstep-by-step.
2.Youwillanalysisthegiventhepersonalinformation.
3.Createasummaryofmydietandexerciseplan.
4.Createadetailedworkoutprogramformyexerciseplan.
5.CreateadetailedMealPlanformydiet.
6.CreateadetailedGroceryListformydietthatincludesquantityofeachitem.
7.Includealistof30motivationalquotesthatwillkeepmeinspiredtowardsmygoals.

##Initialization
Asa/an<Role>,youmustfollowthe<Rules>,youmusttalktouserindefault<Language>,youmustgreettheuser.Thenintroduceyourselfandintroducethe<Workflow>.

With the help of prompt above, you will create a Role named FitnessGPT, he/her will help you design wonderful personal diet and exercise plan.

Role

ChatGPT excels at role-playing. By providing role descriptions, role behaviors, and skills, it can produce actions that align well with the role.

Therefore, LangGPT designed the Role template to help ChatGPT better understand user intentions. The Role template is the core of LangGPT.

作者再次强调Role角色的重要性 下面提供了提示词的模版⬇️

Role Template

Here is the markdown Role template:

#Role:Your_Role_Name

##Profile

-Author:YZFly
-Version:0.1
-Language:Englishor中文orOtherlanguage
-Descriptionescribeyourrole.Giveanoverviewoftherole'scharacteristicsandskills

###Skill-1
1.skilldescription1
2.skilldescription2

###Skill-2
1.skilldescription1
2.skilldescription2

##Rules
1.Don'tbreakcharacterunderanycircumstance.
2.Don'ttalknonsenseandmakeupfacts.

##Workflow
1.Takeadeepbreathandworkonthisproblemstep-by-step.
2.First,xxx
3.Then,xxx
4.Finally,xxx

##Initialization
Asa/an<Role>,youmustfollowthe<Rules>,youmusttalktouserindefault<Language>,youmustgreettheuser.Thenintroduceyourselfandintroducethe<Workflow>.

这部分介绍了模版中每个板块的作用,

The Role template primarily consists of four sections:

Profile是这个提示词角色的简历,或者说叫角色小传;它包括skill技能,也就是这个角色要完成任务需要具备哪些能力;其实这里可以拓展一下:

  1. 除了skill是不是还有knowledge,或者更多的参数?
  2. 为了让这个角色更加鲜活,比如你希望它是风趣还是严肃,个性更加鲜明,是不是可以用另外一个提示词去编写角色小传,然后粘贴到这里来,整个回复口吻是不是完全不同,更符合你的口味呢?

Rules是规则,即你不希望ChatGPT打破的事情。模版中提到:不能跳出角色,不能说废话——说实话,我觉得没有这两个要求,ChatGPT也做的不错,已经很少让我感受到它脱离角色或者讲废话了(当然,这里也许跟我在 Customize ChatGPT 中的个性化定制有关)。另外,很多时候我并不知道 “它不能违反什么或者破坏什么”,所以我写不出来;不过有一点是可以要求的:你必须要完成每一步之后跟我确认,再进行下一步。这一点后面会谈到。

Workflow是工作流程,你希望它应该按照哪些步骤一步一步完成工作。有明确的工作流程和没有工作流程要求,ChatGPT的输出质量会差异很大。后者很可能会跳过一些关键的过程,而让结果变得平庸。所以我们一定要清楚并且提出哪些是它必须要经历的过程。

但是我在使用的时候会遇到以下问题:

  1. 如果我写了8个步骤,ChatGPT会把每一个步骤的过程都打印出来,就像你的下属写PPT之前,把开机,打开PPT,新建文件……这些过程全部展示给你看;实际上这是完全不必要的,而且会占用输出的文字数量——换句话说会大大压缩最后输出结果的数量和质量,甚至会被迫中断。
  2. 每个步骤的结果对我来说都很重要,比如写一篇文章——输出框架,撰写每个板块,生成标题——都很重要,都会影响后面的环节,应该先让我确认后,或者经过优化,再进入下一步。而且一次只做一件事,输出的效果要显然更好。所以以上问题是模版当中没有提供解决方案的。

Initialization是初始化的意思,也就是ChatGPT要怎么跟你开始对话。这种初始化很重要,一方面提醒你要做什么,比如给你一个清单,要求按清单填写;另一方面也告诉了第三方使用者怎么运用。模版中使用了< > 要求ChatGPT重视和回顾自己的角色,相当于一开始就要求它“牢记使命”,“不忘初心”。后面也会介绍。

A role can be defined and configured using the four sections defined above.

Additionally, if you need to create complex prompts with commands, reminder, and other features, simply add the corresponding sections, as demonstrated in the advanced usage section.

下面是介绍如何一步一步使用这套模版。

Steps to Use the Role Template

  1. Set the role name: Replace Your_Role_Name in Role: Your_Role_Name with your desired role name.
  2. Write the role's resume in the # Profile section:







欢迎光临 链载Ai (https://www.lianzai.com/) Powered by Discuz! X3.5