FastSum 的 GitHub 地址先为大家奉上:https://github.com/fastnlp/fastSum
FastSum 是基于 fastNLP 开发的一套完整的文本摘要任务解决方案,包括数据加载、模型调用、模型评价三个部分。
模型
FastSum 实现的模型包括:
1.baseline 的 LSTM/Transformer 的序列标注模型
使用 FastNLP 实现的以 Transformer、LSTM(二者可选其一)作为编码器,序列标注作为解码器进行抽取式摘要的代码,可作为抽取式摘要研究的基线。
2.Pointer-generator network(指针生成器网络)
论文:Get To The Point Summarization with Pointer-Generator Networks
3.文本匹配式摘要抽取
论文:Extractive Summarization as Text Matching
4.使用预训练编码器进行文本摘要
论文:Text Summarization with Pretrained Encoders
输入数据、训练参数设置、如何运行、测试等可以查看各个模型的readme 文档,都有各自的介绍。
FastSum 提供了 12 个文本摘要任务数据集,对不同的数据集,提供了不同的数据加载代码方便从服务器来自动下载数据。我们可以通过运行summarizationLoader.py 来下载和使用这些数据集。这 12 个数据集如下表所示:
名称 | 论文 | 类型 | 描述 |
---|---|---|---|
CNN/DailyMail | Abstractive Text Summarization using Sequence-to-sequence RNNs and Beyond | 新闻 | 修改了原本用于 passage-based question answering 任务的数据库。CNN 和 DailyMail 的网站为每篇文章都人工提供了一些要点信息总结文章。而且这些要点是抽象的而非抽取式摘要形式。微调 Teaching Machines to Read and Comprehend 的脚本之后,作者生成了一个 multi-sentence summary 的数据集合 |
Xsum | Don’t Give Me the Details, Just the Summary! Topic-Aware Convolutional Neural Networks for Extreme Summarization | 新闻 | article-single sentence summary 的数据集。在 BBC 上,每篇文章开头都附有人工撰写的摘要,提取即可 |
The New York Times Annotated Corpus | The New York Times Annotated Corpus | 新闻 | 人工撰写的摘要 |
DUC | The Effects of Human Variation in DUC Summarization Evaluation | 新闻 | 2003 和 2004 Task1 都是对每个 doc 生成一段摘要 |
arXiv PubMed | A Discourse-Aware Attention Model for Abstractive Summarization of Long Documents | 科学著作 | 从 arXiv 和 PubMed 获取的长篇文档的摘要,论文的 abstract 部分作为摘要的 ground-truth。 |
WikiHow | WikiHow: A Large Scale Text Summarization Dataset | 知识库 | [WikiHow 有一个关于“怎么做”的数据库,每个步骤描述是由一段加粗摘要以及详细步骤叙述组成。作者把每个步骤的加粗摘要合并作为最终摘要,每步的剩余部分进行合并组成 article。 |
Multi News | Multi-News: a Large-Scale Multi-Document Summarization Dataset and Abstractive Hierarchical Model | 新闻、多文本摘要 | 数据集由新闻文章和这些文章的人工摘要组成,这些文章来自 newser.com 网站。每一篇摘要都是由专业编辑撰写的,并包含到引用的原始文章的链接。 |
BillSum | BillSum: A Corpus for Automatic Summarization of US Legislation | 法案文本 | 数据是选自美国国会和加利福尼亚州立法机构的法案文本,人为编写的摘要。 |
AMI | The AMI meeting corpus: a pre-announcement | 会议 | AMI会议语料库是一种多模式数据集,包含100小时的会议多模式记录。本语料库为每个单独的讲话者提供了高质量的人工记录,还包含了抽取式摘要、生成式摘要、头部动作、手势、情绪状态等。 |
ICSI | ICSI Corpus | 会议 | ICSI会议语料库是一个音频数据集,包含大约70个小时的会议记录。包含了抽取式摘要和生成式摘要。 |
Reddit TIFU | Abstractive Summarization of Reddit Posts with Multi-level Memory Networks | 在线讨论 | 通过从 Reddit 爬取数据,作者生成了两套摘要:用原帖的 title 作为 short summary,TL;DR summary 作为 long summary。 |
SAMSum | SAMSum Corpus: A Human-annotated Dialogue Dataset for Abstractive Summarization | 对话 | 对话由语言学家根据日常对话写成,之后由语言学家标注摘要。 |
FastSum 提供了两种评估指标:
FastRougeMetric 使用 python 实现的 ROUGE 非官方库来实现在训练过程中快速计算 rouge 近似值。源代码为:https://github.com/pltrdy/rouge
PyRougeMetric 使用论文 ROUGE: A Package for Automatic Evaluation of Summaries 提供的官方 ROUGE 1.5.5 评测库。为了使用ROUGE 1.5.5,需要使用 sudo 权限安装一系列依赖库。FastSum 提供了安装指南。
我们看下在 CNN/DailyMail 数据集上的 ROUGE 分数:
Model | ROUGE-1 | ROUGE-2 | ROUGE-L | Paper |
---|---|---|---|---|
LEAD 3 | 40.11 | 17.64 | 36.32 | Our data pre-process |
ORACLE | 55.24 | 31.14 | 50.96 | Our data pre-process |
LSTM + Sequence Labeling | 40.72 | 18.27 | 36.98 | - |
Transformer + Sequence Labeling | 40.86 | 18.38 | 37.18 | - |
LSTM + Pointer Network | 39.73 | 39.9 | 36.05 | Get To The Point: Summarization with Pointer-Generator Networks |
BERTSUMEXT | 42.83 | 19.92 | 39.18 | Text Summarization with Pretrained Encoders |
TransSUMEXT | 41.04 | 18.34 | 37.3 | Text Summarization with Pretrained Encoders |
BERTSUMABS | 41.17 | 18.72 | 38.16 | Text Summarization with Pretrained Encoders |
TransSUMABS | 40.17 | 17.81 | 37.12 | Text Summarization with Pretrained Encoders |
安装和使用 安装流程如下所示:
需要注意的是,在运行代码前,请在指定的位置填写上你的 ROUGE 路径。
安装最新的 FastNLP:
pip install git+https://gitee.com/fastnlp/fastNLP