论文笔记--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
源代码

相关推荐
ai_lian_shuo3 小时前
Hugging Face的Transformers核心模块:Pipelines(参数说明,各种模型类型调用案例)
人工智能·pipeline·transformers·hugging face
晨航15 小时前
天津大学:《深度解读DeepSeek:部署、使用、安全》
人工智能·安全·ai·prompt·aigc
Ayakanoinu19 小时前
【论文阅读】VAD: Vectorized Scene Representation for Efficient Autonomous Driving
论文阅读
morris1311 天前
【redis】事务
数据库·redis·缓存·pipeline·lua·事务
大囚长1 天前
prompt大师高效提示词解析
人工智能·prompt
大囚长1 天前
prompt样例库推荐
人工智能·prompt
MhZhou04121 天前
Virtual Sparse Convolution for Multimodal 3D Object Detection 论文阅读
论文阅读
0x2111 天前
[论文阅读]Certifiably Robust RAG against Retrieval Corruption
论文阅读
何大春2 天前
【对话推荐系统综述】Broadening the View: Demonstration-augmented Prompt Learning for CR
论文阅读·人工智能·深度学习·语言模型·prompt·论文笔记
风雨中的小七2 天前
解密prompt系列50. RL用于优化Agent行为路径的一些思路
prompt