🚀 Longformer Encoder-Decoder (LED) を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ライセンスの下でライセンスされています。