ruT5_q_a
A fine-tuned version of ai-forever/ruT5-base
for the question answering task in Russian.
The model takes a text (context) and a question about it as input, and generates an answer extracted or paraphrased from the context.
Usage
from transformers import AutoTokenizer, T5ForConditionalGeneration
qa_checkpoint = "r1char9/ruT5_q_a"
qa_model = T5ForConditionalGeneration.from_pretrained(qa_checkpoint)
qa_tokenizer = AutoTokenizer.from_pretrained(qa_checkpoint)
def question_answering(context, question):
tokenized = qa_tokenizer(context, question, return_tensors="pt")
output = qa_model.generate(**tokenized)
return qa_tokenizer.decode(output[0], skip_special_tokens=True)
context = "Нарисуй изображение Томаса Шелби"
question = "Что нужно нарисовать?"
answer = question_answering(context, question)
# 'изображение Томаса Шелби'
Input format
The model expects a (context, question) pair, passed to the tokenizer as
two positional arguments — tokenizer(context, question, ...). The
tokenizer combines them into a single sequence using T5's own separator
scheme.
Limitations
- Answer quality directly depends on how well the question relates to the provided context; questions with no answer present in the context may lead to undefined or nonsensical generations.
- The model has no access to external knowledge — it only works with the context passed as input (extractive/abstractive QA over the given context, not knowledge-based QA).