cllatMTK commited on
Commit
163d2e6
1 Parent(s): 5885208

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -33
app.py CHANGED
@@ -45,7 +45,7 @@ HEADERS = {
45
  MAX_SEC = 30
46
  MAX_INPUT_LENGTH = 5000
47
 
48
- tokenizer = AutoTokenizer.from_pretrained("MediaTek-Research/Breexe-8x7B-Instruct-v0_1", use_auth_token=os.environ.get("HF_TOKEN"))
49
 
50
  def insert_to_db(prompt, response, temperature, top_p):
51
  try:
@@ -95,12 +95,30 @@ def refusal_condition(query):
95
  with gr.Blocks() as demo:
96
  gr.Markdown(DESCRIPTION)
97
 
98
- system_prompt = gr.Textbox(label='System prompt',
99
- value=DEFAULT_SYSTEM_PROMPT,
100
- lines=1)
101
-
102
- with gr.Accordion(label='Advanced options', open=False):
 
 
 
 
 
 
 
103
 
 
 
 
 
 
 
 
 
 
 
 
104
  max_new_tokens = gr.Slider(
105
  label='Max new tokens',
106
  minimum=32,
@@ -111,7 +129,7 @@ with gr.Blocks() as demo:
111
  temperature = gr.Slider(
112
  label='Temperature',
113
  minimum=0.01,
114
- maximum=0.5,
115
  step=0.01,
116
  value=0.01,
117
  )
@@ -122,29 +140,13 @@ with gr.Blocks() as demo:
122
  step=0.01,
123
  value=0.01,
124
  )
125
-
126
- chatbot = gr.Chatbot()
127
- with gr.Row():
128
- msg = gr.Textbox(
129
- container=False,
130
- show_label=False,
131
- placeholder='Type a message...',
132
- scale=10,
133
- lines=6
134
  )
135
- submit_button = gr.Button('Submit',
136
- variant='primary',
137
- scale=1,
138
- min_width=0)
139
-
140
- with gr.Row():
141
- retry_button = gr.Button('🔄 Retry', variant='secondary')
142
- undo_button = gr.Button('↩️ Undo', variant='secondary')
143
- clear = gr.Button('🗑️ Clear', variant='secondary')
144
-
145
- saved_input = gr.State()
146
-
147
-
148
 
149
 
150
  def user(user_message, history):
@@ -184,7 +186,7 @@ with gr.Blocks() as demo:
184
  # start_time = time.time()
185
 
186
 
187
- def bot(history, max_new_tokens, temperature, top_p, system_prompt):
188
  chat_data = []
189
  system_prompt = system_prompt.strip()
190
  if system_prompt:
@@ -206,13 +208,19 @@ with gr.Blocks() as demo:
206
  yield history
207
  else:
208
  data = {
209
- "model_type": "breexe-8x7b-instruct-v01",
210
  "prompt": str(message),
211
  "parameters": {
212
  "temperature": float(temperature),
213
  "top_p": float(top_p),
214
  "max_new_tokens": int(max_new_tokens),
215
- "repetition_penalty": 1.1
 
 
 
 
 
 
216
  }
217
  }
218
 
@@ -248,6 +256,7 @@ with gr.Blocks() as demo:
248
  temperature,
249
  top_p,
250
  system_prompt,
 
251
  ],
252
  outputs=chatbot
253
  )
@@ -261,6 +270,7 @@ with gr.Blocks() as demo:
261
  temperature,
262
  top_p,
263
  system_prompt,
 
264
  ],
265
  outputs=chatbot
266
  )
@@ -300,6 +310,7 @@ with gr.Blocks() as demo:
300
  temperature,
301
  top_p,
302
  system_prompt,
 
303
  ],
304
  outputs=chatbot,
305
  )
@@ -322,5 +333,5 @@ with gr.Blocks() as demo:
322
 
323
  gr.Markdown(LICENSE)
324
 
325
- demo.queue(concurrency_count=4, max_size=128)
326
  demo.launch()
 
45
  MAX_SEC = 30
46
  MAX_INPUT_LENGTH = 5000
47
 
48
+ tokenizer = AutoTokenizer.from_pretrained("MediaTek-Research/Breeze-7B-Instruct-v0_1")
49
 
50
  def insert_to_db(prompt, response, temperature, top_p):
51
  try:
 
95
  with gr.Blocks() as demo:
96
  gr.Markdown(DESCRIPTION)
97
 
98
+ chatbot = gr.Chatbot()
99
+ with gr.Row():
100
+ msg = gr.Textbox(
101
+ container=False,
102
+ show_label=False,
103
+ placeholder='Type a message...',
104
+ scale=10,
105
+ )
106
+ submit_button = gr.Button('Submit',
107
+ variant='primary',
108
+ scale=1,
109
+ min_width=0)
110
 
111
+ with gr.Row():
112
+ retry_button = gr.Button('🔄 Retry', variant='secondary')
113
+ undo_button = gr.Button('↩️ Undo', variant='secondary')
114
+ clear = gr.Button('🗑️ Clear', variant='secondary')
115
+
116
+ saved_input = gr.State()
117
+
118
+ with gr.Accordion(label='Advanced options', open=False):
119
+ system_prompt = gr.Textbox(label='System prompt',
120
+ value=DEFAULT_SYSTEM_PROMPT,
121
+ lines=6)
122
  max_new_tokens = gr.Slider(
123
  label='Max new tokens',
124
  minimum=32,
 
129
  temperature = gr.Slider(
130
  label='Temperature',
131
  minimum=0.01,
132
+ maximum=1.0,
133
  step=0.01,
134
  value=0.01,
135
  )
 
140
  step=0.01,
141
  value=0.01,
142
  )
143
+ repetition_penalty = gr.Slider(
144
+ label='Repetition Penalty',
145
+ minimum=0.1,
146
+ maximum=2,
147
+ step=0.01,
148
+ value=1.1,
 
 
 
149
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
 
152
  def user(user_message, history):
 
186
  # start_time = time.time()
187
 
188
 
189
+ def bot(history, max_new_tokens, temperature, top_p, system_prompt, repetition_penalty):
190
  chat_data = []
191
  system_prompt = system_prompt.strip()
192
  if system_prompt:
 
208
  yield history
209
  else:
210
  data = {
211
+ "model_type": "breeze-7b-instruct-v10",
212
  "prompt": str(message),
213
  "parameters": {
214
  "temperature": float(temperature),
215
  "top_p": float(top_p),
216
  "max_new_tokens": int(max_new_tokens),
217
+ "repetition_penalty": float(repetition_penalty),
218
+
219
+ "num_beams":1, # w/o beam search
220
+ "typical_p":0.99,
221
+ "top_k":0, # w/o top_k
222
+ "do_sample": True,
223
+ "min_length":1,
224
  }
225
  }
226
 
 
256
  temperature,
257
  top_p,
258
  system_prompt,
259
+ repetition_penalty,
260
  ],
261
  outputs=chatbot
262
  )
 
270
  temperature,
271
  top_p,
272
  system_prompt,
273
+ repetition_penalty,
274
  ],
275
  outputs=chatbot
276
  )
 
310
  temperature,
311
  top_p,
312
  system_prompt,
313
+ repetition_penalty,
314
  ],
315
  outputs=chatbot,
316
  )
 
333
 
334
  gr.Markdown(LICENSE)
335
 
336
+ demo.queue(concurrency_count=2, max_size=128)
337
  demo.launch()