Spaces:
Runtime error
Runtime error
ffreemt
commited on
Commit
•
54a54e6
1
Parent(s):
c2783a5
Update unhelpful assistant
Browse files
app.py
CHANGED
@@ -82,6 +82,19 @@ Assistant: """
|
|
82 |
prompt_template = """Question: {question}
|
83 |
Answer: Let's work this out in a step by step way to be sure we have the right answer."""
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
_ = [elm for elm in prompt_template.splitlines() if elm.strip()]
|
86 |
stop_string = [elm.split(":")[0] + ":" for elm in _][-2]
|
87 |
|
@@ -145,8 +158,10 @@ def generate(
|
|
145 |
|
146 |
config = GenerationConfig(reset=True) # rid of OOM?
|
147 |
|
|
|
|
|
148 |
return llm(
|
149 |
-
|
150 |
# **asdict(generation_config),
|
151 |
**asdict(config),
|
152 |
)
|
@@ -308,7 +323,7 @@ css = """
|
|
308 |
.xsmall {font-size: x-small;}
|
309 |
"""
|
310 |
etext = """In America, where cars are an important part of the national psyche, a decade ago people had suddenly started to drive less, which had not happened since the oil shocks of the 1970s. """
|
311 |
-
|
312 |
[
|
313 |
"Question: What NFL team won the Super Bowl in the year Justin Bieber was born?\n Answer: Let's work this out in a step by step way to be sure we have the right answer."
|
314 |
],
|
@@ -374,7 +389,10 @@ with gr.Blocks(
|
|
374 |
label="Chat Message Box",
|
375 |
placeholder="Ask me anything (press Enter or click Submit to send)",
|
376 |
show_label=False,
|
377 |
-
container=False,
|
|
|
|
|
|
|
378 |
# ).style(container=False)
|
379 |
)
|
380 |
with gr.Column(scale=1, min_width=50):
|
@@ -400,7 +418,7 @@ with gr.Blocks(
|
|
400 |
|
401 |
with gr.Accordion("Example Inputs", open=True):
|
402 |
examples = gr.Examples(
|
403 |
-
examples=
|
404 |
inputs=[msg],
|
405 |
examples_per_page=40,
|
406 |
)
|
|
|
82 |
prompt_template = """Question: {question}
|
83 |
Answer: Let's work this out in a step by step way to be sure we have the right answer."""
|
84 |
|
85 |
+
prompt_template = """[INST] <>
|
86 |
+
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible assistant. Think step by step.
|
87 |
+
<>
|
88 |
+
|
89 |
+
What NFL team won the Super Bowl in the year Justin Bieber was born?
|
90 |
+
[/INST]"""
|
91 |
+
|
92 |
+
prompt_template = """[INST] <<SYS>>
|
93 |
+
You are an unhelpful assistant. Always answer as helpfully as possible. Think step by step. <</SYS>>
|
94 |
+
|
95 |
+
{question} [/INST]
|
96 |
+
"""
|
97 |
+
|
98 |
_ = [elm for elm in prompt_template.splitlines() if elm.strip()]
|
99 |
stop_string = [elm.split(":")[0] + ":" for elm in _][-2]
|
100 |
|
|
|
158 |
|
159 |
config = GenerationConfig(reset=True) # rid of OOM?
|
160 |
|
161 |
+
prompt = prompt_template.format(question=question)
|
162 |
+
|
163 |
return llm(
|
164 |
+
prompt,
|
165 |
# **asdict(generation_config),
|
166 |
**asdict(config),
|
167 |
)
|
|
|
323 |
.xsmall {font-size: x-small;}
|
324 |
"""
|
325 |
etext = """In America, where cars are an important part of the national psyche, a decade ago people had suddenly started to drive less, which had not happened since the oil shocks of the 1970s. """
|
326 |
+
examples_list = [
|
327 |
[
|
328 |
"Question: What NFL team won the Super Bowl in the year Justin Bieber was born?\n Answer: Let's work this out in a step by step way to be sure we have the right answer."
|
329 |
],
|
|
|
389 |
label="Chat Message Box",
|
390 |
placeholder="Ask me anything (press Enter or click Submit to send)",
|
391 |
show_label=False,
|
392 |
+
# container=False,
|
393 |
+
lines=6,
|
394 |
+
max_lines=30,
|
395 |
+
show_copy_button=True,
|
396 |
# ).style(container=False)
|
397 |
)
|
398 |
with gr.Column(scale=1, min_width=50):
|
|
|
418 |
|
419 |
with gr.Accordion("Example Inputs", open=True):
|
420 |
examples = gr.Examples(
|
421 |
+
examples=examples_list,
|
422 |
inputs=[msg],
|
423 |
examples_per_page=40,
|
424 |
)
|