🚀 KeywordGen-v2模型
KeywordGen-v2是一款基於T5架構微調的模型,專門用於從文本中提取關鍵詞。輸入一段文本,模型就能輸出與之相關的關鍵詞,為信息提取提供便利。
🚀 快速開始
你可以直接使用文本生成管道來調用這個模型。使用時,為了獲得最佳效果,請在輸入文本前加上 "Keyword: "。
以下是使用Hugging Face Transformers庫在Python中調用該模型的示例:
💻 使用示例
基礎用法
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)
✨ 主要特性
- 針對性微調:該模型 "KeywordGen-v2" 是 "KeywordGen" 系列的第二代產品,基於T5基礎模型進行微調,專注於從文本輸入中生成關鍵詞,尤其擅長處理產品評論。
- 輸出規範:模型輸出的關鍵詞長度在2到8個單詞之間,能有效提取產品評論中的關鍵點或主題。
- 輸入要求:當輸入文本至少有2 - 3個句子時,模型性能更佳。
📚 詳細文檔
模型描述
"KeywordGen-v2" 是 "KeywordGen" 系列的第二個版本,基於T5基礎模型微調而來,專門用於從文本輸入中生成關鍵詞,尤其側重於產品評論。該模型能夠從產品評論中提取關鍵點或主題,輸出的關鍵詞預計在2到8個單詞之間。當輸入文本至少有2 - 3個句子時,模型性能更佳。
訓練情況
此模型在自定義數據集上進行訓練,基礎模型採用的是T5基礎模型。
侷限性和未來工作
和任何機器學習模型一樣,這個關鍵詞生成器的輸出依賴於其訓練數據。如果輸入文本包含不適當或有偏見的內容,模型可能會生成相應的關鍵詞。未來的模型迭代將致力於提高其魯棒性和公平性,並儘量減少潛在的偏差。
📄 許可證
本項目採用Apache-2.0許可證。
屬性 |
詳情 |
模型類型 |
文本到文本生成 |
訓練數據 |
自定義數據集 |
庫名稱 |
transformers |
標籤 |
代碼、關鍵詞生成、英文、T5 |
⚠️ 重要提示
由於模型輸出依賴訓練數據,若輸入文本包含不適當或有偏見的內容,模型可能生成相應關鍵詞。
💡 使用建議
使用模型時,在輸入文本前加上 "Keyword: " 可獲得最佳效果。同時,輸入文本至少為2 - 3個句子,模型性能更佳。