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

news2024/9/23 9:30:36

很久之前,我们介绍到,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: !Template
    answer_choices: '{{sentence_quiz1}} ||| {{sentence_quiz2}}'
    id: 1a4946f9-a0e2-4fbb-aee8-b26ead2cf6b8
    jinja: '{{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: !TemplateMetadata
      choices_in_prompt: true
      languages:
      - en
      metrics:
      - Accuracy
      original_task: true
    name: Answer Given options
    reference: ''
  1a9d53bc-eb77-4e7c-af6e-3d15b79d6cf1: !Template
    answer_choices: '{{sentence_quiz1}} ||| {{sentence_quiz2}}'
    id: 1a9d53bc-eb77-4e7c-af6e-3d15b79d6cf1
    jinja: "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: !TemplateMetadata
      choices_in_prompt: true
      languages:
      - en
      metrics:
      - Accuracy
      original_task: true
    name: Choose Story Ending
    reference: ''

2、Squad任务的prompt

templates:
  3d85b5b0-51db-4d72-8ead-d0b3654025ee: !Template
    answer_choices: null
    id: 3d85b5b0-51db-4d72-8ead-d0b3654025ee
    jinja: 'Refer to the passage below and answer the following question:
      Passage: {{context}}
      Question: {{question}}
      |||
      {{answers["text"][0]}}'
    metadata: !TemplateMetadata
      choices_in_prompt: false
      languages:
      - en
      metrics:
      - Squad
      original_task: true
    name: answer_question_given_context
    reference: ''

3、MathQA任务的prompt

a313a5f8-53cd-4b76-abb6-fea2ac4e9ef4: !Template
    answer_choices: a ||| b ||| c ||| d ||| e
    id: a313a5f8-53cd-4b76-abb6-fea2ac4e9ef4
    jinja: "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: !TemplateMetadata
      choices_in_prompt: true
      languages:
      - en
      metrics:
      - Accuracy
      original_task: true
    name: first_choice_then_problem
    reference: First give the list of choices and then describe the problem
  a3c2ec72-4af5-42aa-9e8e-ef475fa7c039: !Template
    answer_choices: general ||| physics ||| gain ||| geometry ||| probability |||
      other
    id: a3c2ec72-4af5-42aa-9e8e-ef475fa7c039
    jinja: "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: !TemplateMetadata
      choices_in_prompt: true
      languages:
      - en
      metrics:
      - Accuracy
      original_task: false
    name: problem_set_type
    reference: 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.coloradmin.cn/o/1325021.html

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

相关文章

小程序面试题 | 07.精选小程序面试题

&#x1f90d; 前端开发工程师&#xff08;主业&#xff09;、技术博主&#xff08;副业&#xff09;、已过CET6 &#x1f368; 阿珊和她的猫_CSDN个人主页 &#x1f560; 牛客高级专题作者、在牛客打造高质量专栏《前端面试必备》 &#x1f35a; 蓝桥云课签约作者、已在蓝桥云…

语音识别与人机交互:发展历程、挑战与未来前景

导言 语音识别技术作为人机交互领域的重要组成部分&#xff0c;近年来取得了巨大的发展。本文将深入研究语音识别与人机交互的发展历程、遇到的问题、解决过程、未来的可用范围&#xff0c;以及在各国的应用和未来的研究趋势。我们将探讨在这个领域&#xff0c;哪一方能取得竞争…

47 星南二楼

动态规划&#xff0c;相当于求解最长子序列问题 #include <iostream> using namespace::std; using std::cout; using std::cin; int n; int a[5100],dp[5100];int xnel(int n, int a[]) {int result 0;for(int i0; i<n; i){for(int j0; j<i; j){if(a[j]<a[…

每日一博 - Protobuf vs. Protostuff:性能、易用性和适用场景分析

文章目录 历史区别联系性能差异最佳实践场景分析小结 历史 对于Protostuff和Protobuf的关系&#xff0c;需要了解它们的起源和发展。 Protobuf&#xff08;Protocol Buffers&#xff09;是由Google开发的一种数据序列化格式&#xff0c;用于结构化数据的存储和交换。它最初是…

损失函数中正则化中的平方项的作用!!

正则化上的平方项 前言在损失函数中添加正则化项时&#xff0c;通常会使用平方项作为正则化项&#xff0c;原因主要有以下几点&#xff1a; 前言 在损失函数中添加正则化项的原因主要是为了防止过拟合。正则化是一种常用的防止过拟合的技术&#xff0c;它可以对模型的复杂度进…

java反射的实战教程(简单且高效)

1. 参考 建议按顺序阅读以下文章 学了这么久的java反射机制&#xff0c;你知道class.forName和classloader的区别吗&#xff1f; Java反射&#xff08;超详细&#xff01;&#xff09; 2. 实战 2.1 通过Class.forName()方法获取字节码 这个方法会去我们的操作系统寻找这个cl…

linux、widnows的免费局域网桌面远程工具之NoMachine

统信UOS、银河麒麟及其他的linux桌面系统/windows系统都可进行远程桌面操作使用。 1.先到官网下载https://downloads.nomachine.com/自己使用的软件版本。 2.首先下载windwos端的的版本64位进行安装&#xff0c;安装是先暂时退出windows的杀毒软件&#xff0c;以免提示你各种确…

RabbitMQ入门指南(三):Java入门示例

专栏导航 RabbitMQ入门指南 从零开始了解大数据 目录 专栏导航 前言 一、AMQP协议 1.AMQP 2.Spring AMQP 二、使用Spring AMQP实现对RabbitMQ的消息收发 1.案例准备阶段 2.入门案例&#xff08;无交换机&#xff09; 3.任务模型案例&#xff08;Work Queues&#xff0…

论文笔记:Accurate Localization using LTE Signaling Data

1 intro 论文提出LTELoc&#xff0c;仅使用信令数据实现精准定位 信令数据已经包含在已在LTE系统中&#xff0c;因此这种方法几乎不需要数据获取成本仅使用TA&#xff08;时序提前&#xff09;和RSRP【这里单位是瓦】&#xff08;参考信号接收功率&#xff09; TA值对应于信号…

5.6 Linux rsync 服务

1、rsync 概念介绍 官方网站&#xff1a;rsync rsync(Remote Sync) 是一个Unix/linux系统下的文件同步和传输工具。Rsync通过“rsync算法”提供了一个客户机和远程服务器的文件同步的快速方法。 采用C/S模式 端口tcp:873 a. rsync 特性 ① 可以镜像保存整个目录树和文件系…

月薪30k的软件测试工程师,是一个什么样的工作状态?

一位大佬的亲身经历 用了大概6年的时间&#xff0c;成为了年薪30w的测试开发。 回顾我从功能测试到测试开发的成长路径&#xff0c;基本上是伴随着“3次能力飞跃”实现的。 年名企大厂测试岗位内推文末获取&#xff01;2022年名企大厂测试岗位内推文末获取&#xff01; 第一…

OpenCV消除高亮illuminationChange函数的使用

学更好的别人&#xff0c; 做更好的自己。 ——《微卡智享》 本文长度为1129字&#xff0c;预计阅读4分钟 导语 上一篇《OpenCV极坐标变换函数warpPolar的使用》中介绍了极坐标变换的使用&#xff0c;文中提到过因为手机拍的照片&#xff0c;部分地方反光厉害。OpenCV本身也有一…

使用yarn安装electron时手动选择版本

访问1Password或者其他可以提供随机字符的网站&#xff0c;获取随机密码运行安装命令 操作要点&#xff0c;必须触发Couldnt find any versions for "electron" that matches "*"才算成功 将复制的随机密码粘贴到后面 例如&#xff1a;yarn add --dev elec…

CAS-源码分析引出Unsafe类、Unsafe类详解

CASDemo演示 public class CASDemo {public static void main(String[] args) {AtomicInteger atomicInteger new AtomicInteger(5);System.out.println(atomicInteger.compareAndSet(5, 2022) "\t" atomicInteger.get());//true 2022System.out.println(atomicI…

vit-transfomers 逐段精读

Vision Transformer Explained | Papers With Code 有趣的特性 在cnn中处理的不太好&#xff0c;但是在transformers 都能处理的很好的例子。 Intriguing Properties of Vision Transformers | Papers With Code 标题 AN IMAGE IS WORTH 16X16 WORDS: TRANSFORMERS FOR IMAGE…

基于ETM+遥感数据的城市热岛效应现状研究的解决方案

1.引言 城市热岛效应&#xff08;Urban Heat Island Effect&#xff09;是指城市中的气温明显高于外围郊区的现象。在近地面温度图上&#xff0c;郊区气温变化很小&#xff0c;而城区则是一个高温区&#xff0c;就像突出海面的岛屿&#xff0c;由于这种岛屿代表高温的城市区域&…

【已解决】vs2015操作创建声明定义由于以下原因无法完成

本博文解决这样的一个问题&#xff0c;就是vs2015下用qt&#xff0c;在快速创建槽函数时给笔者报了个错误&#xff0c;错误的完整说法是这样子的”操作创建声明/定义“由于下列原因无法完成&#xff0c;所选的文本不包含任何函数签名。第一次遇到这种花里胡哨的问题&#xff0c…

[CVPR-23] PointAvatar: Deformable Point-based Head Avatars from Videos

[paper | code | proj] 本文的形变方法被成为&#xff1a;Forward DeformationPointAvatar基于点云表征动态场景。目标是根据给定的一段单目相机视频&#xff0c;重建目标的数字人&#xff0c;并且数字人可驱动&#xff1b;通过标定空间&#xff08;canonical space&#xff09…

Jmeter实现CSV数据批量导入

CSV&#xff1a;逗号分隔值&#xff0c;是一种简洁且常见的数据存储格式。 1、参数化&#xff1a; 在Jmeter中&#xff0c;可以通过“用户自定义的变量”来实现参数化使操作方便&#xff0c;使用语法位&#xff1a;${参数名}&#xff0c;如下图&#xff1a; 而CSV也同理&…

第二百一十八回 如何修改CircleAvatar的大小

文章目录 1. 概念介绍2. 使用方法3. 代码与效果3.1 示例代码3.2 运行效果 4. 内容总结 我们在上一章回中介绍了"修改页面导航中遇到的问题"沉浸式状态样相关的内容&#xff0c;本章回中将介绍如何修改avada的大小.闲话休提&#xff0c;让我们一起Talk Flutter吧。 1.…