Usage
def qa(doc, q):
doc = doc.replace('\n',' ')
q = q.replace('\n',' ')
q_pr = f'<SC6>Опираясь на информацию: {doc}\n ответь на вопрос: \"{q}\".\n Ответ: '
data_inp = tokenizer(q_pr, return_tensors="pt").to('cuda:0')
return data_inp
def generate(doc, q):
t = qa(doc, q)
output_ids = model.generate(
**t, do_sample=False, temperature=0.0, max_new_tokens=512, repetition_penalty=1, no_repeat_ngram_size=8
)[0]
out = tokenizer.decode(output_ids.tolist(), skip_special_tokens=True)
out = out.replace("<extra_id_0>","")
ans_sqs = sent_tokenize(out, language="russian")
ans = ' '.join(ans_sqs[:3])
return ans.split('Ответ:')[0].split('Вопрос:')[0]
- Downloads last month
- 1
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social
visibility and check back later, or deploy to Inference Endpoints (dedicated)
instead.