🚀 T5 Base with QA + Summary + Emotion
このモデルは、質問応答、要約、感情検出の機能を備えたT5 Baseモデルです。CoQa、Squad 2、GoEmotions、CNN/DailyMailのデータセットでファインチューニングされています。
🚀 クイックスタート
依存関係
transformers>=4.0.0が必要です。
✨ 主な機能
- 質問応答:Squad 2の開発セットでF1 79.5、CoQaの開発セットでF1 70.6のスコアを達成します。
- 要約:CNN/DailyMailのデータセットでファインチューニングされていますが、評価はまだ行われていません。
- 感情検出:GoEmotionsのデータセットでファインチューニングされていますが、評価はまだ行われていません。
📦 インストール
依存関係をインストールするには、以下のコマンドを実行します。
pip install transformers>=4.0.0
💻 使用例
基本的な使用法
質問応答
Transformersを使用する場合
from transformers import T5ForConditionalGeneration, T5Tokenizer
model = T5ForConditionalGeneration.from_pretrained("kiri-ai/t5-base-qa-summary-emotion")
tokenizer = T5Tokenizer.from_pretrained("kiri-ai/t5-base-qa-summary-emotion")
def get_answer(question, prev_qa, context):
input_text = [f"q: {qa[0]} a: {qa[1]}" for qa in prev_qa]
input_text.append(f"q: {question}")
input_text.append(f"c: {context}")
input_text = " ".join(input_text)
features = tokenizer([input_text], return_tensors='pt')
tokens = model.generate(input_ids=features['input_ids'],
attention_mask=features['attention_mask'], max_length=64)
return tokenizer.decode(tokens[0], skip_special_tokens=True)
print(get_answer("Why is the moon yellow?", "I'm not entirely sure why the moon is yellow."))
context = "Elon Musk left OpenAI to avoid possible future conflicts with his role as CEO of Tesla."
print(get_answer("Why not?", [("Does Elon Musk still work with OpenAI", "No")], context))
Kiriを使用する場合
from kiri.models import T5QASummaryEmotion
context = "Elon Musk left OpenAI to avoid possible future conflicts with his role as CEO of Tesla."
prev_qa = [("Does Elon Musk still work with OpenAI", "No")]
model = T5QASummaryEmotion()
model.qa("Why not?", context, prev_qa=prev_qa)
> "to avoid possible future conflicts with his role as CEO of Tesla"
要約
Transformersを使用する場合
from transformers import T5ForConditionalGeneration, T5Tokenizer
model = T5ForConditionalGeneration.from_pretrained("kiri-ai/t5-base-qa-summary-emotion")
tokenizer = T5Tokenizer.from_pretrained("kiri-ai/t5-base-qa-summary-emotion")
def summary(context):
input_text = f"summarize: {context}"
features = tokenizer([input_text], return_tensors='pt')
tokens = model.generate(input_ids=features['input_ids'],
attention_mask=features['attention_mask'], max_length=64)
return tokenizer.decode(tokens[0], skip_special_tokens=True)
Kiriを使用する場合
from kiri.models import T5QASummaryEmotion
model = T5QASummaryEmotion()
model.summarise("Long text to summarise")
> "Short summary of long text"
感情検出
Transformersを使用する場合
from transformers import T5ForConditionalGeneration, T5Tokenizer
model = T5ForConditionalGeneration.from_pretrained("kiri-ai/t5-base-qa-summary-emotion")
tokenizer = T5Tokenizer.from_pretrained("kiri-ai/t5-base-qa-summary-emotion")
def emotion(context):
input_text = f"emotion: {context}"
features = tokenizer([input_text], return_tensors='pt')
tokens = model.generate(input_ids=features['input_ids'],
attention_mask=features['attention_mask'], max_length=64)
return tokenizer.decode(tokens[0], skip_special_tokens=True)
Kiriを使用する場合
from kiri.models import T5QASummaryEmotion
model = T5QASummaryEmotion()
model.emotion("I hope this works!")
> "optimism"
📚 ドキュメント
このモデルは、CoQa、Squad 2、GoEmotions、CNN/DailyMailのデータセットでファインチューニングされています。Squad 2の開発セットでF1 79.5、CoQaの開発セットでF1 70.6のスコアを達成しています。要約と感情検出の評価はまだ行われていません。
📄 ライセンス
このモデルは、Apache 2.0ライセンスの下で提供されています。
👋 私たちについて
Kiriは、最先端のモデルを簡単に、アクセス可能に、スケーラブルに使用できるようにします。
ウェブサイト | 自然言語エンジン
📋 モデル情報
属性 |
详情 |
モデルタイプ |
T5 Base with QA + Summary + Emotion |
学習データ |
CoQa、Squad 2、GoEmotions、CNN/DailyMail |
評価指標 |
F1 |
パイプラインタグ |
text2text-generation |