
This is a paraphraser for Russian sentences described [in this Habr post](https://habr.com/ru/post/564916/). 

It is recommended to use the model with the `encoder_no_repeat_ngram_size` argument:
```
from transformers import T5ForConditionalGeneration, T5Tokenizer
MODEL_NAME = 'cointegrated/rut5-base-paraphraser'
model = T5ForConditionalGeneration.from_pretrained(MODEL_NAME)
tokenizer = T5Tokenizer.from_pretrained(MODEL_NAME)
model.cuda();
model.eval();

def paraphrase(text, beams=5, grams=4, do_sample=False):
    x = tokenizer(text, return_tensors='pt', padding=True).to(model.device)
    max_size = int(x.input_ids.shape[1] * 1.5 + 10)
    out = model.generate(**x, encoder_no_repeat_ngram_size=grams, num_beams=beams, max_length=max_size, do_sample=do_sample)
    return tokenizer.decode(out[0], skip_special_tokens=True)

print(paraphrase('Каждый охотник желает знать, где сидит фазан.'))
# Все охотники хотят знать где фазан сидит.
```
{"language": ["ru"], "license": "mit", "tags": ["russian", "paraphrasing", "paraphraser", "paraphrase"], "datasets": ["cointegrated/ru-paraphrase-NMT-Leipzig"], "widget": [{"text": "\u041a\u0430\u0436\u0434\u044b\u0439 \u043e\u0445\u043e\u0442\u043d\u0438\u043a \u0436\u0435\u043b\u0430\u0435\u0442 \u0437\u043d\u0430\u0442\u044c, \u0433\u0434\u0435 \u0441\u0438\u0434\u0438\u0442 \u0444\u0430\u0437\u0430\u043d."}]}
transformers pytorch safetensors t5 text2text-generation russian paraphrasing paraphraser paraphrase ru dataset:cointegrated/ru-paraphrase-NMT-Leipzig license:mit autotrain_compatible endpoints_compatible has_space text-generation-inference region:us
TAGS
#transformers #pytorch #safetensors #t5 #text2text-generation #russian #paraphrasing #paraphraser #paraphrase #ru #dataset-cointegrated/ru-paraphrase-NMT-Leipzig #license-mit #autotrain_compatible #endpoints_compatible #has_space #text-generation-inference #region-us 


This is a paraphraser for Russian sentences described in this Habr post. 

It is recommended to use the model with the 'encoder_no_repeat_ngram_size' argument:

TAGS
#transformers #pytorch #safetensors #t5 #text2text-generation #russian #paraphrasing #paraphraser #paraphrase #ru #dataset-cointegrated/ru-paraphrase-NMT-Leipzig #license-mit #autotrain_compatible #endpoints_compatible #has_space #text-generation-inference #region-us 

passage: TAGS
#transformers #pytorch #safetensors #t5 #text2text-generation #russian #paraphrasing #paraphraser #paraphrase #ru #dataset-cointegrated/ru-paraphrase-NMT-Leipzig #license-mit #autotrain_compatible #endpoints_compatible #has_space #text-generation-inference #region-us 
