Spaces:
Runtime error
Runtime error
File size: 772 Bytes
ac627d3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
from transformers import MT5ForConditionalGeneration, MT5Tokenizer
model = MT5ForConditionalGeneration.from_pretrained("./model")
tokenizer = MT5Tokenizer.from_pretrained("google/mt5-small")
def ask(question, context):
input_text = f"Сұрақ: {question} Контекст: {context}"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
output = model.generate(input_ids, max_length=100)
return tokenizer.decode(output[0], skip_special_tokens=True)
context = """Мәліметтер қоры дегеніміз – белгілі бір сипаттамасы бар, өзара байланыса сақталатын ақпараттар жиынтығы."""
print(ask("Мәліметтер қоры дегеніміз не?", context))
|