论文笔记--OpenPrompt: An Open-source Framework for Prompt-learning

论文笔记--OpenPrompt: An Open-source Framework for Prompt-learning

  • [1. 文章简介](#1. 文章简介)
  • [2. 文章概括](#2. 文章概括)
  • [3 文章重点技术](#3 文章重点技术)
  • [4. 文章亮点](#4. 文章亮点)
  • [5. 原文传送门](#5. 原文传送门)

1. 文章简介

  • 标题:OpenPrompt: An Open-source Framework for Prompt-learning
  • 作者:Ning Ding, Shengding Hu, Weilin Zhao, Yulin Chen, Zhiyuan Liu, Hai-Tao Zheng, Maosong Sun
  • 日期:2022
  • 期刊:ACL

2. 文章概括

文章介绍了一种开源的工具OpenPrompt,该工具将prompt-learning的一些操作进行封装处理,设计成为一种用户友好的开源三方库,使用起来非常方便。

OpenPrompt使用的基本方法为

3 文章重点技术

  • PLMs:文章支持Huggingface transformers上的PLMs(预训练模型),开发者可通过下述操作直接加载PLMs:
python 复制代码
from openprompt.plms import load_plm
plm, tokenizer, model_config, WrapperClass = load_plm("bert", path_to_bert)
  • 预训练模型PLMs:文章支持Huggingface transformers上的PLMs(预训练模型),开发者可通过下述操作直接加载PLMs:
python 复制代码
from openprompt.plms import load_plm
plm, tokenizer, model_config, WrapperClass = load_plm("bert", path_to_bert)
  • 分词Tokenization:文章特别设计了针对prompt learning的分词模块,可以自动选择合适的分词器,从而简化用户操作。分词器通过上述代码直接加载
  • 模板Templates:Templates将原始文本和软编码或是硬编码(文本)template结合,一般来说会包含上下文相关的token和掩码token。OpenPrompt接受用Python中的字典语法编写的template:
python 复制代码
from openprompt.prompts import ManualTemplate
promptTemplate = ManualTemplate(
    text = '{"placeholder":"text_a"} It was {"mask"}',
    tokenizer = tokenizer,
)

文章给出了一些常用的templates的示例,见下表

  • 言语化Verbalizer:Verbalizer将原始的标签映射到词表中的label words,文章接受手动设计Verbalizer或直接调用AutomaticVerbalizer/SoftVerbalizer/...等API自带的verbalizer方法。下面为一个手动设计verbalizer的示例:
python 复制代码
from openprompt.prompts import ManualVerbalizer
promptVerbalizer = ManualVerbalizer(
    classes = classes,
    label_words = {
        "negative": ["bad"],
        "positive": ["good", "wonderful", "great"],
    },
    tokenizer = tokenizer,
)
  • PromptModel:OpenPrompt使用PromptModel 模块来用于训练和推理,用户只需把上述template\ Verbalizer\ PLMs结合在一起即可以完成此步骤:
python 复制代码
from openprompt import PromptForClassification
promptModel = PromptForClassification(
    template = promptTemplate,
    plm = plm,
    verbalizer = promptVerbalizer,

4. 文章亮点

文章给出了开源工具OpenPrompt,将Prompt learning中涉及到的一些基本操作进行封装,形成了一个方便的pipeline。用户只需安装openprompt三方库并下载一个PLM,就可以进行简单的prompt learning了~

5. 原文传送门

OpenPrompt: An Open-source Framework for Prompt-learning
源代码

相关推荐
nenchoumi31197 小时前
VLA 论文精读(十六)FP3: A 3D Foundation Policy for Robotic Manipulation
论文阅读·人工智能·笔记·学习·vln
何大春10 小时前
【视频时刻检索】Text-Video Retrieval via Multi-Modal Hypergraph Networks 论文阅读
论文阅读·深度学习·神经网络·计算机视觉·视觉检测·论文笔记
王上上14 小时前
【论文阅读25】-滑坡时间预测-PFTF
论文阅读
李一帆'14 小时前
【论文阅读】Hierarchical Group-Level Emotion Recognition
论文阅读·计算机视觉
何双新15 小时前
L3-3、从单轮到链式任务:设计协作型 Prompt 系统
服务器·搜索引擎·prompt
nenchoumi31191 天前
VLA 论文精读(十八)π0.5: a Vision-Language-Action Model with Open-World Generalization
论文阅读·人工智能·深度学习·语言模型·vla
RockLiu@8051 天前
大模型技术全景解析:从基础架构到Prompt工程
语言模型·prompt
江左子固2 天前
《Deep Learning Inference on Embedded Devices: Fixed-Point vs Posit》(一)
论文阅读
uncle_ll2 天前
李宏毅NLP-6-seq2seq&HMM
人工智能·自然语言处理·nlp·李宏毅·hmm