File size: 1,939 Bytes
7571ecb cf5775b 7571ecb a92b56a 7571ecb c32fe02 7571ecb c32fe02 7571ecb c32fe02 7571ecb c32fe02 7571ecb caff306 7571ecb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
---
license: mit
language:
- ru
pipeline_tag: text2text-generation
widget:
- text: '<SC1>- Как тебя зовут?\n- Даша\n- А меня Денис\n- <extra_id_0>'
---
# Den4ikAI/FRED-T5-XL-chitchat
Болталка на основе FRED-T5-XL. Длина контекста модели 6-8 реплик.
# Пример использования
```python
import torch
import transformers
use_cuda = torch.cuda.is_available()
device = torch.device("cuda" if use_cuda else "cpu")
t5_tokenizer = transformers.GPT2Tokenizer.from_pretrained("Den4ikAI/FRED-T5-XL-chitchat")
t5_model = transformers.T5ForConditionalGeneration.from_pretrained("Den4ikAI/FRED-T5-XL-chitchat")
while True:
print('-'*80)
dialog = []
while True:
msg = input('H:> ').strip()
if len(msg) == 0:
break
dialog.append('- ' + msg)
dialog.append('- <extra_id_0>')
input_ids = t5_tokenizer('<SC1>'+'\n'.join(dialog), return_tensors='pt').input_ids
out_ids = t5_model.generate(input_ids=input_ids,
max_length=200,
eos_token_id=t5_tokenizer.eos_token_id,
early_stopping=True,
do_sample=True,
temperature=1.0,
top_k=0,
top_p=0.85)
dialog.pop(-1)
t5_output = t5_tokenizer.decode(out_ids[0][1:]).replace('<extra_id_0>','')
if '</s>' in t5_output:
t5_output = t5_output[:t5_output.find('</s>')].strip()
print('B:> {}'.format(t5_output))
dialog.append('- '+t5_output)
```
# Citation
```
@MISC{Den4ikAI/FRED-T5-XL-chitchat,
author = {Denis Petrov},
title = {Russian chitchat model},
url = {https://huggingface.co/Den4ikAI/FRED-T5-XL-chitchat},
year = 2023
}
```
|