yiping commited on
Commit
43e0470
·
1 Parent(s): 61b9067

Initial commit

Browse files
Files changed (2) hide show
  1. app.py +13 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py — local chat with FLAN-T5 (no token needed)
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+ pipe = pipeline("text2text-generation",
5
+ model="google/flan-t5-base")
6
+ def chat(message, history):
7
+ # prepend a simple instruction; keep short history to avoid long inputs
8
+ prompt = f"Respond helpfully to the user.\nUser:{message}\nAssistant:"
9
+ out = pipe(prompt, max_new_tokens=256,temperature=0.7)[0]["generated_text"]
10
+ return out
11
+ demo = gr.ChatInterface(chat, title="FLAN-T5 Chat (no token)")
12
+ if __name__ == "__main__":
13
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch