这是基于 google/mt5-small 模型的一个小型俄语改写工具。它的改写性能相对较差,但可以根据这个或其他任务进行微调。
该模型是通过从 alenusch/mt5small-ruparaphraser 模型中剥离与俄语无关或不常见的词汇的96%来创建的。
可以按照以下方式使用该模型:
# !pip install transformers sentencepiece
import torch
from transformers import T5ForConditionalGeneration, T5Tokenizer
tokenizer = T5Tokenizer.from_pretrained("cointegrated/rut5-small")
model = T5ForConditionalGeneration.from_pretrained("cointegrated/rut5-small")
text = 'Ехал Грека через реку, видит Грека в реке рак. '
inputs = tokenizer(text, return_tensors='pt')
with torch.no_grad():
hypotheses = model.generate(
**inputs,
do_sample=True, top_p=0.95, num_return_sequences=10,
repetition_penalty=2.5,
max_length=32,
)
for h in hypotheses:
print(tokenizer.decode(h, skip_special_tokens=True))