🚀 長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 許可證。