Sugamdeol commited on
Commit
6f43e4f
1 Parent(s): 8ed9c1d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
3
+
4
+ # Load the model and tokenizer
5
+ model_name = "google/flan-t5-base" # Free LLM from Hugging Face
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
8
+
9
+ def solve_math_problem(problem):
10
+ inputs = tokenizer.encode(problem, return_tensors="pt")
11
+ outputs = model.generate(inputs, max_length=500)
12
+ result = tokenizer.decode(outputs[0], skip_special_tokens=True)
13
+
14
+ # Breaking it down to step-by-step
15
+ steps = "Step-by-Step: " + result
16
+ return steps
17
+
18
+ # Gradio interface
19
+ iface = gr.Interface(
20
+ fn=solve_math_problem,
21
+ inputs="text",
22
+ outputs="text",
23
+ title="Maths Step-by-Step Solver with LLM",
24
+ description="Enter a maths problem and get a step-by-step solution using LLM."
25
+ )
26
+
27
+ iface.launch()