Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import T5Tokenizer, T5ForConditionalGeneration | |
model_name = "cuneytkaya/fine-tuned-t5-small-turkish-mmlu" | |
tokenizer = T5Tokenizer.from_pretrained(model_name) | |
model = T5ForConditionalGeneration.from_pretrained(model_name) | |
def generate_answer(question): | |
input_text = f"Soru: {question}" | |
inputs = tokenizer(input_text, return_tensors="pt") | |
outputs = model.generate(**inputs, max_length=50, num_beams=4, early_stopping=True) | |
answer = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
if "Cevap:" in answer: | |
return answer.split("Cevap:")[1].strip() | |
return answer | |
interface = gr.Interface( | |
fn=generate_answer, | |
inputs="text", | |
outputs="text", | |
title="Turkish Exam Question Answering Model", | |
description="This model answers questions from Turkish academic exams like KPSS, TUS, etc.", | |
) | |
interface.launch(share=True) | |