--- license: mit --- ## Usage ``` def qa(doc, q): doc = doc.replace('\n',' ') q = q.replace('\n',' ') q_pr = f'Опираясь на информацию: {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("","") ans_sqs = sent_tokenize(out, language="russian") ans = ' '.join(ans_sqs[:3]) return ans.split('Ответ:')[0].split('Вопрос:')[0] ```