🚀 bart-large-summary-map-reduce
このモデルは、分割された長文ドキュメントの要約を「マップリデュース」して1つの要約にまとめるtext2textモデルです。
このモデルがtextsum(または以下に類似した他の長文要約手法)の事後処理として果たす役割についての説明:

Googleのブログこちらから改変したフローチャート
🚀 クイックスタート
このセクションでは、このモデルを使用して長文ドキュメントの要約を集約する基本的な手順を説明します。
✨ 主な機能
📦 インストール
このモデルを使用するには、transformers
ライブラリが必要です。以下のコマンドでインストールできます。
pip install transformers
💻 使用例
基本的な使用法
長文ドキュメントのチャンクから要約を集約する例です。
import torch
from transformers import pipeline
pipe = pipeline(
"text2text-generation",
model="pszemraj/bart-large-summary-map-reduce",
device_map="auto",
)
text = """"Sangers on a Train" is a 1950 film about a train driver, Guy Haines, who discovers his wife, Miriam, has been murdered in Metcalf, Washington, DC. The film delves into the relationship between Guy and Anne Burton, focusing on Guy's desire for Anne to marry him.
"Screentalk" is a comedy about Anne Burton and her husband, Guy Haines, who are investigating the murder of their daughter, Miriam. The plot revolves around Anne's relationship with Bruno, who has been arrested for his wife's murder. In the second set, Guy and Anne meet at a tennis court in Washington, DC, where they plan to play against each other. Hennessy and Hammond investigate the crime scene, leading to Guy's arrest.
"The Announcer's Boom Forest Hills" is a tennis game between Guy Haines and Bruno Antony, with the score six-five. In the second set, Haines leads three games to four, but his opponent, Bernard Reynolds, attacks him in the third set. Meanwhile, Anne Hennessy and Barbara Hammond are preparing for dinner at the amusement park, where Guy has been waiting for hours. A police car arrives, followed by a taxi. The boatman and detectives follow Guy through the queue, leading to the conclusion that Guy was the man responsible for the accident."""
text = """A computer implemented method of generating a syntactic object. The method includes the steps of providing a plurality of input data sets, each input data set comprising one or more words, wherein each word is associated with at least one non-adjacent second word; creating an exocentric relationship between the first and second words by applying a neo-ian event semantics to the input data in such a way that the neo-antagonistic effect results in the generation of the syntactic object; and storing the generated syntactic object for future use.
A method of learning and using language is disclosed. The method includes the steps of creating a lexicon of words, wherein each word in the lexicon has at least two possible states, selecting a set of one or more of the possible states of the lexicon to be used as a base state for a subsequent computational operation, and applying the computational operation to the base state to form a new output state.
A computer implemented method for changing a first workspace to a second workspace. The method includes the steps of creating a new workspace by merging the first workspace with the second workspace, wherein the merging is based on at least one of: an impenetrable condition; a constraint on movement; and a resource restriction.
The brain is constantly loosing neurons because you doesn't want all the junk around."""
if torch.cuda.is_available():
torch.cuda.empty_cache()
res = pipe(
text,
max_new_tokens=512,
num_beams=4,
early_stopping=True,
truncation=True,
)
print(res[0]["generated_text"])
高度な使用法
このモデルは、GPUでの推論にいくつかの高速化手法をサポートしています。以下のように設定することで、高速化を実現できます。
💡 使用アドバイス
BARTは、GPUでの推論にflash-attention2やtorch SDPAなどのいくつかの高速化手法をサポートしています。
import torch
from transformers import pipeline
torch.backends.cuda.matmul.allow_tf32 = True
pipe = pipeline(
"text2text-generation",
model="pszemraj/bart-large-summary-map-reduce",
device_map="auto",
model_kwargs={"use_flash_attention_2": True}
)
text = "長文のテキストをここに入力"
res = pipe(
text,
max_new_tokens=512,
num_beams=4,
early_stopping=True,
truncation=True,
)
print(res[0]["generated_text"])
📚 ドキュメント
詳細
このモデルは、pszemraj/summary-map-reduceデータセットでfacebook/bart-largeをファインチューニングしたバージョンです。
評価セットでは、以下の結果を達成しています。
- 損失: 0.7894
- 入力トークン数: 14258488
トレーニング手順
トレーニングハイパーパラメータ
トレーニング中に使用されたハイパーパラメータは以下の通りです。
パラメータ |
値 |
学習率 |
0.0001 |
トレーニングバッチサイズ |
4 |
評価バッチサイズ |
4 |
シード |
17868 |
勾配累積ステップ数 |
16 |
総トレーニングバッチサイズ |
64 |
オプティマイザ |
OptimizerNames.PAGED_ADAMW (betas=(0.9,0.999), epsilon=1e-08, 追加のオプティマイザ引数なし) |
学習率スケジューラの種類 |
cosine |
学習率スケジューラのウォームアップ比率 |
0.05 |
エポック数 |
3.0 |
📄 ライセンス
このモデルは、Apache-2.0ライセンスの下で提供されています。