这是一种在一些俄语对话数据上进行微调的 cointegrated/rut5-small 模型的版本。它并不很聪明和富有创意,但它是小巧而快速的,可以作为一些聊天机器人的备用响应生成器,也可以用来进行微调,以模仿某个人的风格。
模型的输入是以'\n\n'分隔的前一个对话话语,输出是下一个话语。
模型的使用方式如下:
# !pip install transformers sentencepiece
import torch
from transformers import T5ForConditionalGeneration, T5Tokenizer
tokenizer = T5Tokenizer.from_pretrained("cointegrated/rut5-small-chitchat")
model = T5ForConditionalGeneration.from_pretrained("cointegrated/rut5-small-chitchat")
text = 'Привет! Расскажи, как твои дела?'
inputs = tokenizer(text, return_tensors='pt')
with torch.no_grad():
hypotheses = model.generate(
**inputs,
do_sample=True, top_p=0.5, num_return_sequences=3,
repetition_penalty=2.5,
max_length=32,
)
for h in hypotheses:
print(tokenizer.decode(h, skip_special_tokens=True))
# Как обычно.
# Сейчас - в порядке.
# Хорошо.
# Wall time: 363 ms