面向 NLP 任务的大模型 Prompt 设计

很久之前,我们介绍到,prompt是影响下游任务的关键所在,当我们在应用chatgpt进行nlp任务落地时,如何选择合适的prompt,对于SFT以及推理环节尤为重要。

不过,硬想不是办法,我们可以充分参考开源的一些已有工作,幸运的是,这类工作已然存在。

因此,本文主要介绍longbench、LooGLE、pclue以及firefly自然语言处理任务prompt以及PromptSource英文常用评测任务prompt生成工具包。

一、其他一些关于NLP任务的代表prompt

最近我们在看长文本说的一些评估数据集,而对于评估来说,如何针对不同的任务,设定相应的prompt,最为重要。下面介绍longbench、LooGLE、pclue以及firefly自然语言处理任务prompt。

1、longbench长文本prompt

地址:https://github.com/THUDM/LongBench

图片

图片

技术交流群

前沿技术资讯、算法交流、求职内推、算法竞赛、面试交流(校招、社招、实习)等、与 10000+来自港科大、北大、清华、中科院、CMU、腾讯、百度等名校名企开发者互动交流~

建了技术交流群&星球!想要资料、进交流群的同学,可以直接加微信号:mlc2060。加的时候备注一下:研究方向 +学校/公司,即可。然后就可以拉你进群了。

方式①、添加微信号:mlc2060,备注:大模型资料 or 技术交流
方式②、微信搜索公众号:机器学习社区,后台回复:大模型资料 or 技术交流

在这里插入图片描述

在这里插入图片描述

2、LooGLE长文本评测prompt

地址: https://github.com/bigai-nlco/LooGLE

图片

4、Pclue任务评测prompt

地址: https://github.com/CLUEbenchmark/pCLUE

图片

图片

图片

4、firefly自然语言处理任务prompt

地址:https://huggingface.co/datasets/YeungNLP/firefly-train-1.1M/viewer/default/train?row=3

图片

二、PromptSource英文NLP prompt生成工具

PromptSource是一个用于创建、共享和使用自然语言提示的工具包,截至2022年1月20日,P3中有约2000个prompt,涵盖170多个英语数据集。

图片

项目地址:https://github.com/bigscience-workshop/promptsource

1、storycloze的prompt

templates:1a4946f9-a0e2-4fbb-aee8-b26ead2cf6b8: !Templateanswer_choices: '{{sentence_quiz1}} ||| {{sentence_quiz2}}'id: 1a4946f9-a0e2-4fbb-aee8-b26ead2cf6b8jinja: '{{input_sentence_1}} {{input_sentence_2}} {{input_sentence_3}} {{input_sentence_4}}What is a possible continuation for the story given the following options ?- {{answer_choices | join("\n- ")}} ||| {{answer_choices[answer_right_ending-1]}}'metadata: !TemplateMetadatachoices_in_prompt: truelanguages:- enmetrics:- Accuracyoriginal_task: truename: Answer Given optionsreference: ''1a9d53bc-eb77-4e7c-af6e-3d15b79d6cf1: !Templateanswer_choices: '{{sentence_quiz1}} ||| {{sentence_quiz2}}'id: 1a9d53bc-eb77-4e7c-af6e-3d15b79d6cf1jinja: "Read the following story :\n\n{{input_sentence_1}}\n{{input_sentence_2}}\n\{{input_sentence_3}}\n{{input_sentence_4}}\n\nChoose a possible ending for the\\ previous story from the following options: \n- {{answer_choices | join(\"\\\n- \")}}\n|||\n\n{{answer_choices[answer_right_ending -1]}}"metadata: !TemplateMetadatachoices_in_prompt: truelanguages:- enmetrics:- Accuracyoriginal_task: truename: Choose Story Endingreference: ''

2、Squad任务的prompt

templates:3d85b5b0-51db-4d72-8ead-d0b3654025ee: !Templateanswer_choices: nullid: 3d85b5b0-51db-4d72-8ead-d0b3654025eejinja: 'Refer to the passage below and answer the following question:Passage: {{context}}Question: {{question}}|||{{answers["text"][0]}}'metadata: !TemplateMetadatachoices_in_prompt: falselanguages:- enmetrics:- Squadoriginal_task: truename: answer_question_given_contextreference: ''

3、MathQA任务的prompt

a313a5f8-53cd-4b76-abb6-fea2ac4e9ef4: !Templateanswer_choices: a ||| b ||| c ||| d ||| eid: a313a5f8-53cd-4b76-abb6-fea2ac4e9ef4jinja: "One of the five choices are correctly answers the math problem. Can you\\ choose the right one? \n\n{{options}}\n\nProblem: {{Problem}}\n|||\n{{correct}}"metadata: !TemplateMetadatachoices_in_prompt: truelanguages:- enmetrics:- Accuracyoriginal_task: truename: first_choice_then_problemreference: First give the list of choices and then describe the problema3c2ec72-4af5-42aa-9e8e-ef475fa7c039: !Templateanswer_choices: general ||| physics ||| gain ||| geometry ||| probability |||otherid: a3c2ec72-4af5-42aa-9e8e-ef475fa7c039jinja: "Given the problem below, in what category would you classify it?\n===\n\{{Problem}} \n\nCategories:\n{{answer_choices | join(\"\\n\")}}\n|||\n{{category}}\n"metadata: !TemplateMetadatachoices_in_prompt: truelanguages:- enmetrics:- Accuracyoriginal_task: falsename: problem_set_typereference: The template asks to generate the category of the problem set

4、使用方式

# Load an example from the datasets ag_news
>>> from datasets import load_dataset
>>> dataset = load_dataset("ag_news", split="train")
>>> example = dataset[1]# Load prompts for this dataset
>>> from promptsource.templates import DatasetTemplates
>>> ag_news_prompts = DatasetTemplates('ag_news')# Print all the prompts available for this dataset. The keys of the dict are the uuids the uniquely identify each of the prompt, and the values are instances of `Template` which wraps prompts
>>> print(ag_news_prompts.templates)
{'24e44a81-a18a-42dd-a71c-5b31b2d2cb39': <promptsource.templates.Template object at 0x7fa7aeb20350>, '8fdc1056-1029-41a1-9c67-354fc2b8ceaf': <promptsource.templates.Template object at 0x7fa7aeb17c10>, '918267e0-af68-4117-892d-2dbe66a58ce9': <promptsource.templates.Template object at 0x7fa7ac7a2310>, '9345df33-4f23-4944-a33c-eef94e626862': <promptsource.templates.Template object at 0x7fa7ac7a2050>, '98534347-fff7-4c39-a795-4e69a44791f7': <promptsource.templates.Template object at 0x7fa7ac7a1310>, 'b401b0ee-6ffe-4a91-8e15-77ee073cd858': <promptsource.templates.Template object at 0x7fa7ac7a12d0>, 'cb355f33-7e8c-4455-a72b-48d315bd4f60': <promptsource.templates.Template object at 0x7fa7ac7a1110>}# Select a prompt by its name
>>> prompt = ag_news_prompts["classify_question_first"]# Apply the prompt to the example
>>> result = prompt.apply(example)
>>> print("INPUT: ", result[0])
INPUT:  What label best describes this news article?
Carlyle Looks Toward Commercial Aerospace (Reuters) Reuters - Private investment firm Carlyle Group,\which has a reputation for making well-timed and occasionally\controversial plays in the defense industry, has quietly placed\its bets on another part of the market.
>>> print("TARGET: ", result[1])
TARGET:  Business

总结

本文主要介绍了PromptSource英文常用评测任务prompt生成工具包以及现有NLP的一些prompt,这些对我们进行信息抽取等任务有很大的帮助。

对于具体的使用,大家可以参考参考文献链接进行进一步查看,并实践。

参考文献

1、https://github.com/bigscience-workshop/promptsource

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/353382.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

MATLAB安装第三方工具箱

1.1 如果是Matlab安装光盘上的工具箱&#xff0c;重新执行安装程序&#xff0c;选中即可&#xff1b;1.2 如果是单独下载的工具箱&#xff0c;一般情况下仅需要把新的工具箱解压到某个目录。2 在matlab的file下面的set path把它加上&#xff0c;或者用genpath(yourlocation/you…

Debug method

#define DEBUG(format,...) printf("Ray.he file:"__FILE__" func:%s() line:%d, print "format"", __func__, __LINE__, ##__VA_ARGS__)转载于:https://www.cnblogs.com/debruyne/p/9254619.html

soa学习路线_Web服务安全性和SOA路线图的人为维度

soa学习路线在大多数非平凡的SOA环境中&#xff0c;很难跟踪系统之间不断发展的集成&#xff0c;除非有明确的发布和查找适当信息的方法。 概述IT环境&#xff0c;定义当前或将要连接的内容&#xff0c;是维护环境的先决条件。 缺少这种方法通常会导致“面向意大利面条的环境”…

MATLAB函数参数个数控制

if nargin < 1 else if nargin < 2 else if nargin < 4 end

生产Java应用程序中的十大异常类型-基于1B事件

Pareto记录原理&#xff1a;97&#xff05;的记录错误语句是由3&#xff05;的唯一错误引起的 在最新的数据整理帖子之后&#xff0c;我们收到了很多反馈和问题&#xff0c;在该文章中&#xff0c;我们显示97&#xff05;的记录错误是由10个唯一错误引起的 。 根据普遍的需求&…

Matlab矩阵查找

find(x&#xff09;find(Aa)find(A>a)find(A>a,n);A为目标矩阵&#xff0c;a为要查找的数&#xff0c;n为查找的个数&#xff0c;返回位置

剑指Offer 斐波那契数列

时间限制&#xff1a;1秒 空间限制&#xff1a;32768K 热度指数&#xff1a;332130算法知识视频讲解 题目描述 大家都知道斐波那契数列&#xff0c;现在要求输入一个整数n&#xff0c;请你输出斐波那契数列的第n项。 n<39 给出代码&#xff1a; class Solution { public:int…

Matlab将一矩阵中等于某个值的元素全部替换成另一个值

A(Ax)X; %将A中等于x的值全部替换为XA(isnan(A))X;%将A中等于nan的值全部替换为X

教你制作QQ空间超高连通率背景音乐链接。

1.进入【搜搜音乐】http://music.soso.com/index.html 搜索你想要的歌曲名字。。。如下图&#xff1a; 2、 3.此链接地址并不能做背景链接&#xff0c;因为腾讯加密了&#xff0c;你只需将链接地址里的qq改成%71%71就可以作为背景音乐链接了。如图&#xff1a;

linux中查找文件属于那个软件包的方法

一、linux中查找文件属于那个软件包的方法 [rootsalt prod]# whereis htpasswdhtpasswd: /usr/bin/htpasswd /usr/share/man/man1/htpasswd.1.gz [rootsalt prod]# rpm -qf /usr/bin/htpasswdhttpd-tools-2.4.6-80.el7.centos.x86_64转载于:https://www.cnblogs.com/nulige/p/9…

java io顺序_Java顺序IO性能

java io顺序许多应用程序将一系列事件记录到基于文件的存储中&#xff0c;以供以后使用。 从日志记录和审核&#xff0c;直到在事件源设计或其紧密相关的CQRS中保留事务重做日志&#xff0c;这都可以是任何东西。 Java具有多种方法&#xff0c;可以通过这些方法将文件顺序写入或…

Matlab矩阵的拼接

oneyeardata.fert [(0:14),zeros(15,3);oneyeardata.fert;(50:90),zeros(41,3)];%把0补齐

sqlmap常用操作命令

一、sqlmap常用基础命令 sqlmap Common operation command 以下命令顺序即为sql注入常见步骤。 sqlmap -u [“url”] --dbs #获取数据库 sqlmap -u [“url”] --current-user #获取当前用户名称 &#xff1a; sqlmap -u [“url”] --current-db #获取当前数据库名称 sqlmap -u …

hdu 2066

一个人的旅行 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 12820 Accepted Submission(s): 4343 Problem Description虽然草儿是个路痴&#xff08;就是在杭电待了一年多&#xff0c;居然还会在校园里迷路…

Java EE 8,当前状态是什么:自2015年底以来已完成工作的案例研究

对于那些密切关注Java EE的人来说&#xff0c;在过去的六个月中已经很清楚&#xff0c;活动有所减少&#xff0c;尤其是在Oracle保持领先的JSR中。 这是怎么回事&#xff1f; 最近&#xff0c;在这方面&#xff0c;Java EE社区进行了很多讨论&#xff0c;我认为给开发人员社区一…

Matlab矩阵替换所有等于某个值的数

若非NaN&#xff1a;a[2,5;1,4;1,4;3,6;3,6;2,5];a(a1)0;%所有1替换为0%上述方法可以把数替换为NaN但不能把NaN替换为数 若为NaNa(isnan(a))0;%将NaN替换为0

将Sublime Text3添加到右键菜单中

方法一&#xff08;推荐&#xff09; 把以下代码&#xff0c;复制到SublimeText3的安装目录&#xff0c;然后重命名为&#xff1a;sublime_addright.inf&#xff0c;然后右击安装就可以了。 PS&#xff1a;重命名文件之前&#xff0c;需要先在工具--文件夹选项&#xff0c;查看…

Matlab判断矩阵是否为对称矩阵

if AA%是对称矩阵if A~A%不是对称矩阵

Lombok,一种编译时Java注释预处理器,可最大程度地减少代码大小

在本文中&#xff0c;我们将看到如何在常规Java代码中使用lombok来最小化代码长度和冗余。 什么是Lombok&#xff1f; Lombok&#xff0c;一个编译时注释预处理器&#xff0c;有助于在编译时注入一些代码。 在详细介绍之前&#xff0c;我要求您应该从他们的网站上观看视频。 …

如何面对人生逆境

在违缘中坚定自我 什么是违缘&#xff1f;违缘就是我们生活、修行等方面所遇到不如意有障碍的事。违缘也可以说是一种逆境、一种挫折。    我们生存在这个世界&#xff0c;在人生的道路上不可能永远都是一帆风顺的。当我们遇到违缘时&#xff0c;应该以怎样的心态去面对&am…