DrDavis commited on
Commit
dd37249
·
verified ·
1 Parent(s): 0f43562

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ MODEL_ID = "google/flan-t5-small"
5
+ pipe = pipeline("text2text-generation", model=MODEL_ID)
6
+
7
+ def infer(prompt, max_new_tokens=128, temperature=0.7, top_p=0.9):
8
+ if not prompt.strip():
9
+ return "Please type something to generate."
10
+ out = pipe(prompt, max_new_tokens=int(max_new_tokens), do_sample=True, temperature=float(temperature), top_p=float(top_p))
11
+ return out[0]["generated_text"]
12
+
13
+ demo = gr.Interface(fn=infer, inputs=[gr.Textbox(lines=3, label="Instruction"), gr.Slider(16,256,128,step=8,label="Max new tokens"), gr.Slider(0,1.5,0.7,step=0.05,label="Temperature"), gr.Slider(0.1,1.0,0.9,step=0.05,label="Top‑p")], outputs=gr.Textbox(lines=8, label="Output"), title="Mini LLM (Local)")
14
+ demo.launch()