Keybart
KeyBART是基于BART架构预训练的文本生成模型,专门用于生成符合CatSeqD格式的串联关键短语序列。
下载量 737
发布时间 : 3/2/2022
模型简介
KeyBART模型通过学习文本中关键短语的丰富表示,能够生成与输入文本相关的关键短语序列。该模型在判别式和生成式设置下进行预训练,显著提升了关键短语提取和生成的性能。
模型特点
关键短语生成
能够生成符合CatSeqD格式的串联关键短语序列,显著提升关键短语提取和生成的性能。
零样本能力
在零样本设置下,模型能够生成与输入文本相关的关键短语,无需额外训练。
多任务支持
除了关键短语生成,模型还支持抽象摘要生成等任务,性能与SOTA相当。
模型能力
文本生成
关键短语提取
抽象摘要生成
使用案例
学术研究
论文关键短语生成
从学术论文中自动提取关键短语,帮助研究人员快速了解论文内容。
F1@M最高提升4.33分
新闻摘要
新闻关键短语生成
从新闻文章中提取关键短语,用于快速生成新闻摘要。
与SOTA性能相当
🚀 KeyBART
KeyBART 是在《Learning Rich Representations of Keyphrase from Text》(发表于 2022 年北美计算语言学协会会议(NAACL)成果集,论文链接:https://aclanthology.org/2022.findings-naacl.67.pdf)中提出的模型。它基于 BART 架构进行预训练,以 CatSeqD 格式生成关键词组的拼接序列。
我们提供了一些下游评估设置的示例,以及如何在零样本设置下将其用于文本到文本生成任务。
🚀 快速开始
你可以参考以下不同任务的代码示例来快速使用 KeyBART。
✨ 主要特性
- 基于 BART 架构预训练,能够生成关键词组的拼接序列。
- 在关键词生成、抽象摘要等下游任务中表现良好。
- 支持零样本设置下的文本到文本生成。
📦 安装指南
文档未提及具体安装步骤,可通过以下代码加载相关模型和数据集:
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
from datasets import load_dataset
# 加载 KeyBART 模型和分词器
tokenizer = AutoTokenizer.from_pretrained("bloomberg/KeyBART")
model = AutoModelForSeq2SeqLM.from_pretrained("bloomberg/KeyBART")
# 加载数据集示例
dataset = load_dataset("midas/kp20k")
💻 使用示例
基础用法
关键词生成
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
from datasets import load_dataset
# 加载 KeyBART 模型和分词器
tokenizer = AutoTokenizer.from_pretrained("bloomberg/KeyBART")
model = AutoModelForSeq2SeqLM.from_pretrained("bloomberg/KeyBART")
# 加载数据集
dataset = load_dataset("midas/kp20k")
抽象摘要
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
from datasets import load_dataset
# 加载 KeyBART 模型和分词器
tokenizer = AutoTokenizer.from_pretrained("bloomberg/KeyBART")
model = AutoModelForSeq2SeqLM.from_pretrained("bloomberg/KeyBART")
# 加载数据集
dataset = load_dataset("cnn_dailymail")
零样本设置
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
# 加载 KeyBART 模型和分词器
tokenizer = AutoTokenizer.from_pretrained("bloomberg/KeyBART")
model = AutoModelForSeq2SeqLM.from_pretrained("bloomberg/KeyBART")
或者使用 https://huggingface.co/bloomberg/KeyBART 提供的托管推理 API 控制台。
高级用法
零样本设置示例
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
# 加载 KeyBART 模型和分词器
tokenizer = AutoTokenizer.from_pretrained("bloomberg/KeyBART")
model = AutoModelForSeq2SeqLM.from_pretrained("bloomberg/KeyBART")
# 输入文本
input_text = "In this work, we explore how to learn task specific language models aimed towards learning rich representation of keyphrases from text documents. \
We experiment with different masking strategies for pre-training transformer language models (LMs) in discriminative as well as generative settings. \
In the discriminative setting, we introduce a new pre-training objective - Keyphrase Boundary Infilling with Replacement (KBIR), \
showing large gains in performance (upto 9.26 points in F1) over SOTA, when LM pre-trained using KBIR is fine-tuned for the task of keyphrase extraction. \
In the generative setting, we introduce a new pre-training setup for BART - KeyBART, that reproduces the keyphrases related to the input text in the CatSeq \
format, instead of the denoised original input. This also led to gains in performance (upto 4.33 points in F1@M) over SOTA for keyphrase generation. \
Additionally, we also fine-tune the pre-trained language models on named entity recognition (NER), question answering (QA), relation extraction (RE), \
abstractive summarization and achieve comparable performance with that of the SOTA, showing that learning rich representation of keyphrases is indeed beneficial \
for many other fundamental NLP tasks."
# 输出结果示例
print("Output: language model;keyphrase generation;new pre-training objective;pre-training setup;")
📚 详细文档
下游评估
关键词生成
以下是不同模型在关键词生成任务上的报告结果:
现有关键词生成
模型 | Inspec (F1@5) | Inspec (F1@M) | NUS (F1@5) | NUS (F1@M) | Krapivin (F1@5) | Krapivin (F1@M) | SemEval (F1@5) | SemEval (F1@M) | KP20k (F1@5) | KP20k (F1@M) |
---|---|---|---|---|---|---|---|---|---|---|
catSeq | 22.5 | 26.2 | 32.3 | 39.7 | 26.9 | 35.4 | 24.2 | 28.3 | 29.1 | 36.7 |
catSeqTG | 22.9 | 27 | 32.5 | 39.3 | 28.2 | 36.6 | 24.6 | 29.0 | 29.2 | 36.6 |
catSeqTG - 2RF1 | 25.3 | 30.1 | 37.5 | 43.3 | 30 | 36.9 | 28.7 | 32.9 | 32.1 | 38.6 |
GANMR | 25.8 | 29.9 | 34.8 | 41.7 | 28.8 | 36.9 | N/A | N/A | 30.3 | 37.8 |
ExHiRD - h | 25.3 | 29.1 | N/A | N/A | 28.6 | 34.7 | 28.4 | 33.5 | 31.1 | 37.4 |
Transformer (Ye et al., 2021) | 28.15 | 32.56 | 37.07 | 41.91 | 31.58 | 36.55 | 28.71 | 32.52 | 33.21 | 37.71 |
BART* | 23.59 | 28.46 | 35.00 | 42.65 | 26.91 | 35.37 | 26.72 | 31.91 | 29.25 | 37.51 |
KeyBART - DOC* | 24.42 | 29.57 | 31.37 | 39.24 | 24.21 | 32.60 | 24.69 | 30.50 | 28.82 | 37.59 |
KeyBART* | 24.49 | 29.69 | 34.77 | 43.57 | 29.24 | 38.62 | 27.47 | 33.54 | 30.71 | 39.76 |
KeyBART* (零样本) | 30.72 | 36.89 | 18.86 | 21.67 | 18.35 | 20.46 | 20.25 | 25.82 | 12.57 | 15.41 |
缺失关键词生成
模型 | Inspec (F1@5) | Inspec (F1@M) | NUS (F1@5) | NUS (F1@M) | Krapivin (F1@5) | Krapivin (F1@M) | SemEval (F1@5) | SemEval (F1@M) | KP20k (F1@5) | KP20k (F1@M) |
---|---|---|---|---|---|---|---|---|---|---|
catSeq | 0.4 | 0.8 | 1.6 | 2.8 | 1.8 | 3.6 | 1.6 | 2.8 | 1.5 | 3.2 |
catSeqTG | 0.5 | 1.1 | 1.1 | 1.8 | 1.8 | 3.4 | 1.1 | 1.8 | 1.5 | 3.2 |
catSeqTG - 2RF1 | 1.2 | 2.1 | 1.9 | 3.1 | 3.0 | 5.3 | 2.1 | 3.0 | 2.7 | 5.0 |
GANMR | 1.3 | 1.9 | 2.6 | 3.8 | 4.2 | 5.7 | N/A | N/A | 3.2 | 4.5 |
ExHiRD - h | 1.1 | 2.2 | N/A | N/A | 2.2 | 4.3 | 1.7 | 2.5 | 1.6 | 3.2 |
Transformer (Ye et al., 2021) | 1.02 | 1.94 | 2.82 | 4.82 | 3.21 | 6.04 | 2.05 | 2.33 | 2.31 | 4.61 |
BART* | 1.08 | 1.96 | 1.80 | 2.75 | 2.59 | 4.91 | 1.34 | 1.75 | 1.77 | 3.56 |
KeyBART - DOC* | 0.99 | 2.03 | 1.39 | 2.74 | 2.40 | 4.58 | 1.07 | 1.39 | 1.69 | 3.38 |
KeyBART* | 0.95 | 1.81 | 1.23 | 1.90 | 3.09 | 6.08 | 1.96 | 2.65 | 2.03 | 4.26 |
KeyBART* (零样本) | 1.83 | 2.92 | 1.46 | 2.19 | 1.29 | 2.09 | 1.12 | 1.45 | 0.70 | 1.14 |
抽象摘要
以下是不同模型在抽象摘要任务上的报告结果:
模型 | R1 | R2 | RL |
---|---|---|---|
BART (Lewis et al., 2019) | 44.16 | 21.28 | 40.9 |
BART* | 42.93 | 20.12 | 39.72 |
KeyBART - DOC* | 42.92 | 20.07 | 39.69 |
KeyBART* | 43.10 | 20.26 | 39.90 |
零样本设置
可通过以下代码进行零样本设置:
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("bloomberg/KeyBART")
model = AutoModelForSeq2SeqLM.from_pretrained("bloomberg/KeyBART")
或者使用 https://huggingface.co/bloomberg/KeyBART 提供的托管推理 API 控制台。
📄 许可证
本项目采用 Apache-2.0 许可证。
🔗 引用
请使用以下 BibTeX 条目引用此工作:
@inproceedings{kulkarni-etal-2022-learning,
title = "Learning Rich Representation of Keyphrases from Text",
author = "Kulkarni, Mayank and
Mahata, Debanjan and
Arora, Ravneet and
Bhowmik, Rajarshi",
booktitle = "Findings of the Association for Computational Linguistics: NAACL 2022",
month = jul,
year = "2022",
address = "Seattle, United States",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2022.findings-naacl.67",
doi = "10.18653/v1/2022.findings-naacl.67",
pages = "891--906",
abstract = "In this work, we explore how to train task-specific language models aimed towards learning rich representation of keyphrases from text documents. We experiment with different masking strategies for pre-training transformer language models (LMs) in discriminative as well as generative settings. In the discriminative setting, we introduce a new pre-training objective - Keyphrase Boundary Infilling with Replacement (KBIR), showing large gains in performance (upto 8.16 points in F1) over SOTA, when the LM pre-trained using KBIR is fine-tuned for the task of keyphrase extraction. In the generative setting, we introduce a new pre-training setup for BART - KeyBART, that reproduces the keyphrases related to the input text in the CatSeq format, instead of the denoised original input. This also led to gains in performance (upto 4.33 points in F1@M) over SOTA for keyphrase generation. Additionally, we also fine-tune the pre-trained language models on named entity recognition (NER), question answering (QA), relation extraction (RE), abstractive summarization and achieve comparable performance with that of the SOTA, showing that learning rich representation of keyphrases is indeed beneficial for many other fundamental NLP tasks.",
}
如有任何问题,请联系 dmahata@bloomberg.net。
Phi 2 GGUF
其他
Phi-2是微软开发的一个小型但强大的语言模型,具有27亿参数,专注于高效推理和高质量文本生成。
大型语言模型 支持多种语言
P
TheBloke
41.5M
205
Roberta Large
MIT
基于掩码语言建模目标预训练的大型英语语言模型,采用改进的BERT训练方法
大型语言模型 英语
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERT是BERT基础模型的蒸馏版本,在保持相近性能的同时更轻量高效,适用于序列分类、标记分类等自然语言处理任务。
大型语言模型 英语
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instruct 是一个多语言大语言模型,针对多语言对话用例进行了优化,在常见的行业基准测试中表现优异。
大型语言模型 英语
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM-RoBERTa是基于100种语言的2.5TB过滤CommonCrawl数据预训练的多语言模型,采用掩码语言建模目标进行训练。
大型语言模型 支持多种语言
X
FacebookAI
9.6M
664
Roberta Base
MIT
基于Transformer架构的英语预训练模型,通过掩码语言建模目标在海量文本上训练,支持文本特征提取和下游任务微调
大型语言模型 英语
R
FacebookAI
9.3M
488
Opt 125m
其他
OPT是由Meta AI发布的开放预训练Transformer语言模型套件,参数量从1.25亿到1750亿,旨在对标GPT-3系列性能,同时促进大规模语言模型的开放研究。
大型语言模型 英语
O
facebook
6.3M
198
1
基于transformers库的预训练模型,适用于多种NLP任务
大型语言模型
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1是Meta推出的多语言大语言模型系列,包含8B、70B和405B参数规模,支持8种语言和代码生成,优化了多语言对话场景。
大型语言模型
Transformers 支持多种语言

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5基础版是由Google开发的文本到文本转换Transformer模型,参数规模2.2亿,支持多语言NLP任务。
大型语言模型 支持多种语言
T
google-t5
5.4M
702
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98