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

相关推荐
GISer_Jing20 分钟前
智能体工具使用、规划模式
人工智能·设计模式·prompt·aigc
切糕师学AI4 小时前
AI 领域中的 Prompt(提示词/提示)是什么?
人工智能·prompt
小明_GLC21 小时前
Falcon-TST: A Large-Scale Time Series Foundation Model
论文阅读·人工智能·深度学习·transformer
效率客栈老秦21 小时前
Python Trae提示词开发实战(12):AI实现API自动化批量调用与数据处理让效率提升10倍
人工智能·python·ai·prompt·trae
猫头虎21 小时前
2025年AI领域年度深度总结:始于DeepSeek R1开源发布,终于Manus天价出海
人工智能·langchain·开源·prompt·aigc·ai编程·编程技术
新元代码1 天前
论文写作 Prompt 模板库
prompt
谁怕平生太急1 天前
MAI-UI的prompt
ui·prompt·gui agent·mai-ui
无妄无望1 天前
The Prompt Report: A Systematic Survey of Prompt Engineering Techniques(文本部分 )
人工智能·自然语言处理·prompt
0x2111 天前
[论文阅读]Through the Stealth Lens: Rethinking Attacks and Defenses in RAG
论文阅读
努力犯错1 天前
LTX-2 进阶 Prompt 技巧:从入门到专业视频创作
人工智能·数码相机·机器学习·计算机视觉·开源·prompt·音视频