Spaces:
Runtime error
Runtime error
Tweak demo text & params
Browse files
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
-
title: StarChat
|
3 |
-
emoji:
|
4 |
colorFrom: pink
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
+
title: StarChat Playground
|
3 |
+
emoji: ⭐️💬
|
4 |
colorFrom: pink
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
app.py
CHANGED
@@ -34,7 +34,7 @@ if HF_TOKEN:
|
|
34 |
pass
|
35 |
|
36 |
repo = Repository(
|
37 |
-
local_dir="./data/", clone_from="
|
38 |
)
|
39 |
repo.git_pull()
|
40 |
|
@@ -71,7 +71,6 @@ def has_no_history(chatbot, history):
|
|
71 |
|
72 |
|
73 |
def generate(
|
74 |
-
# model,
|
75 |
system_message,
|
76 |
user_message,
|
77 |
chatbot,
|
@@ -126,7 +125,7 @@ def generate(
|
|
126 |
top_p=top_p,
|
127 |
repetition_penalty=repetition_penalty,
|
128 |
do_sample=True,
|
129 |
-
truncate=
|
130 |
seed=42,
|
131 |
stop_sequences=["<|end|>"],
|
132 |
)
|
@@ -149,52 +148,26 @@ def generate(
|
|
149 |
chat = [(history[i].strip(), history[i + 1].strip()) for i in range(0, len(history) - 1, 2)]
|
150 |
|
151 |
yield chat, history, user_message, ""
|
152 |
-
|
153 |
if HF_TOKEN and do_save:
|
154 |
try:
|
155 |
print("Pushing prompt and completion to the Hub")
|
156 |
save_inputs_and_outputs(prompt, output, generate_kwargs)
|
157 |
except Exception as e:
|
158 |
print(e)
|
159 |
-
|
160 |
return chat, history, user_message, ""
|
161 |
|
|
|
162 |
examples = [
|
163 |
"How can I write a Python function to generate the nth Fibonacci number?",
|
164 |
-
"
|
165 |
"How do I get the current date using shell commands? Explain how it works.",
|
166 |
"What's the meaning of life?",
|
167 |
"Write a function in Python to reverse words in a given string.",
|
168 |
]
|
169 |
|
170 |
|
171 |
-
# def regenerate(
|
172 |
-
# system_message,
|
173 |
-
# user_message,
|
174 |
-
# chatbot,
|
175 |
-
# history,
|
176 |
-
# temperature,
|
177 |
-
# top_k,
|
178 |
-
# top_p,
|
179 |
-
# max_new_tokens,
|
180 |
-
# repetition_penalty,
|
181 |
-
# do_save=True,
|
182 |
-
# ):
|
183 |
-
# # Do nothing if there's no history
|
184 |
-
# if has_no_history(chatbot, history):
|
185 |
-
# return (
|
186 |
-
# chatbot,
|
187 |
-
# history,
|
188 |
-
# user_message,
|
189 |
-
# "",
|
190 |
-
# )
|
191 |
-
|
192 |
-
# chatbot = chatbot[:-1]
|
193 |
-
# history = history[:-2]
|
194 |
-
|
195 |
-
# return generate(system_message, user_message, chatbot, history, temperature, top_k, top_p, max_new_tokens, repetition_penalty, do_save)
|
196 |
-
|
197 |
-
|
198 |
def clear_chat():
|
199 |
return [], []
|
200 |
|
@@ -205,7 +178,7 @@ def process_example(args):
|
|
205 |
return [x, y]
|
206 |
|
207 |
|
208 |
-
title = """<h1 align="center">⭐
|
209 |
custom_css = """
|
210 |
#banner-image {
|
211 |
display: block;
|
@@ -228,19 +201,17 @@ with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
|
|
228 |
gr.Image("StarCoderBanner.png", elem_id="banner-image", show_label=False)
|
229 |
with gr.Column():
|
230 |
gr.Markdown(
|
231 |
-
|
232 |
-
💻 This demo showcases an
|
233 |
-
|
234 |
-
🤗 With an enterprise-friendly license, 8,192 token context length, and fast large-batch inference via [multi-query attention](https://arxiv.org/abs/1911.02150), **StarCoder** is currently the best open-source choice for code-based applications.
|
235 |
-
|
236 |
📝 For more details, check out our [blog post]().
|
237 |
|
238 |
-
⚠️ **Intended Use**: this app and its [supporting model](https://huggingface.co/HuggingFaceH4/
|
239 |
|
240 |
-
⚠️ **Data Collection**: by default, we are collecting the prompts entered in this app to further improve and evaluate the model. Do NOT share any personal or sensitive information while using the app! You can opt out of this data collection by removing the checkbox below.
|
241 |
"""
|
242 |
-
|
243 |
-
|
244 |
with gr.Row():
|
245 |
do_save = gr.Checkbox(
|
246 |
value=True,
|
@@ -248,11 +219,11 @@ with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
|
|
248 |
info="You agree to the storage of your prompt and generated text for research and development purposes:",
|
249 |
)
|
250 |
with gr.Accordion(label="System Prompt", open=False, elem_id="parameters-accordion"):
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
with gr.Row():
|
257 |
with gr.Box():
|
258 |
output = gr.Markdown()
|
@@ -263,7 +234,7 @@ with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
|
|
263 |
user_message = gr.Textbox(placeholder="Enter your message here", show_label=False, elem_id="q-input")
|
264 |
with gr.Row():
|
265 |
send_button = gr.Button("Send", elem_id="send-btn", visible=True)
|
266 |
-
|
267 |
# regenerate_button = gr.Button("Regenerate", elem_id="send-btn", visible=True)
|
268 |
|
269 |
clear_chat_button = gr.Button("Clear chat", elem_id="clear-btn", visible=True)
|
@@ -298,7 +269,7 @@ with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
|
|
298 |
)
|
299 |
max_new_tokens = gr.Slider(
|
300 |
label="Max new tokens",
|
301 |
-
value=
|
302 |
minimum=0,
|
303 |
maximum=2048,
|
304 |
step=4,
|
@@ -327,7 +298,6 @@ with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
|
|
327 |
outputs=[output],
|
328 |
)
|
329 |
|
330 |
-
|
331 |
history = gr.State([])
|
332 |
# To clear out "message" input textbox and use this to regenerate message
|
333 |
last_user_message = gr.State("")
|
@@ -366,41 +336,24 @@ with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
|
|
366 |
outputs=[chatbot, history, last_user_message, user_message],
|
367 |
)
|
368 |
|
369 |
-
# regenerate_button.click(
|
370 |
-
# regenerate,
|
371 |
-
# inputs=[
|
372 |
-
# system_message,
|
373 |
-
# last_user_message,
|
374 |
-
# chatbot,
|
375 |
-
# history,
|
376 |
-
# temperature,
|
377 |
-
# top_k,
|
378 |
-
# top_p,
|
379 |
-
# max_new_tokens,
|
380 |
-
# repetition_penalty,
|
381 |
-
# do_save,
|
382 |
-
# ],
|
383 |
-
# outputs=[chatbot, history, last_user_message, user_message],
|
384 |
-
# )
|
385 |
-
|
386 |
clear_chat_button.click(clear_chat, outputs=[chatbot, history])
|
387 |
# share_button.click(None, [], [], _js=share_js)
|
388 |
-
with gr.Row():
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
🤗 With an enterprise-friendly license, 8,192 token context length, and fast large-batch inference via [multi-query attention](https://arxiv.org/abs/1911.02150), **StarCoder** is currently the best open-source choice for code-based applications.
|
397 |
-
|
398 |
-
📝 For more details, check out our [blog post]().
|
399 |
|
400 |
-
|
401 |
|
402 |
-
|
403 |
-
|
404 |
-
)
|
|
|
|
|
|
|
|
|
405 |
|
406 |
demo.queue(concurrency_count=16).launch(debug=True)
|
|
|
34 |
pass
|
35 |
|
36 |
repo = Repository(
|
37 |
+
local_dir="./data/", clone_from="HuggingFaceH4/starchat-prompts", use_auth_token=HF_TOKEN, repo_type="dataset"
|
38 |
)
|
39 |
repo.git_pull()
|
40 |
|
|
|
71 |
|
72 |
|
73 |
def generate(
|
|
|
74 |
system_message,
|
75 |
user_message,
|
76 |
chatbot,
|
|
|
125 |
top_p=top_p,
|
126 |
repetition_penalty=repetition_penalty,
|
127 |
do_sample=True,
|
128 |
+
truncate=2048,
|
129 |
seed=42,
|
130 |
stop_sequences=["<|end|>"],
|
131 |
)
|
|
|
148 |
chat = [(history[i].strip(), history[i + 1].strip()) for i in range(0, len(history) - 1, 2)]
|
149 |
|
150 |
yield chat, history, user_message, ""
|
151 |
+
|
152 |
if HF_TOKEN and do_save:
|
153 |
try:
|
154 |
print("Pushing prompt and completion to the Hub")
|
155 |
save_inputs_and_outputs(prompt, output, generate_kwargs)
|
156 |
except Exception as e:
|
157 |
print(e)
|
158 |
+
|
159 |
return chat, history, user_message, ""
|
160 |
|
161 |
+
|
162 |
examples = [
|
163 |
"How can I write a Python function to generate the nth Fibonacci number?",
|
164 |
+
"Draw me a map of the world using geopandas. Make it so that only Germany and Spain are colored red.",
|
165 |
"How do I get the current date using shell commands? Explain how it works.",
|
166 |
"What's the meaning of life?",
|
167 |
"Write a function in Python to reverse words in a given string.",
|
168 |
]
|
169 |
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
def clear_chat():
|
172 |
return [], []
|
173 |
|
|
|
178 |
return [x, y]
|
179 |
|
180 |
|
181 |
+
title = """<h1 align="center">⭐ StarChat Playground 💬</h1>"""
|
182 |
custom_css = """
|
183 |
#banner-image {
|
184 |
display: block;
|
|
|
201 |
gr.Image("StarCoderBanner.png", elem_id="banner-image", show_label=False)
|
202 |
with gr.Column():
|
203 |
gr.Markdown(
|
204 |
+
"""
|
205 |
+
💻 This demo showcases an **alpha** version of **[StarChat](https://huggingface.co/HuggingFaceH4/starchat-alpha)**, a variant of **[StarCoderBase](https://huggingface.co/bigcode/starcoderbase)** that was fine-tuned on the [Dolly](https://huggingface.co/datasets/databricks/databricks-dolly-15k) and [OpenAssistant](https://huggingface.co/datasets/OpenAssistant/oasst1) datasets to act as a helpful coding assistant. The base model has 16B parameters and was pretrained on one trillion tokens sourced from 80+ programming languages, GitHub issues, Git commits, and Jupyter notebooks (all permissively licensed).
|
206 |
+
|
|
|
|
|
207 |
📝 For more details, check out our [blog post]().
|
208 |
|
209 |
+
⚠️ **Intended Use**: this app and its [supporting model](https://huggingface.co/HuggingFaceH4/starchat-alpha) are provided as educational tools to explain large language model fine-tuning; not to serve as replacement for human expertise. In particular, this alpha version of **StarChat** has not been aligned to human preferences with techniques like RLHF, so the model can produce problematic outputs (especially when prompted to do so). For more details on the model's limitations in terms of factuality and biases, see the [model card](https://huggingface.co/HuggingFaceH4/starchat-alpha#bias-risks-and-limitations).
|
210 |
|
211 |
+
⚠️ **Data Collection**: by default, we are collecting the prompts entered in this app to further improve and evaluate the model. Do **NOT** share any personal or sensitive information while using the app! You can opt out of this data collection by removing the checkbox below.
|
212 |
"""
|
213 |
+
)
|
214 |
+
|
215 |
with gr.Row():
|
216 |
do_save = gr.Checkbox(
|
217 |
value=True,
|
|
|
219 |
info="You agree to the storage of your prompt and generated text for research and development purposes:",
|
220 |
)
|
221 |
with gr.Accordion(label="System Prompt", open=False, elem_id="parameters-accordion"):
|
222 |
+
system_message = gr.Textbox(
|
223 |
+
elem_id="system-message",
|
224 |
+
placeholder="Below is a conversation between a human user and a helpful AI coding assistant.",
|
225 |
+
show_label=False,
|
226 |
+
)
|
227 |
with gr.Row():
|
228 |
with gr.Box():
|
229 |
output = gr.Markdown()
|
|
|
234 |
user_message = gr.Textbox(placeholder="Enter your message here", show_label=False, elem_id="q-input")
|
235 |
with gr.Row():
|
236 |
send_button = gr.Button("Send", elem_id="send-btn", visible=True)
|
237 |
+
|
238 |
# regenerate_button = gr.Button("Regenerate", elem_id="send-btn", visible=True)
|
239 |
|
240 |
clear_chat_button = gr.Button("Clear chat", elem_id="clear-btn", visible=True)
|
|
|
269 |
)
|
270 |
max_new_tokens = gr.Slider(
|
271 |
label="Max new tokens",
|
272 |
+
value=512,
|
273 |
minimum=0,
|
274 |
maximum=2048,
|
275 |
step=4,
|
|
|
298 |
outputs=[output],
|
299 |
)
|
300 |
|
|
|
301 |
history = gr.State([])
|
302 |
# To clear out "message" input textbox and use this to regenerate message
|
303 |
last_user_message = gr.State("")
|
|
|
336 |
outputs=[chatbot, history, last_user_message, user_message],
|
337 |
)
|
338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
clear_chat_button.click(clear_chat, outputs=[chatbot, history])
|
340 |
# share_button.click(None, [], [], _js=share_js)
|
341 |
+
# with gr.Row():
|
342 |
+
# with gr.Column():
|
343 |
+
# gr.Image("StarCoderBanner.png", elem_id="banner-image", show_label=False)
|
344 |
+
# with gr.Column():
|
345 |
+
# gr.Markdown(
|
346 |
+
# """
|
347 |
+
# 💻 This demo showcases an instruction fine-tuned model based on **[StarCoder](https://huggingface.co/bigcode/starcoder)**, a 16B parameter model trained on one trillion tokens sourced from 80+ programming languages, GitHub issues, Git commits, and Jupyter notebooks (all permissively licensed).
|
|
|
|
|
|
|
|
|
348 |
|
349 |
+
# 🤗 With an enterprise-friendly license, 8,192 token context length, and fast large-batch inference via [multi-query attention](https://arxiv.org/abs/1911.02150), **StarCoder** is currently the best open-source choice for code-based applications.
|
350 |
|
351 |
+
# 📝 For more details, check out our [blog post]().
|
352 |
+
|
353 |
+
# ⚠️ **Intended Use**: this app and its [supporting model](https://huggingface.co/HuggingFaceH4/starcoderbase-finetuned-oasst1) are provided as educational tools to explain instruction fine-tuning; not to serve as replacement for human expertise. For more details on the model's limitations in terms of factuality and biases, see the [model card](https://huggingface.co/HuggingFaceH4/starcoderbase-finetuned-oasst1#bias-risks-and-limitations).
|
354 |
+
|
355 |
+
# ⚠️ **Data Collection**: by default, we are collecting the prompts entered in this app to further improve and evaluate the model. Do NOT share any personal or sensitive information while using the app! You can opt out of this data collection by removing the checkbox below.
|
356 |
+
# """
|
357 |
+
# )
|
358 |
|
359 |
demo.queue(concurrency_count=16).launch(debug=True)
|