BlinkDL commited on
Commit
ab56f98
1 Parent(s): b454fd9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -38
app.py CHANGED
@@ -87,7 +87,8 @@ def evaluate(
87
 
88
  gpu_info = nvmlDeviceGetMemoryInfo(gpu_h)
89
  print(f'vram {gpu_info.total} used {gpu_info.used} free {gpu_info.free}')
90
-
 
91
  gc.collect()
92
  torch.cuda.empty_cache()
93
  yield out_str.strip()
@@ -244,7 +245,7 @@ def chat(
244
  with gr.Blocks(title=title) as demo:
245
  gr.HTML(f"<div style=\"text-align: center;\">\n<h1>🐦Raven - {title}</h1>\n</div>")
246
  with gr.Tab("Instruct mode"):
247
- gr.Markdown(f"Raven is [RWKV 7B](https://github.com/BlinkDL/ChatRWKV) 100% RNN [RWKV-LM](https://github.com/BlinkDL/RWKV-LM) finetuned to follow instructions. *** Please try examples first (bottom of page) *** (edit them to use your question). Demo limited to ctxlen {ctx_limit}. Finetuned on alpaca, gpt4all, codealpaca and more. For best results, *** keep you prompt short and clear ***. <b>UPDATE: now with Chat (see above, as a tab)</b>.")
248
  with gr.Row():
249
  with gr.Column():
250
  instruction = gr.Textbox(lines=2, label="Instruction", value="Tell me about ravens.")
@@ -264,42 +265,42 @@ with gr.Blocks(title=title) as demo:
264
  clear.click(lambda: None, [], [output])
265
  data.click(lambda x: x, [data], [instruction, input, token_count, temperature, top_p, presence_penalty, count_penalty])
266
 
267
- with gr.Tab("Chat (Experimental - Might be buggy - use ChatRWKV for reference)"):
268
- gr.Markdown(f'''<b>*** The length of response is restricted in this demo. Use ChatRWKV for longer generations. ***</b> Say "go on" or "continue" can sometimes continue the response. If you'd like to edit the scenario, make sure to follow the exact same format: empty lines between (and only between) different speakers. Changes only take effect after you press [Clear]. <b>The default "Bob" & "Alice" names work the best.</b>''', label="Description")
269
- with gr.Row():
270
- with gr.Column():
271
- chatbot = gr.Chatbot()
272
- state = gr.State()
273
- message = gr.Textbox(label="Message", value="Write me a python code to land on moon.")
274
- with gr.Row():
275
- send = gr.Button("Send", variant="primary")
276
- alt = gr.Button("Alternative", variant="secondary")
277
- clear = gr.Button("Clear", variant="secondary")
278
- with gr.Column():
279
- with gr.Row():
280
- user_name = gr.Textbox(lines=1, max_lines=1, label="User Name", value="Bob")
281
- bot_name = gr.Textbox(lines=1, max_lines=1, label="Bot Name", value="Alice")
282
- prompt = gr.Textbox(lines=10, max_lines=50, label="Scenario", value=chat_intro)
283
- temperature = gr.Slider(0.2, 2.0, label="Temperature", step=0.1, value=1.2)
284
- top_p = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.5)
285
- presence_penalty = gr.Slider(0.0, 1.0, label="Presence Penalty", step=0.1, value=0.4)
286
- count_penalty = gr.Slider(0.0, 1.0, label="Count Penalty", step=0.1, value=0.4)
287
- chat_inputs = [
288
- prompt,
289
- user_name,
290
- bot_name,
291
- chatbot,
292
- state,
293
- temperature,
294
- top_p,
295
- presence_penalty,
296
- count_penalty
297
- ]
298
- chat_outputs = [chatbot, state]
299
- message.submit(user, [message, chatbot], [message, chatbot], queue=False).then(chat, chat_inputs, chat_outputs)
300
- send.click(user, [message, chatbot], [message, chatbot], queue=False).then(chat, chat_inputs, chat_outputs)
301
- alt.click(alternative, [chatbot, state], [chatbot, state], queue=False).then(chat, chat_inputs, chat_outputs)
302
- clear.click(lambda: ([], None, ""), [], [chatbot, state, message], queue=False)
303
 
304
  demo.queue(concurrency_count=1, max_size=10)
305
  demo.launch(share=False)
 
87
 
88
  gpu_info = nvmlDeviceGetMemoryInfo(gpu_h)
89
  print(f'vram {gpu_info.total} used {gpu_info.used} free {gpu_info.free}')
90
+ del out
91
+ del state
92
  gc.collect()
93
  torch.cuda.empty_cache()
94
  yield out_str.strip()
 
245
  with gr.Blocks(title=title) as demo:
246
  gr.HTML(f"<div style=\"text-align: center;\">\n<h1>🐦Raven - {title}</h1>\n</div>")
247
  with gr.Tab("Instruct mode"):
248
+ gr.Markdown(f"Raven is [RWKV 7B](https://github.com/BlinkDL/ChatRWKV) 100% RNN [RWKV-LM](https://github.com/BlinkDL/RWKV-LM) finetuned to follow instructions. *** Please try examples first (bottom of page) *** (edit them to use your question). Demo limited to ctxlen {ctx_limit}. Finetuned on alpaca, gpt4all, codealpaca and more. For best results, *** keep you prompt short and clear ***. <b>UPDATE: now with Chat (see above, as a tab) ==> turn off as of now due to VRAM leak caused by buggy code.</b>.")
249
  with gr.Row():
250
  with gr.Column():
251
  instruction = gr.Textbox(lines=2, label="Instruction", value="Tell me about ravens.")
 
265
  clear.click(lambda: None, [], [output])
266
  data.click(lambda x: x, [data], [instruction, input, token_count, temperature, top_p, presence_penalty, count_penalty])
267
 
268
+ # with gr.Tab("Chat (Experimental - Might be buggy - use ChatRWKV for reference)"):
269
+ # gr.Markdown(f'''<b>*** The length of response is restricted in this demo. Use ChatRWKV for longer generations. ***</b> Say "go on" or "continue" can sometimes continue the response. If you'd like to edit the scenario, make sure to follow the exact same format: empty lines between (and only between) different speakers. Changes only take effect after you press [Clear]. <b>The default "Bob" & "Alice" names work the best.</b>''', label="Description")
270
+ # with gr.Row():
271
+ # with gr.Column():
272
+ # chatbot = gr.Chatbot()
273
+ # state = gr.State()
274
+ # message = gr.Textbox(label="Message", value="Write me a python code to land on moon.")
275
+ # with gr.Row():
276
+ # send = gr.Button("Send", variant="primary")
277
+ # alt = gr.Button("Alternative", variant="secondary")
278
+ # clear = gr.Button("Clear", variant="secondary")
279
+ # with gr.Column():
280
+ # with gr.Row():
281
+ # user_name = gr.Textbox(lines=1, max_lines=1, label="User Name", value="Bob")
282
+ # bot_name = gr.Textbox(lines=1, max_lines=1, label="Bot Name", value="Alice")
283
+ # prompt = gr.Textbox(lines=10, max_lines=50, label="Scenario", value=chat_intro)
284
+ # temperature = gr.Slider(0.2, 2.0, label="Temperature", step=0.1, value=1.2)
285
+ # top_p = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.5)
286
+ # presence_penalty = gr.Slider(0.0, 1.0, label="Presence Penalty", step=0.1, value=0.4)
287
+ # count_penalty = gr.Slider(0.0, 1.0, label="Count Penalty", step=0.1, value=0.4)
288
+ # chat_inputs = [
289
+ # prompt,
290
+ # user_name,
291
+ # bot_name,
292
+ # chatbot,
293
+ # state,
294
+ # temperature,
295
+ # top_p,
296
+ # presence_penalty,
297
+ # count_penalty
298
+ # ]
299
+ # chat_outputs = [chatbot, state]
300
+ # message.submit(user, [message, chatbot], [message, chatbot], queue=False).then(chat, chat_inputs, chat_outputs)
301
+ # send.click(user, [message, chatbot], [message, chatbot], queue=False).then(chat, chat_inputs, chat_outputs)
302
+ # alt.click(alternative, [chatbot, state], [chatbot, state], queue=False).then(chat, chat_inputs, chat_outputs)
303
+ # clear.click(lambda: ([], None, ""), [], [chatbot, state, message], queue=False)
304
 
305
  demo.queue(concurrency_count=1, max_size=10)
306
  demo.launch(share=False)