cedpsam commited on
Commit
1c2bc1d
·
1 Parent(s): bc192d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -4
app.py CHANGED
@@ -33,7 +33,7 @@ def format_prompt(message, history):
33
  return prompt
34
 
35
  def generate(
36
- prompt, history, temperature=0.9, top_p=0.95,
37
  ):
38
 
39
  temperature = float(temperature)
@@ -49,9 +49,10 @@ def generate(
49
  output = ""
50
  output=llm(formatted_prompt,
51
  temperature=temperature,
52
- max_tokens=30,
 
53
  top_p=top_p,)
54
- output=formatted_prompt+"ans:"+output
55
  # for response in stream:
56
  # output += response.token.text
57
  # yield output
@@ -78,6 +79,24 @@ additional_inputs=[
78
  interactive=True,
79
  info="Higher values sample more low-probability tokens",
80
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  ]
83
 
@@ -99,4 +118,4 @@ with gr.Blocks(css=css) as demo:
99
  examples=[["What is the secret to life?"], ["Write me a recipe for pancakes."]]
100
  )
101
 
102
- demo.queue().launch(debug=True)
 
33
  return prompt
34
 
35
  def generate(
36
+ prompt, history, temperature=0.9, top_p=0.95, max_new_tokens=256,repetition_penalty=1.0,
37
  ):
38
 
39
  temperature = float(temperature)
 
49
  output = ""
50
  output=llm(formatted_prompt,
51
  temperature=temperature,
52
+ max_tokens=max_new_tokens,
53
+ repeat_penalty=repetition_penalty,
54
  top_p=top_p,)
55
+ # output=formatted_prompt+"ans:"+output
56
  # for response in stream:
57
  # output += response.token.text
58
  # yield output
 
79
  interactive=True,
80
  info="Higher values sample more low-probability tokens",
81
  ),
82
+ gr.Slider(
83
+ label="Max new tokens",
84
+ value=256,
85
+ minimum=0,
86
+ maximum=1048,
87
+ step=64,
88
+ interactive=True,
89
+ info="The maximum numbers of new tokens",
90
+ ),
91
+ gr.Slider(
92
+ label="Repetition penalty",
93
+ value=1.2,
94
+ minimum=1.0,
95
+ maximum=2.0,
96
+ step=0.05,
97
+ interactive=True,
98
+ info="Penalize repeated tokens",
99
+ )
100
 
101
  ]
102
 
 
118
  examples=[["What is the secret to life?"], ["Write me a recipe for pancakes."]]
119
  )
120
 
121
+ demo.queue(max_size=20).launch(debug=True)