🚀 多用途文本摘要生成器(在多個摘要數據集上微調110億參數的google/flan - t5 - xxl模型)
本項目是一個多用途的文本摘要生成模型,它基於在多個摘要數據集上微調的google/flan - t5 - xxl
模型。該模型可用於學術和日常的文本摘要任務,通過在源文檔前添加不同的提示詞,能靈活控制摘要的類型。
🚀 快速開始
本模型可以通過Colab進行使用,點擊下面的鏈接在Colab中打開:
✨ 主要特性
- 多用途摘要:可用於學術和日常的文本摘要任務,適用於多種類型的文本。
- 提示詞控制:通過在源文檔前添加不同的提示詞,可以控制摘要的類型和長度。
- 數據過濾:70%的訓練數據使用
contriever
進行過濾,以餘弦相似度0.6為閾值,提高數據質量。
📦 安裝指南
在使用模型之前,需要安裝transformers
庫:
pip install transformers
💻 使用示例
基礎用法
本模型需要在源文檔前添加提示詞以指示摘要類型,以下是一些示例提示詞:
example_prompts = {
"social": "Produce a short summary of the following social media post:",
"ten": "Summarize the following article in 10 - 20 words:",
"5": "Summarize the following article in 0 - 5 words:",
"100": "Summarize the following article in about 100 words:",
"summary": "Write a ~ 100 word summary of the following text:",
"short": "Provide a short summary of the following article:",
}
提示詞應以冒號結尾,輸入格式示例:"Summarize the following: \n\n {input_text}"
安裝transformers
庫後,運行以下代碼:
from transformers import pipeline
import torch
summarizer = pipeline("summarization", "jordiclive/flan-t5-11b-summarizer-filtered", torch_dtype=torch.bfloat16)
raw_document = 'You must be 18 years old to live or work in New York State...'
prompt = "Summarize the following article in 10-20 words:"
results = summarizer(
f"{prompt} \n\n {raw_document}",
num_beams=5,
min_length=5,
no_repeat_ngram_size=3,
truncation=True,
max_length=512,
)
高級用法
本模型還支持通過指定“x - y words”或“~/approximately/about/ x words”的範圍來控制摘要的長度。
🔧 技術細節
訓練過程
- 訓練使用BF16精度,採用deepspeed stage 2並結合CPU卸載,訓練1個epoch,並監控驗證損失。
硬件配置
- GPU數量:8塊NVIDIA A100 - SXM4 - 80GB
- CPU數量:48核
訓練超參數
- 學習率(learning_rate):3e - 05
- 訓練批次大小(train_batch_size):4
- 評估批次大小(eval_batch_size):4
- 隨機種子(seed):42
- 分佈式類型(distributed_type):多GPU
- 梯度累積步數(gradient_accumulation_steps):2
- 有效訓練批次大小(effective_train_batch_size):64
- 優化器(optimizer):Adam,β1 = 0.9,β2 = 0.999,ε = 1e - 08
- 學習率調度器類型(lr_scheduler_type):線性
- 熱身步數(warmup_steps):2000
- 訓練輪數(num_epochs):4
框架版本
- Transformers:4.24.0
- Pytorch:1.9.1+cu111
- Deepspeed:0.7.4
- Pytorch - lightning:1.8.1
📄 許可證
本項目採用以下許可證:
- Apache - 2.0
- BSD - 3 - Clause
屬性 |
詳情 |
模型類型 |
基於微調的google/flan - t5 - xxl的多用途文本摘要生成器 |
訓練數據 |
xsum、wikihow、cnn_dailymail/3.0.0、samsum、scitldr/AIC、billsum、TLDR、wikipedia - summary等數據集,70%的數據使用contriever過濾 |
評估指標 |
ROUGE |