FredZhang7
commited on
add _instruct suffix
Browse files
app.py
CHANGED
@@ -113,28 +113,7 @@ def alternative(chatbot, history):
|
|
113 |
|
114 |
with gr.Blocks(title=title) as demo:
|
115 |
gr.HTML(f"<div style=\"text-align: center;\">\n<h1>🌍World - {title}</h1>\n</div>")
|
116 |
-
|
117 |
-
with gr.Tab("Instruct mode"):
|
118 |
-
gr.Markdown(f"100% RNN RWKV-LM **trained on 100+ natural languages**. Demo limited to ctxlen {ctx_limit}. For best results, <b>keep your prompt short and clear</b>.")
|
119 |
-
with gr.Row():
|
120 |
-
with gr.Column():
|
121 |
-
instruction = gr.Textbox(lines=2, label="Instruction", value='東京で訪れるべき素晴らしい場所とその紹介をいくつか挙げてください。')
|
122 |
-
input_instruct = gr.Textbox(lines=2, label="Input", placeholder="")
|
123 |
-
token_count_instruct = gr.Slider(10, 512, label="Max Tokens", step=10, value=333)
|
124 |
-
temperature_instruct = gr.Slider(0.2, 2.0, label="Temperature", step=0.1, value=1.2)
|
125 |
-
top_p_instruct = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.3)
|
126 |
-
presence_penalty_instruct = gr.Slider(0.0, 1.0, label="Presence Penalty", step=0.1, value=0)
|
127 |
-
count_penalty_instruct = gr.Slider(0.0, 1.0, label="Count Penalty", step=0.1, value=0.7)
|
128 |
-
with gr.Column():
|
129 |
-
with gr.Row():
|
130 |
-
submit = gr.Button("Submit", variant="primary")
|
131 |
-
clear = gr.Button("Clear", variant="secondary")
|
132 |
-
output = gr.Textbox(label="Output", lines=5)
|
133 |
-
data = gr.Dataset(components=[instruction, input_instruct, token_count_instruct, temperature_instruct, top_p_instruct, presence_penalty_instruct, count_penalty_instruct], samples=examples, label="Example Instructions", headers=["Instruction", "Input", "Max Tokens", "Temperature", "Top P", "Presence Penalty", "Count Penalty"])
|
134 |
-
submit.click(evaluate, [instruction, input, token_count, temperature, top_p, presence_penalty, count_penalty], [output])
|
135 |
-
clear.click(lambda: None, [], [output])
|
136 |
-
data.click(lambda x: x, [data], [instruction, input_instruct, token_count_instruct, temperature_instruct, top_p_instruct, presence_penalty_instruct, count_penalty_instruct])
|
137 |
-
|
138 |
with gr.Tab("Chat mode"):
|
139 |
with gr.Row():
|
140 |
chatbot = gr.Chatbot()
|
@@ -172,11 +151,32 @@ with gr.Blocks(title=title) as demo:
|
|
172 |
history[-1][1] = response
|
173 |
return history
|
174 |
|
175 |
-
|
176 |
msg.submit(user_msg, [msg, chatbot], [msg, chatbot], queue=False).then(
|
177 |
chat, chatbot, chatbot, api_name="chat"
|
178 |
)
|
179 |
clear.click(clear_chat, None, [chatbot], queue=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
|
181 |
demo.queue(max_size=10)
|
182 |
demo.launch(share=False)
|
|
|
113 |
|
114 |
with gr.Blocks(title=title) as demo:
|
115 |
gr.HTML(f"<div style=\"text-align: center;\">\n<h1>🌍World - {title}</h1>\n</div>")
|
116 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
with gr.Tab("Chat mode"):
|
118 |
with gr.Row():
|
119 |
chatbot = gr.Chatbot()
|
|
|
151 |
history[-1][1] = response
|
152 |
return history
|
153 |
|
|
|
154 |
msg.submit(user_msg, [msg, chatbot], [msg, chatbot], queue=False).then(
|
155 |
chat, chatbot, chatbot, api_name="chat"
|
156 |
)
|
157 |
clear.click(clear_chat, None, [chatbot], queue=False)
|
158 |
+
|
159 |
+
with gr.Tab("Instruct mode"):
|
160 |
+
gr.Markdown(f"100% RNN RWKV-LM **trained on 100+ natural languages**. Demo limited to ctxlen {ctx_limit}. For best results, <b>keep your prompt short and clear</b>.")
|
161 |
+
with gr.Row():
|
162 |
+
with gr.Column():
|
163 |
+
instruction = gr.Textbox(lines=2, label="Instruction", value='東京で訪れるべき素晴らしい場所とその紹介をいくつか挙げてください。')
|
164 |
+
input_instruct = gr.Textbox(lines=2, label="Input", placeholder="")
|
165 |
+
token_count_instruct = gr.Slider(10, 512, label="Max Tokens", step=10, value=333)
|
166 |
+
temperature_instruct = gr.Slider(0.2, 2.0, label="Temperature", step=0.1, value=1.2)
|
167 |
+
top_p_instruct = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.3)
|
168 |
+
presence_penalty_instruct = gr.Slider(0.0, 1.0, label="Presence Penalty", step=0.1, value=0)
|
169 |
+
count_penalty_instruct = gr.Slider(0.0, 1.0, label="Count Penalty", step=0.1, value=0.7)
|
170 |
+
with gr.Column():
|
171 |
+
with gr.Row():
|
172 |
+
submit = gr.Button("Submit", variant="primary")
|
173 |
+
clear = gr.Button("Clear", variant="secondary")
|
174 |
+
output = gr.Textbox(label="Output", lines=5)
|
175 |
+
data = gr.Dataset(components=[instruction, input_instruct, token_count_instruct, temperature_instruct, top_p_instruct, presence_penalty_instruct, count_penalty_instruct], samples=examples, label="Example Instructions", headers=["Instruction", "Input", "Max Tokens", "Temperature", "Top P", "Presence Penalty", "Count Penalty"])
|
176 |
+
submit.click(evaluate, [instruction, input_instruct, token_count_instruct, temperature_instruct, top_p_instruct, presence_penalty_instruct, count_penalty_instruct], [output])
|
177 |
+
clear.click(lambda: None, [], [output])
|
178 |
+
data.click(lambda x: x, [data], [instruction, input_instruct, token_count_instruct, temperature_instruct, top_p_instruct, presence_penalty_instruct, count_penalty_instruct])
|
179 |
+
|
180 |
|
181 |
demo.queue(max_size=10)
|
182 |
demo.launch(share=False)
|