🚀 t5-small-machine-articles-tag-generation
このモデルは、機械学習関連の記事にタグを生成するための機械学習モデルです。このモデルは、t5-small を微調整したもので、190k Medium Articles データセットの改良版を使用して、記事のテキスト内容を入力として、機械学習記事のタグを生成するように微調整されています。通常はマルチラベル分類問題として定式化されますが、このモデルは タグ生成 をテキスト生成タスクとして扱っています(参考: fabiochiu/t5-base-tag-generation)。
微調整ノートブックの参考: Hugging face summarization notebook。
🚀 クイックスタート
📦 インストール
pip install transformers nltk
💻 使用例
基本的な使用法
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import nltk
nltk.download('punkt')
tokenizer = AutoTokenizer.from_pretrained("nandakishormpai/t5-small-machine-articles-tag-generation")
model = AutoModelForSeq2SeqLM.from_pretrained("nandakishormpai/t5-small-machine-articles-tag-generation")
article_text = """
Paige, AI in pathology and genomics
Fundamentally transforming the diagnosis and treatment of cancer
Paige has raised $25M in total. We talked with Leo Grady, its CEO.
How would you describe Paige in a single tweet?
AI in pathology and genomics will fundamentally transform the diagnosis and treatment of cancer.
How did it all start and why?
Paige was founded out of Memorial Sloan Kettering to bring technology that was developed there to doctors and patients worldwide. For over a decade, Thomas Fuchs and his colleagues have developed a new, powerful technology for pathology. This technology can improve cancer diagnostics, driving better patient care at lower cost. Paige is building clinical products from this technology and extending the technology to the development of new biomarkers for the biopharma industry.
What have you achieved so far?
TEAM: In the past year and a half, Paige has built a team with members experienced in AI, entrepreneurship, design and commercialization of clinical software.
PRODUCT: We have achieved FDA breakthrough designation for the first product we plan to launch, a testament to the impact our technology will have in this market.
CUSTOMERS: None yet, as we are working on CE and FDA regulatory clearances. We are working with several biopharma companies.
What do you plan to achieve in the next 2 or 3 years?
Commercialization of multiple clinical products for pathologists, as well as the development of novel biomarkers that can help speed up and better inform the diagnosis and treatment selection for patients with cancer.
"""
inputs = tokenizer([article_text], max_length=1024, truncation=True, return_tensors="pt")
output = model.generate(**inputs, num_beams=8, do_sample=True, min_length=10,
max_length=128)
decoded_output = tokenizer.batch_decode(output, skip_special_tokens=True)[0]
tags = [ tag.strip() for tag in decoded_output.split(",")]
print(tags)
📚 ドキュメント
データセットの準備
Kaggleの190k記事データセットのうち、約12kは機械学習に関するもので、タグはかなり大まかなものでした。技術ブログプラットフォーム用のシステムを開発する際には、より具体的なタグを生成することが有用です。ML記事を抽出し、約1000記事をサンプリングしました。それらにGPT3 APIを使用してタグ付けを行い、生成されたタグに前処理を施して、4または5個のタグを持つ記事を選択し、最終的なデータセットとして約940記事を得ました。
想定される用途と制限
このモデルは主に機械学習記事のタグ生成に使用でき、他の技術記事にも使用できますが、精度と詳細度は低くなります。結果には重複するタグが含まれる場合があり、結果の後処理で対処する必要があります。
結果
評価セットでは、以下の結果を達成します。
- Loss: 1.8786
- Rouge1: 35.5143
- Rouge2: 18.6656
- Rougel: 32.7292
- Rougelsum: 32.6493
- Gen Len: 17.5745
学習と評価データ
940記事以上のデータセットを、学習:検証:テスト = 80:10:10の比率で分割しました。
学習ハイパーパラメータ
学習時には、以下のハイパーパラメータを使用しました。
- learning_rate: 2e-05
- train_batch_size: 16
- eval_batch_size: 16
- seed: 42
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 10
- mixed_precision_training: Native AMP
フレームワークのバージョン
- Transformers 4.26.1
- Pytorch 1.13.1+cu116
- Datasets 2.9.0
- Tokenizers 0.13.2
📄 ライセンス
このモデルは、Apache-2.0ライセンスの下で提供されています。