Downloads · 30 days
14
1% of all-time downloads
Den4ikAI/FRED-T5-XL_instructor_chitchat
FRED-T5-XL_instructor_chitchat is a text generation model from Den4ikAI. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as mit.
Инструкционная модель на FRED-T5-XL. Обратите внимание на промпты в примере чит-чата.
Downloads · 30 days
14
1% of all-time downloads
All-time downloads
2.1K
Public
Parameters
1.7B
7 GB on disk
Likes
2
Public
Click a slice to open those files.
.bin3.5 GB · 50%
From the Hugging Face model README
Инструкционная модель на FRED-T5-XL. Обратите внимание на промпты в примере чит-чата.
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, GenerationConfig
import torch
use_cuda = torch.cuda.is_available()
device = torch.device("cuda" if use_cuda else "cpu")
tokenizer = AutoTokenizer.from_pretrained("Den4ikAI/FRED-T5-XL_instructor_chitchat")
model = AutoModelForSeq2SeqLM.from_pretrained("Den4ikAI/FRED-T5-XL_instructor_chitchat", torch_dtype=torch.float16).to(device)
model.eval()
generation_config = GenerationConfig.from_pretrained("Den4ikAI/FRED-T5-XL_instructor_chitchat")
def generate(prompt):
data = tokenizer(f"<SC6>Человек: {prompt}\nБот: <extra_id_0>", return_tensors="pt").to(model.device)
output_ids = model.generate(
**data,
generation_config=generation_config
)[0]
print(tokenizer.decode(data["input_ids"][0].tolist()))
out = tokenizer.decode(output_ids.tolist())
return out
while 1:
generate(input(":> "))
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_instructor_chitchat")
t5_model = transformers.T5ForConditionalGeneration.from_pretrained("Den4ikAI/FRED-T5-XL_instructor_chitchat")
generation_config = transformers.GenerationConfig.from_pretrained("Den4ikAI/FRED-T5-XL_instructor_chitchat")
while True:
print('-'*80)
dialog = []
while True:
msg = input('H:> ').strip()
if len(msg) == 0:
break
msg = msg[0].upper() + msg[1:]
dialog.append('Собеседник сказал: ' + msg)
# Данный пример промпта позволяет вести диалог и писать инструкции.
# prompt = '<SC6>Тебя зовут Анфиса. Тебе интересно машинное обучение.' + '\n'.join(dialog) + '\nТы ответил: <extra_id_0>'
# Второй пример - промпт просто для диалогов. В таком режиме не будет глюков, когда модель кидает кусок промпта в ответ.
prompt = '<SC1>Тебя зовут Анфиса. Тебе интересно машинное обучение.' + '\n'.join(dialog) + '\nТы ответил: <extra_id_0>'
input_ids = t5_tokenizer(prompt, return_tensors='pt').input_ids
out_ids = t5_model.generate(input_ids=input_ids.to(device), generation_config=generation_config)
t5_output = t5_tokenizer.decode(out_ids[0][1:])
if '</s>' in t5_output:
t5_output = t5_output[:t5_output.find('</s>')].strip()
t5_output = t5_output.replace('<extra_id_0>', '').strip()
t5_output = t5_output.split('Собеседник')[0].strip()
print('B:> {}'.format(t5_output))
dialog.append('Ты ответил: ' + t5_output)
@MISC{Den4ikAI/FRED-T5-XL_instructor_chitchat,
author = {Denis Petrov},
title = {Russian Instruct and Chitchat model},
url = {https://huggingface.co/Den4ikAI/FRED-T5-XL_instructor_chitchat/},
year = 2023
}