🚀 KeywordGen-v2モデル
KeywordGen-v1は、文章からキーワードを生成するためにファインチューニングされたT5ベースのモデルです。入力された文章に対して、関連するキーワードを返します。
✨ 主な機能
この「KeywordGen-v2」モデルは、「KeywordGen」シリーズの第2版です。T5ベースモデルをベースに、特に商品レビューからのキーワード生成にファインチューニングされています。
このモデルは、商品レビューから要点やテーマを抽出することで、有用な洞察を提供することができます。出力は2〜8語のキーワードを含むことが期待されます。入力が少なくとも2〜3文以上の場合、モデルの性能が向上します。
📦 インストール
このモデルを使用するには、Hugging Face Transformersライブラリが必要です。以下のコマンドでインストールできます。
pip install transformers
💻 使用例
基本的な使用法
このモデルは、テキスト生成用のパイプラインで直接使用できます。モデルを使用する際には、入力の前に「Keyword: 」を付けると、最適な結果が得られます。
以下は、PythonでHugging Face Transformersライブラリを使用してこのモデルを使用する方法です。
単一入力の場合
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("mrutyunjay-patil/keywordGen-v2")
model = T5ForConditionalGeneration.from_pretrained("mrutyunjay-patil/keywordGen-v2")
input_sequence = "Keyword: I purchased the new Android smartphone last week and I've been thoroughly impressed. The display is incredibly vibrant and sharp, and the battery life is surprisingly good, easily lasting a full day with heavy usage."
input_ids = tokenizer.encode(input_sequence, return_tensors="pt")
outputs = model.generate(input_ids)
output_sequence = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(output_sequence)
複数入力の場合
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("mrutyunjay-patil/keywordGen-v2")
model = T5ForConditionalGeneration.from_pretrained("mrutyunjay-patil/keywordGen-v2")
task_prefix = "Keyword: "
inputs = [
"Absolutely love this tablet. It has a clear, sharp screen and runs apps smoothly without any hiccups.",
"The headphones are fantastic with great sound quality, but the build quality could be better.",
"Bought this smartwatch last week, and I'm thrilled with its performance. Battery life is impressive.",
"This laptop exceeded my expectations. Excellent speed, plenty of storage, and light weight. Perfect for my needs.",
"The camera quality on this phone is exceptional. It captures detailed and vibrant photos. However, battery life is not the best."
]
for sample in inputs:
input_sequence = task_prefix + sample
input_ids = tokenizer.encode(input_sequence, return_tensors="pt")
outputs = model.generate(input_ids)
output_sequence = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(sample, "\n --->", output_sequence)
🔧 技術詳細
このモデルは、カスタムデータセットでトレーニングされています。ベースモデルにはT5ベースモデルが使用されています。
📄 ライセンス
このモデルは、Apache-2.0ライセンスの下で提供されています。
⚠️ 制限事項と今後の展望
他の機械学習モデルと同様に、このキーワード生成器の出力は、トレーニングに使用されたデータに依存します。入力テキストに不適切または偏った内容が含まれている場合、モデルが不適切または偏ったキーワードを生成する可能性があります。今後のモデルのバージョンでは、ロバスト性と公平性の向上、および潜在的なバイアスの最小化を目指します。