Skip to content

Latest commit

 

History

History
138 lines (85 loc) · 9.17 KB

Readme_zh.md

File metadata and controls

138 lines (85 loc) · 9.17 KB

FastSum

FastSum是基于fastNLP开发的一套完整的文本摘要任务解决方案,包括数据加载、模型调用、模型评价三个部分。

模型

FastSum中实现的模型包括:

  1. 基准模型 (LSTM/Transformer + SeqLab)
  2. Get To The Point: Summarization with Pointer-Generator Networks
  3. Extractive Summarization as Text Matching
  4. Text Summarization with Pretrained Encoders

数据集

我们提供了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 对话 对话由语言学家根据日常对话写成,之后由语言学家标注摘要。

你可以运行summarizationLoader.py下载并使用它们。

模型评价

FastRougeMetric

FastRougeMetric使用python实现的ROUGE非官方库来实现在训练过程中快速计算rouge近似值。

源代码可见 https://github.com/pltrdy/rouge

在fastNLP中,该方法已经被包装成Metric.py中的FastRougeMetric类以供trainer直接使用。需要事先使用pip安装该rouge库。

pip install rouge

注意:由于实现细节的差异,该结果和官方ROUGE结果存在1-2个点的差异,仅可作为训练过程优化趋势的粗略估计。

PyRougeMetric

PyRougeMetric 使用论文 ROUGE: A Package for Automatic Evaluation of Summaries 提供的官方ROUGE 1.5.5评测库。

由于原本的ROUGE使用perl解释器,pyrouge对其进行了python包装,而PyRougeMetric将其进一步包装为trainer可以直接使用的Metric类。

为了使用ROUGE 1.5.5,需要使用sudo权限安装一系列依赖库。

sudo apt-get install libxml-perl libxml-dom-perl
pip install git+git://github.com/bheinzerling/pyrouge
export PYROUGE_HOME_DIR=the/path/to/RELEASE-1.5.5
pyrouge_set_rouge_path $PYROUGE_HOME_DIR
chmod +x $PYROUGE_HOME_DIR/ROUGE-1.5.5.pl

为避免下载失败,我们在resources中放置了所有你需要的安装文件。对于RELEASE-1.5.5,请务必在RELEASE-1.5.5/data中构建Wordnet 2.0而不是Wordnet 1.6,你可以参考此链接中的说明

cd $PYROUGE_HOME_DIR/data/WordNet-2.0-Exceptions/
./buildExeptionDB.pl . exc WordNet-2.0.exc.db
cd ../
ln -s WordNet-2.0-Exceptions/WordNet-2.0.exc.db WordNet-2.0.exc.db

测试ROUGE是否安装正确

pyrouge_set_rouge_path /absolute/path/to/ROUGE-1.5.5/directory
python -m pyrouge.test

安装PyRouge:

pip install pyrouge

ROUGE分数

数据集:CNN/DailyMail

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.90 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.30 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

安装和使用

建议在Linux上安装和使用

安装最新的FastNLP

pip install git+https://gitee.com/fastnlp/fastNLP@dev