テキスト要約

Hugging Faceを使いこなす

Jacob H. Marquez

Lead Data Engineer

要約とは

$$

Large text

$$

part2.jpg

Hugging Faceを使いこなす

抽出的要約と 抽象的要約

$$

抽出的:

$$ ✅ テキストから重要な文を抜き出す

$$ ✅ 効率的で、必要なリソースが少ない

$$ ❌ 柔軟性やまとまりに欠けることがある

$$

抽象的:

$$ ✅ テキストを言い換えて生成する

$$ ✅ 明確で読みやすい

$$ ❌ より多くのリソースと処理が必要

Hugging Faceを使いこなす

抽出的要約の使用例

$$

  • 📑 法的文書: 重要な条項を抜き出す

$$

$$

$$

  • 💰 金融調査: 分析結果を抽出する

法的文書

金融調査

Hugging Faceを使いこなす

抽象的要約の使用例

ニュース記事

Content Recommendations.jpg

$$

  • 📰 ニュース記事: 簡潔な要約を作成

$$

$$ $$

  • 📍 コンテンツ紹介文: 魅力のある説明文を生成する
Hugging Faceを使いこなす

抽出的要約の実行方法

from transformers import pipeline

# Load the extractive summarization pipeline
summarizer = pipeline("summarization", model="nyamuda/extractive-summarization")
text = "This is my really large text about Data Science..."
summary_text = summarizer(text)
print(summary_text[0]['summary_text'])
"data science is a field that combines mathematics, statistics...."
Hugging Faceを使いこなす

抽象的要約の実行方法

from transformers import pipeline

# Load the abstractive summarization pipeline
summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")

text = "This is my really large text about Data Science..." summary_text = summarizer(text) print(summary_text[0]['summary_text'])
"The global data science platform market is projected
 is projected to reach $140.9 billion by 2025..."
Hugging Faceを使いこなす

要約のパラメーター

  • min_new_tokens & max_new_tokens: 要約の長さを調整
summarizer = pipeline(task="summarization", min_new_tokens=10, max_new_tokens=150)
Hugging Faceを使いこなす

練習しましょう!

Hugging Faceを使いこなす

Preparing Video For Download...