bart large xsum

提供商facebook
分类summarization
许可证mit
下载量334
星标0

简介

BART-large-xsum 是由 Facebook 开发的一款专注于“极简摘要”的预训练模型。与追求覆盖所有要点的通用摘要模型不同,它在 XSum 数据集上进行了微调,擅长用一句话概括文章的核心主旨,风格更接近新闻标题或电报式总结。对于中国开发者来说,它非常适合集成到内容聚合应用或信息流预览中,用于快速提取长文精髓。虽然它不支持超长文本输入,且在中文处理上需配合翻译或使用多语言版本,但在英文摘要的精炼度上表现极佳,上手门槛低,可通过 Hugging Face 快速部署。

核心亮点

  • 擅长极简摘要,能将长文浓缩为单句主旨
  • 基于 BART 架构,文本生成流畅度高
  • 适用于新闻快讯、内容预览等摘要场景
  • MIT 协议开源,部署便捷且无商业限制

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("facebook/bart-large-xsum")
tokenizer = AutoTokenizer.from_pretrained("facebook/bart-large-xsum")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download facebook/bart-large-xsum

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download facebook/bart-large-xsum config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('facebook/bart-large-xsum')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/facebook/bart-large-xsum

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/facebook/bart-large-xsum

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('facebook/bart-large-xsum')
tokenizer = AutoTokenizer.from_pretrained('facebook/bart-large-xsum')

模型下载

我们推荐使用命令行或者 ModelScope SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 ModelScope:

操作指引
pip install modelscope

命令行下载

下载完整模型库

下载完整模型库
modelscope download --model facebook/bart-large-xsum

下载单个文件到指定本地文件夹(以下载 README.md 到当前路径下 dir 目录为例)

下载单个文件到指定本地文件夹(以下载 README.md 到当前路径下 dir 目录为例)
modelscope download --model facebook/bart-large-xsum README.md --local_dir ./dir

更多更丰富的命令行下载选项,可参见具体文档

SDK 下载

SDK 下载
# 模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('facebook/bart-large-xsum')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://www.modelscope.cn/facebook/bart-large-xsum.git

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/facebook/bart-large-xsum.git

ModelScope 模型页直接下载模型文件;无需将模型文件放在本站服务器。

Notebook 快速开发

下载并安装 ModelScope library

下载并安装 ModelScope library
pip install "modelscope[audio,cv,nlp,multi-modal,science]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

模型加载和推理

模型加载和推理
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

p = pipeline('text-generation', 'facebook/bart-large-xsum')

完整文档

来源: HuggingFace

---
tags:

  • summarization

language:
  • en

license: mit
model-index:
  • name: facebook/bart-large-xsum

results:
- task:
type: summarization
name: Summarization
dataset:
name: cnn_dailymail
type: cnn_dailymail
config: 3.0.0
split: test
metrics:
- name: ROUGE-1
type: rouge
value: 25.2697
verified: true
- name: ROUGE-2
type: rouge
value: 7.6638
verified: true
- name: ROUGE-L
type: rouge
value: 17.1808
verified: true
- name: ROUGE-LSUM
type: rouge
value: 21.7933
verified: true
- name: loss
type: loss
value: 3.5042972564697266
verified: true
- name: gen_len
type: gen_len
value: 27.4462
verified: true
- task:
type: summarization
name: Summarization
dataset:
name: xsum
type: xsum
config: default
split: test
metrics:
- name: ROUGE-1
type: rouge
value: 45.4525
verified: true
- name: ROUGE-2
type: rouge
value: 22.3455
verified: true
- name: ROUGE-L
type: rouge
value: 37.2302
verified: true
- name: ROUGE-LSUM
type: rouge
value: 37.2323
verified: true
- name: loss
type: loss
value: 2.3128726482391357
verified: true
- name: gen_len
type: gen_len
value: 25.5435
verified: true
- task:
type: summarization
name: Summarization
dataset:
name: samsum
type: samsum
config: samsum
split: train
metrics:
- name: ROUGE-1
type: rouge
value: 24.7852
verified: true
- name: ROUGE-2
type: rouge
value: 5.2533
verified: true
- name: ROUGE-L
type: rouge
value: 18.6792
verified: true
- name: ROUGE-LSUM
type: rouge
value: 20.629
verified: true
- name: loss
type: loss
value: 3.746837854385376
verified: true
- name: gen_len
type: gen_len
value: 23.1206
verified: true
- task:
type: summarization
name: Summarization
dataset:
name: samsum
type: samsum
config: samsum
split: test
metrics:
- name: ROUGE-1
type: rouge
value: 24.9158
verified: true
- name: ROUGE-2
type: rouge
value: 5.5837
verified: true
- name: ROUGE-L
type: rouge
value: 18.8935
verified: true
- name: ROUGE-LSUM
type: rouge
value: 20.76
verified: true
- name: loss
type: loss
value: 3.775235891342163
verified: true
- name: gen_len
type: gen_len
value: 23.0928
verified: true
---

Bart model finetuned on xsum

docs: https://huggingface.co/transformers/model_doc/bart.html

finetuning: examples/seq2seq/ (as of Aug 20, 2020)

Metrics: ROUGE > 22 on xsum.

variants: search for distilbart

paper: https://arxiv.org/abs/1910.13461