cuneytkaya commited on
Commit
2454f33
1 Parent(s): a8fd2c8

requirements.txt

Browse files

transformers
torch
gradio

Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
3
+
4
+
5
+ model_name = "cuneytkaya/fine-tuned-t5-small-turkish-mmlu"
6
+ tokenizer = T5Tokenizer.from_pretrained(model_name)
7
+ model = T5ForConditionalGeneration.from_pretrained(model_name)
8
+
9
+ def generate_answer(question):
10
+ input_text = f"Soru: {question}"
11
+ inputs = tokenizer(input_text, return_tensors="pt")
12
+ outputs = model.generate(**inputs)
13
+ answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
14
+ return answer
15
+
16
+ # Gradio arayüzü
17
+ interface = gr.Interface(
18
+ fn=generate_answer,
19
+ inputs="text",
20
+ outputs="text",
21
+ title="Turkish Exam Question Answering Model",
22
+ description="This model answers questions from Turkish academic exams like KPSS, TUS, etc.",
23
+ )
24
+
25
+ interface.launch()