tjido commited on
Commit
2e1ef2f
·
verified ·
1 Parent(s): de105d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -1,18 +1,20 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
- # ✅ Use Falcon-7B-Instruct now that you're on GPU
5
- generator = pipeline("text-generation", model="tiiuae/falcon-7b-instruct", device_map="auto")
6
 
7
  def interpret_prompt(prompt):
8
  system_prompt = (
9
- f"A user has typed this prompt to an AI: \"{prompt}\"\n"
10
- "List 3 different ways the AI could interpret this prompt, clearly labeled.\n"
11
- "Then give 1 tip for how the user could improve their prompt to be more specific or useful."
 
12
  )
13
 
14
- output = generator(system_prompt, max_new_tokens=300, do_sample=True, temperature=0.7)[0]['generated_text']
15
 
 
16
  if "Tip" in output:
17
  parts = output.split("Tip", 1)
18
  interpretations = parts[0].strip()
 
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
+ # Upgrade to FLAN-UL2 — more detailed, better reasoning
5
+ generator = pipeline("text2text-generation", model="google/flan-ul2")
6
 
7
  def interpret_prompt(prompt):
8
  system_prompt = (
9
+ f"A user gave this prompt to an AI: \"{prompt}\"\n"
10
+ "What are three different ways the AI could interpret this prompt?\n"
11
+ "Number each one.\n"
12
+ "Then give one short tip for how the user could improve their prompt."
13
  )
14
 
15
+ output = generator(system_prompt, max_length=400)[0]['generated_text']
16
 
17
+ # Optional formatting fix
18
  if "Tip" in output:
19
  parts = output.split("Tip", 1)
20
  interpretations = parts[0].strip()