Go-Raw commited on
Commit
899ccdc
Β·
verified Β·
1 Parent(s): d287a82

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -14
app.py CHANGED
@@ -1,36 +1,41 @@
1
- from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
2
  import gradio as gr
3
 
4
- model_name = "EleutherAI/gpt-neo-1.3B"
5
  tokenizer = AutoTokenizer.from_pretrained(model_name)
6
- model = AutoModelForCausalLM.from_pretrained(model_name)
7
- pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
8
 
 
9
  personas = {
10
- "🟒 Optimist": "Give an optimistic argument with 2 benefits and one example.",
11
- "πŸ”΄ Pessimist": "Give a critical argument with 2 drawbacks and one example.",
12
- "🟑 Neutral": "List pros and cons and give a neutral summary."
13
  }
14
 
15
  def generate_debate(topic):
16
  results = []
17
  for label, instruction in personas.items():
18
  prompt = (
19
- f"Debate Topic: {topic}\n"
20
- f"Persona: {label}\n"
21
  f"{instruction}\n"
22
- f"Write 3–4 sentences."
23
  )
24
- output = pipe(prompt, max_new_tokens=150, temperature=0.7)[0]['generated_text']
25
- results.append(f"### {label}\n{output.strip()}")
 
 
 
 
26
  return "\n\n".join(results)
27
 
28
  demo = gr.Interface(
29
  fn=generate_debate,
30
  inputs=gr.Textbox(label="Debate Topic"),
31
  outputs=gr.Markdown(),
32
- title="πŸŽ™οΈ Debate Simulator with GPT-Neo",
33
- description="Debate with Optimist, Pessimist & Neutral perspectives using GPT-Neo-1.3B."
34
  )
35
 
36
  demo.launch()
 
1
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
2
  import gradio as gr
3
 
4
+ model_name = "google/flan-t5-base"
5
  tokenizer = AutoTokenizer.from_pretrained(model_name)
6
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
7
+ pipe = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
8
 
9
+ # New, more specific instructions
10
  personas = {
11
+ "🟒 Optimist": "Give a detailed, optimistic argument with at least two clear benefits and an example.",
12
+ "πŸ”΄ Pessimist": "Give a detailed, critical argument highlighting at least two risks or drawbacks and an example.",
13
+ "🟑 Neutral": "Provide a balanced perspective. Start by listing pros, then cons, and conclude with a neutral summary."
14
  }
15
 
16
  def generate_debate(topic):
17
  results = []
18
  for label, instruction in personas.items():
19
  prompt = (
20
+ f"You are an experienced debater.\n"
21
+ f"Debate Topic: \"{topic}\"\n"
22
  f"{instruction}\n"
23
+ f"Write at least 3–4 sentences."
24
  )
25
+ response = pipe(
26
+ prompt,
27
+ max_new_tokens=180, # increased from 120
28
+ temperature=0.7
29
+ )[0]['generated_text'].strip()
30
+ results.append(f"### {label}\n{response}")
31
  return "\n\n".join(results)
32
 
33
  demo = gr.Interface(
34
  fn=generate_debate,
35
  inputs=gr.Textbox(label="Debate Topic"),
36
  outputs=gr.Markdown(),
37
+ title="πŸŽ™οΈ Multi-Agent Debate Simulator",
38
+ description="Debates with Optimist, Pessimist & Neutral perspectives using FLAN-T5-Base."
39
  )
40
 
41
  demo.launch()