WuChengyue commited on
Commit
1d22c5e
1 Parent(s): eb727b5

update chatbot

Browse files
__pycache__/model.cpython-39.pyc ADDED
Binary file (2.58 kB). View file
 
app.py CHANGED
@@ -53,27 +53,13 @@ def instruct(instruction, max_token_output=1024):
53
  input_ids = tokenizer(input_text, return_tensors='pt', truncation=False)
54
  input_ids["input_ids"] = input_ids["input_ids"].cuda()
55
  input_ids["attention_mask"] = input_ids["attention_mask"].cuda()
56
- generation_kwargs = dict(input_ids, streamer=streamer, max_new_tokens=max_token_output)
57
  thread = Thread(target=model.generate, kwargs=generation_kwargs)
58
  thread.start()
59
  return streamer
60
 
61
 
62
  with gr.Blocks() as demo:
63
- # recreating the original qa demo in blocks
64
- with gr.Tab("QA Demo"):
65
- with gr.Row():
66
- instruction = gr.Textbox(label="Input")
67
- output = gr.Textbox(label="Output")
68
- greet_btn = gr.Button("Submit")
69
- def yield_instruct(instruction):
70
- # quick prompt hack:
71
- instruction = "<|user|>\n" + instruction + "\n<|assistant|>\n"
72
- output = ""
73
- for token in instruct(instruction):
74
- output += token
75
- yield output
76
- greet_btn.click(fn=yield_instruct, inputs=[instruction], outputs=output, api_name="greet")
77
  # chatbot-style model
78
  with gr.Tab("Chatbot"):
79
  chatbot = gr.Chatbot([], elem_id="chatbot")
 
53
  input_ids = tokenizer(input_text, return_tensors='pt', truncation=False)
54
  input_ids["input_ids"] = input_ids["input_ids"].cuda()
55
  input_ids["attention_mask"] = input_ids["attention_mask"].cuda()
56
+ generation_kwargs = dict(input_ids, streamer=streamer, max_new_tokens=max_token_output, do_sample=False)
57
  thread = Thread(target=model.generate, kwargs=generation_kwargs)
58
  thread.start()
59
  return streamer
60
 
61
 
62
  with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  # chatbot-style model
64
  with gr.Tab("Chatbot"):
65
  chatbot = gr.Chatbot([], elem_id="chatbot")
gradio_cached_examples/20/Chatbot/tmp02mduth2.json ADDED
@@ -0,0 +1 @@
 
 
1
+ [["Can you explain briefly what Python is good for?", "I'm asking for a general answer, as Python is used in many different fields for many different purposes."]]
gradio_cached_examples/20/Chatbot/tmp_dz2r23_.json ADDED
@@ -0,0 +1 @@
 
 
1
+ [["How can I display a grid of images in SwiftUI?", ""]]
gradio_cached_examples/20/Chatbot/tmpsclequs1.json ADDED
@@ -0,0 +1 @@
 
 
1
+ [["What is the Fibonacci sequence?", ""]]
gradio_cached_examples/20/log.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ component 0,Chatbot,flag,username,timestamp
2
+ ,/home/chengyue/Documents/LLaMA-Pro-8B-Instruct-Chat/gradio_cached_examples/20/Chatbot/tmpsclequs1.json,,,2024-01-06 14:55:22.452760
3
+ ,/home/chengyue/Documents/LLaMA-Pro-8B-Instruct-Chat/gradio_cached_examples/20/Chatbot/tmp02mduth2.json,,,2024-01-06 14:55:23.044483
4
+ ,/home/chengyue/Documents/LLaMA-Pro-8B-Instruct-Chat/gradio_cached_examples/20/Chatbot/tmp_dz2r23_.json,,,2024-01-06 14:55:23.083752