🚀 长former编码器-解码器(LED)在ILC数据集上微调
本模型是 led-base-16384 在 ILC 数据集上的微调版本。它能够处理长文档的摘要任务,为相关领域提供了有效的解决方案。
🚀 快速开始
本模型是 led-base-16384 在 ILC 数据集上的微调版本。
正如 Iz Beltagy、Matthew E. Peters、Arman Cohan 在 Longformer: The Long-Document Transformer 中所描述的,led-base-16384 是从 bart-base 初始化而来的,因为这两个模型具有完全相同的架构。为了能够处理 16K 个标记,bart-base 的位置嵌入矩阵被简单地复制了 16 次。
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
device = "cuda" if torch.cuda.is_available() else "CPU"
checkpoint = "d0r1h/led-base-ilc"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint, return_dict_in_generate=True).to(device)
case = "......."
input_ids = tokenizer(case, return_tensors="pt").input_ids.to(device)
global_attention_mask = torch.zeros_like(input_ids)
global_attention_mask[:, 0] = 1
sequences = model.generate(input_ids,
global_attention_mask=global_attention_mask).sequences
summary = tokenizer.batch_decode(sequences,
skip_special_tokens=True)
💻 使用示例
基础用法
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
device = "cuda" if torch.cuda.is_available() else "CPU"
checkpoint = "d0r1h/led-base-ilc"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint, return_dict_in_generate=True).to(device)
case = "......."
input_ids = tokenizer(case, return_tensors="pt").input_ids.to(device)
global_attention_mask = torch.zeros_like(input_ids)
global_attention_mask[:, 0] = 1
sequences = model.generate(input_ids,
global_attention_mask=global_attention_mask).sequences
summary = tokenizer.batch_decode(sequences,
skip_special_tokens=True)
📚 详细文档
评估结果
当该模型用于总结 ILC 文档(10 个样本)时,取得了以下结果:
模型 |
rouge1-f |
rouge1-p |
rouge2-f |
rouge2-p |
rougeL-f |
rougeL-p |
led-ilc |
42 |
47 |
22 |
24 |
39 |
44 |
led-base |
3 |
39 |
1 |
21 |
3 |
37 |
此笔记本 展示了如何有效地将 led 用于下游任务,如摘要生成。
📄 许可证
本项目采用 Apache-2.0 许可证。